Zabbix4.0部署
官网 https://www.zabbix.com/cn/manuals
1.zabbix安装
1.配置yum仓库
https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/
安装
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
# 修改repo文件,改为清华源
sed -i 's#repo.zabbix.com#mirrors.tuna.tsinghua.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo
2.安装zabbix服务端(前端)、zabbix连接数据库、zabbix-agent(客户端)
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server
启动mariadb数据库,设置开机自启
systemctl start mariadb && systemctl enable mariadb
3.设置mariadb数据库,创建zabbix库,存储监控数据,且创建账号
mysqladmin password www.yuchaoit.cn
mysql -uroot -pwww.yuchaoit.cn -e 'create database zabbix character set utf8 collate utf8_bin;'
mysql -uroot -pwww.yuchaoit.cn -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'www.yuchaoit.cn';"
测试zabbix用户
[root@zabbix4-server ~]#mysql -uzabbix -pwww.yuchaoit.cn -e "show databases;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
| zabbix |
+--------------------+
4.导入zabbix的数据库
[root@zabbix4-server ~]#zcat /usr/share/doc/zabbix-server-mysql-4.0.41/create.sql.gz | mysql -uroot -pwww.yuchaoit.cn zabbix
5.编辑zabbix服务端配置文件(修改数据库部分即可)
[root@zabbix4-server ~]#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=www.yuchaoit.cn
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
6.启动zabbix服务端,且开机自启
systemctl start zabbix-server && systemctl enable zabbix-server
7.检查zabbix
[root@zabbix4-server ~]#ps -ef|grep zabbix
[root@zabbix4-server ~]#netstat -tunlp|grep zabbix
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3125/zabbix_server
tcp6 0 0 :::10051 :::* LISTEN 3125/zabbix_server
2.apache配置
1.修改时区
[root@zabbix4-server /tmp]#grep -in 'shanghai' /etc/httpd/conf.d/zabbix.conf
20: php_value date.timezone Asia/Shanghai
2.重启
systemctl restart httpd
关于apache和zabbix是怎么结合的?
# 看apache配置文件就行了,你可以访问zabbix路由即可,apache自动加载php模块,解析请求
[root@zabbix4-server /var/www/html]#cat /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
3.访问zabbix前端安装界面
直接访问服务器的80端口的apache服务,已经和zabbix结合了,其实就是一个LAMP架构了而已。
zabbix-web-mysql封装了php和httpd
[root@zabbix4-server /var/www/html]#rm -f phpinfo.php
4.访问zabbix入口
http://ip/zabbix/
安装环境检查
配置数据库连接
配置zabbix服务端的主机端口信息
最终确认
安装成功
登录zabbix
默认登录账号:Admin
密码:zabbix
zabbix首页
修改语言为中文
修复中文乱码
解决办法,这是因为缺少zabbix所需的字体
# 文泉仪微黑字体
[root@zabbix4-server ~]#yum install wqy-microhei-fonts -y
# 拷贝字体给zabbix用,覆盖图形字体
[root@zabbix4-server ~]#cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/zabbix/assets/fonts/graphfont.ttf
cp: overwrite ‘/usr/share/zabbix/assets/fonts/graphfont.ttf’? y
标签:cn,部署,zabbix4,zabbix,server,Zabbix,php,root
From: https://www.cnblogs.com/chunjeh/p/17730821.html