1.環(huán)境準(zhǔn)備
1.安裝nginx
2.部署php-fpm
3.部署數(shù)據(jù)庫(kù)
4.部署zabbix服務(wù)端
2.部署nginx
配置nginx源
[root@m03 ~]# cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
##安裝nginx
[root@m03 ~]# yum install nginx --enablerepo=nginx-stable
3.部署php
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release.noarch -y #webtatic 要求
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm #webtatic源
##方案2.[root@zabbix-server ~]# yum install epel-release -y
[root@zabbix-server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
##安裝php
yum install php72w-cli php72w-fpm php72w-gd php72w-mbstring php72w-bcmath php72w-xml php72w-ldap php72w mysqlnd -y
4.部署mariadb
1.安裝數(shù)據(jù)庫(kù)
[root@m03 ~]# yum install -y mariadb-server
2.配置數(shù)據(jù)庫(kù)(刪除無用的庫(kù)和用戶)
[root@m03 ~]# mysql_secure_installation
#進(jìn)去之后選擇刪除沒用的用戶和庫(kù)其他的都可以y
MariaDB [(none)]> select user,host from mysql.user ;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
| root | m03 |
+------+-----------+
4 rows in set (0.00 sec)
MariaDB [(none)]> show databases;
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]>
###創(chuàng)建zabbix庫(kù)
create database zabbix character set utf8 collate utf8_bin;
###創(chuàng)建zabbix用戶密碼為123456
grant all on zabbix.* to zabbix@'localhost' identified by '123456';
5.部署zabbix
1.安裝zabbix yum源
rpm -Uvh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-
1.el7.noarch.rpm
#zabbix-release.....rpm zabbix yum源的配置文件
[root@m03 ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
# 安裝 zabbix-server
[root@m03 ~]# yum install -y zabbix-server zabbix-agent2
# zabbix 數(shù)據(jù)庫(kù)導(dǎo)入數(shù)據(jù)
[root@m03 ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.13/create.sql.gz |mysql -uzabbix-p123456 zabbix
# zabbix 服務(wù)端 配置連接數(shù)據(jù)庫(kù)
[root@m03 ~]# vim /etc/zabbix/zabbix_server.conf
[root@m03 ~]# grep ^DB /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
#修改后 zabbix 服務(wù)端開啟的功能 (不用修改)
[root@m03 ~]# grep '^[a-Z]' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
#啟動(dòng) zabbix-server
root@m03 ~]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to
/usr/lib/systemd/system/zabbix-server.service.
[root@m03 ~]# systemctl start zabbix-server.service
5.1zabbix前端頁(yè)面準(zhǔn)備
#使用源碼包
tar xf zabbix-5.0.13.tar.gz
cd zabbix-5.0.13/
mv ui/* /code/zabbix/
chown -R nginx.nginx /code/zabbix/
#web頁(yè)面安裝
6.nginx配置文件
[root@zabbix ~]# egrep '^$|^#' /etc/nginx/conf.d/zabbix.conf
[root@zabbix ~]# cat /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name www.zabbix.cn;
root /code/zabbix;
location / {
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
7.php配置文件
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
8.數(shù)據(jù)庫(kù)已經(jīng)在安裝時(shí)候已經(jīng)完成測(cè)試就行
mysql -uroot -p123
mysql -uzabbix -p123456
use 進(jìn)入庫(kù)中看是否表導(dǎo)進(jìn)去了
show tables;
9.zabbix配置文件
[root@zabbix ~]# grep '^[a-Z]' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartVMwareCollectors=5
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1