Zabbix获取
在网站 https://www.zabbix.com/cn/download_sources 下载安装包zabbix-4.0.19.tar.gz 到/usr/src/
服务器时间同步
服务器时间若不准确会导致Zabbix编译安装会失败
1 2 3 4 5
| # ntpdate ntp1.aliyun.com 或 # ntpdate us.pool.ntp.org 或 # ntpdate time.windows.com
|
MySQL安装及数据库创建
MySQL可以yum安装或编译安装,参考之前文档
1. Zabbix数据库账号创建
1 2 3 4 5
| mysql> alter user 'root'@'localhost' identified by 'Zabbix!123';
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'Zabbix!123';
|
2. Zabbix数据库导入
1 2 3
| # tar zxvf zabbix-4.0.19.tar.gz
# cd /usr/src/zabbix-4.0.19/database/mysql
|
导入:
1 2 3
| # mysql -uzabbix -p'Zabbix!123' zabbix < schema.sql # mysql -uzabbix -p'Zabbix!123' zabbix < images.sql # mysql -uzabbix -p'Zabbix!123' zabbix < data.sql
|
依赖包安装
1
| # yum install libxml2-devel libcurl-devel libevent-devel net-snmp-devel mysql-community-devel -y
|
创建zabbix用户和组
1 2
| # groupadd zabbix # useradd -g zabbix zabbix -s /sbin/nologin
|
openjdk安装
1 2
| # yum search openjdk # yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel -y
|
编译安装Zabbix
1 2 3
| # ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
# make install
|
Zabbix安装目录:/usr/local/zabbix
Zabbix Server配置文件
1
| # vi /usr/local/zabbix/etc/zabbix_server.conf
|
修改:
1 2 3 4
| DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=Zabbix!123
|
启动Zabbix Server服务
1
| # /usr/local/zabbix/sbin/zabbix_server
|
或设置Zabbix启动服务:
1
| # vi /usr/lib/systemd/system/zabbix-server.service
|
添加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| [Unit] Description=Zabbix Server After=syslog.target After=network.target
[Service] Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf" EnvironmentFile=-/etc/sysconfig/zabbix-server Type=forking Restart=on-failure PIDFile=/tmp/zabbix_server.pid KillMode=control-group ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE ExecStop=/bin/kill -SIGTERM $MAINPID RestartSec=10s TimeoutSec=0
[Install] WantedBy=multi-user.target
|
启动Zabbix Agent服务
1
| # /usr/local/zabbix/sbin/zabbix_agentd
|
检查Zabbix相关服务:
部署Zabbix Web界面
Zabbix Web前端使用PHP,所以必须运行在支持PHP的Web服务器上
1. 复制Zabbix的php文件
1 2
| # cd /usr/src/zabbix-4.0.19 # cp /usr/src/zabbix-4.0.19/frontends/php/* /usr/local/nginx/html/ -rf
|
2. 在Nginx上设置站点
1
| # vi /usr/local/nginx/conf/nginx.conf
|
添加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| server { listen 80; server_name localhost;
access_log logs/zabbix.access.log main;
location / { root html; index index.php index.html index.htm; }
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
|
重启Nginx服务,测试是否能正常开启Zabbix配置向导网站 http://192.168.229.88
Zabbix配置向导
根据向导提示信息修改php配置
1
| # vi /usr/local/php/etc/php.ini
|
修改如下配置:
1 2 3 4 5
| post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = Asia/Shanghai always_populate_raw_post_data = -1
|
Zabbix需要启动的服务:
- mysql (# systemctl start mysqld.service)
- nginx (# systemctl start nginx.service)
- php (# systemctl start php-fpm.service)
- zabbix_server (# systemctl start zabbix-server.service)
- zabbix_agentd (需执行运行: # /usr/local/zabbix/sbin/zabbix_agentd)