centos7下安装zabbix
前提条件:lamp已经配置成功。
1.防火墙及SELINUX关闭
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
2.导入zabbix源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
3.Zabbix安装
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-server zabbix-get
4.初始化数据库,创建zabbix数据库
建库,设置权限
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by ‘123456’;
示例:
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright © 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.08 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by ‘123456’;
Query OK, 0 rows affected (0.22 sec)
MariaDB [(none)]> quit
Bye
5.zabbix初始数据导入mysql
找到create.sql.gz的位置,将其导入zabbix库中
zcat create.sql.gz | mysql -uroot -p zabbix
示例:
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@localhost zabbix-server-mysql-3.2.11]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@localhost zabbix-server-mysql-3.2.11]# zcat create.sql.gz | mysql -uroot -p zabbix
Enter password:
6.配置zabbix-server
[root@localhost lib]# cd /etc/zabbix/
[root@localhost zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@localhost zabbix]# vim zabbix_server.conf
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
81:DBHost=localhost ###此行需要修改,去掉注释即可。
91:DBName=zabbix
107:DBUser=zabbix
115:DBPassword=zabbix ###此行需要修改,去掉注释加上密码。
287:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
413:Timeout=30
455:AlertScriptsPath=/usr/lib/zabbix/alertscripts
465:ExternalScripts=/usr/lib/zabbix/externalscripts
501:LogSlowQueries=3000
7.启动zabbix server并设置开机启动
systemctl enable zabbix-server
systemctl start zabbix-server
8.编辑Zabbix前端PHP配置,更改时区
[root@localhost zabbix]# vim /etc/httpd/conf.d/zabbix.conf
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 always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai ###此行需要修改,去掉注释,改成Asia/Shanghai
9.重新启动httpd
[root@localhost zabbix]# service httpd restart
10.zabbix web
浏览器访问:192.168.11.12/zabbix (替换为虚拟机ip)
根据提示填写,即可。
11.启动zabbix-agent
因为server端也安装了agent,所以可以监控自己。
[root@localhost zabbix]# systemctl start zabbix-agent.service
[root@localhost zabbix]# systemctl enable zabbix-agent.service
完成后,根据需求配置主机等。
12.其它主机安装,zabbix-agent
-
导入zabbix源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
-
安装zabbix-agent
yum install zabbix-agent -y
-
修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
95 Server=192.168.11.12 #Server端的IP地址
136 ServerActive=192.168.11.12 #Server端的IP地址
147 Hostname=Zabbix server #必须与zabbix server端创建主机时候输入的zabbix agent端的host name一致。 -
启动服务
[root@localhost zabbix]# systemctl start zabbix-agent.service
[root@localhost zabbix]# systemctl enable zabbix-agent.service