CentOS7下yum安装zabbix3.4
系统环境
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[[email protected] ~]# uname -r
3.10.0-862.el7.x86_64
防火墙,selinux已关闭
服务端 |
192.168.231.130 node1 |
zabbix-server、zabbix-agent |
作为服务端,也最为客户端,监控本地 |
客户端 |
192.168.231.131 node2 |
zabbix-agent |
客户端 |
#注意
- zabbix需要lamp环境,node1上以搭建lamp环境,可参考CentOS7用yum搭建LAMP环境
- 服务端和客户端时间要一致
安装zabbix的yum源
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
服务端安装
[[email protected] ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get -y
[[email protected] ~]# mysql -uroot -pzabbix
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 41
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
初始化数据库
[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.15/
[[email protected] zabbix-server-mysql-3.4.15]# zcat create.sql.gz | mysql -uroot -p zabbix
Enter password:
查看数据库是否有表单生成导入
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
......
修改zabbix-server配置文件
[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf
#如果服务端有多个IP地址需要指定SourceIP
SourceIP=192.168.231.130
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
启动zabbix-server并设置开机自启
[[email protected] ~]# systemctl start zabbix-server
[[email protected] ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
编辑zabbix-server的php内部参数
<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>
重启httpd,刷新配置
[[email protected] ~]# systemctl restart httpd
修改zabbix-agent.conf
[[email protected] ~]# vim /etc/zabbix/zabbix_agentd.conf
SourceIP=192.168.231.130
Server=192.168.231.130
ServerActive=192.168.231.130
Hostname=Zabbix server
启动zabbix-agent
[[email protected] ~]# systemctl start zabbix-agent
客户端安装
[[email protected] ~]# yum install zabbix-agent zabbix-sender -y
[[email protected] ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.231.130
ServerActive=192.168.231.130
Hostname=Zabbix server
服务端客户端连通性检查
服务器端安装了 zabbix-get
工具便可以进行到客户端的测试
[[email protected] ~]# zabbix_get --host 192.168.231.131 --port 10050 --key "system.cpu.load[all,avg1]"
0.000000
zabbix网页安装
网页输入192.168.231.130/zabbix即可进入安装
安装环境满足要求
配置DB连接,要与zabbix_server.conf中的信息一致
zabbix服务器的详细信息
信息汇总
安装完成
浏览器登录访问:
默认的用户名Admin 密码为 zabbix
进入后界面为英文,点击用户设置语言为中文
改成中文后显示图形,下边的中文还可能会乱码,所以还要修改字体配置:
#把windows下C:\Windows\Fonts中的如下文件复制到linux中
[[email protected] ~]# mv simkai.ttf /usr/share/zabbix/fonts/
[[email protected] ~]# cd /usr/share/zabbix/fonts/
#修改权限
[[email protected] fonts]# chmod 777 simkai.ttf
[[email protected] fonts]# ls
graphfont.ttf simkai.ttf
#对原有文件进行备份
[[email protected] fonts]# cp graphfont.ttf graphfont.ttf.bak
#覆盖
[[email protected] fonts]# mv simkai.ttf graphfont.ttf
mv: overwrite ‘graphfont.ttf’? y
在打开图形界面时,下边所圈内容就不会乱码了
OK!