mysql -uroot
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
MariaDB [(none)]> quit
3.4 创建初始数据库
mysql -uroot
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
MariaDB [(none)]> quit
导入初始模式和数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
为Zabbix服务器配置数据库:
[root@Rich七哥 log]# vim /etc/zabbix/zabbix_server.conf
(修改前)
/etc/zabbix/zabbix_server.conf:38:LogFile=http://www.likecs.com/var/log/zabbix/zabbix_server.log
/etc/zabbix/zabbix_server.conf:49:LogFileSize=0
/etc/zabbix/zabbix_server.conf:72:PidFile=http://www.likecs.com/var/run/zabbix/zabbix_server.pid
/etc/zabbix/zabbix_server.conf:82:SocketDir=http://www.likecs.com/var/run/zabbix
/etc/zabbix/zabbix_server.conf:91:# DBHost=localhost
/etc/zabbix/zabbix_server.conf:102:### Option: DBSchema
/etc/zabbix/zabbix_server.conf:117:
/etc/zabbix/zabbix_server.conf:125:
/etc/zabbix/zabbix_server.conf:330:
/etc/zabbix/zabbix_server.conf:448:### Option: TrapperTimeout
/etc/zabbix/zabbix_server.conf:490:### Option: ExternalScripts
/etc/zabbix/zabbix_server.conf:500:### Option: FpingLocation
/etc/zabbix/zabbix_server.conf:536:### Option: TmpDir
[root@Rich七哥 log]# grep -n '^' [a-Z] /etc/zabbix/zabbix_server.conf
(修改后)
启动Zabbix服务器和代理进程,并在系统启动时启动
systemctl start zabbix-server zabbix-agent httpd && systemctl enable zabbix-server zabbix-agent httpd
为Zabbix前端配置PHP,更改时区
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
重启系统
reboot
然后打开浏览器,输入你的IP地址进行访问测试
ip address:/zabbix/
访问成功!
至此,zabbix监控系统就搭建完毕了!
附录:
(zabbix的一些包名以及用途)
zabbix-server-mysql-3.4.6-1.el7.x86_64 (zabbix server主安装程序)
zabbix-agent-3.4.6-1.el7.x86_64 (zabbix agent 主安装程序)
zabbix-web-3.4.6-1.el7.noarch(zabbix web安装程序)
zabbix-get-3.4.6-1.el7.x86_64.rpm (zabbix server安装程序,用于获取监控数据)
zabbix-web-mysql-3.4.6-1.el7.noarch.rpm (zabbix web连接数据库的安装程序)
zabbix-release-3.4.2-1.el7.noarch.rpm (生成zabbix yum源配置文件)
zabbix-sender-3.4.6-1.el7.x86_64.rpm (zabbix agent安装程序,用于发送监控数据)
你用”rpm -q 包名“的命令去查看一下以上包是否安装,以上包都安装上了才是正确的。接着重点说下两个包(zabbix-get和zabbix-sender),zabbix-get是安装在zabbix server端的,用于和zabbix agent端通信,用于从agent端主动拉取数据到server端;zabbix-sender是安装在zabbix agent端,用于和zabbix server端通信,用于主动把agent端的数据推送给server端。
zabbix-get (在server端安装)
zabbix-sender(在agent端安装)