character_set_server = utf8
DBHost=127.0.0.1 //在DBName=zabbix上面增加
DBPassword=aming-zabbix //在DBuser下面增加
A机器
[root@hf-01 ~]# wget wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
B机器
[root@hf-02 ~]# wget wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
A机器安装rpm包
[root@hf-01 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
B机器安装rpm包
[root@hf-02 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
[root@hf-01 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo zabbix.repo
CentOS-CR.repo CentOS-Media.repo epel.repo.1
CentOS-Debuginfo.repo CentOS-Sources.repo epel-testing.repo
[root@hf-01 ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
B机器
[root@hf-02 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
A机器(因为之前安装过mysql)
[root@hf-01 ~]# !ps
ps aux| grep mysql
root 1203 0.0 0.1 115388 1684 ? S 01:22 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/hf-01.pid
mysql 1498 0.1 45.3 973552 458376 ? Sl 01:22 0:03 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/hf-01.err --pid-file=/data/mysql/hf-01.pid
root 2586 0.0 0.0 112676 980 pts/1 R+ 02:10 0:00 grep --color=auto mysql
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# vim /etc/my.cnf
在[mysqld]下添加字符集
character_set_server = utf8
保存退出
A机器
[root@hf-01 ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@hf-01 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix character set utf8; //创建zabbix库,并指定编码为utf8
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'hanfeng-zabbix';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@hf-01 zabbix-server-mysql-3.2.11]#
A机器
[root@hf-01 zabbix-server-mysql-3.2.11]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@hf-01 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz
[root@hf-01 zabbix-server-mysql-3.2.11]# ls
AUTHORS ChangeLog COPYING create.sql NEWS README
[root@hf-01 zabbix-server-mysql-3.2.11]#
A机器
[root@hf-01 zabbix-server-mysql-3.2.11]# mysql -uroot -phanfeng zabbix < create.sql
Warning: Using a password on the command line interface can be insecure.
[root@hf-01 zabbix-server-mysql-3.2.11]#
[root@hf-01 ~]# systemctl start zabbix-server
[root@hf-01 ~]#
[root@hf-01 ~]# ps aux |grep nginx
root 2866 0.0 0.0 112676 984 pts/1 R+ 03:06 0:00 grep --color=auto nginx
[root@hf-01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1517/master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1191/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1517/master
tcp6 0 0 :::3306 :::* LISTEN 2749/mysqld
tcp6 0 0 :::22 :::* LISTEN 1191/sshd
[root@hf-01 ~]# systemctl start httpd
[root@hf-01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1517/master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1191/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1517/master
tcp6 0 0 :::3306 :::* LISTEN 2749/mysqld
tcp6 0 0 :::80 :::* LISTEN 2874/httpd
tcp6 0 0 :::22 :::* LISTEN 1191/sshd
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@hf-01 ~]# 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.
[root@hf-01 ~]#
[root@hf-01 ~]# ps aux |grep zabbix
zabbix 2863 0.0 0.3 251752 3332 ? S 03:04 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
root 2926 0.0 0.0 112676 984 pts/1 R+ 03:15 0:00 grep --color=auto zabbix
[root@hf-01 ~]#
[root@hf-01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1517/master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1191/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1517/master
tcp6 0 0 :::3306 :::* LISTEN 2749/mysqld
tcp6 0 0 :::80 :::* LISTEN 2874/httpd
tcp6 0 0 :::22 :::* LISTEN 1191/sshd
[root@hf-01 ~]#
[root@hf-01 ~]# tail /var/log/zabbix/zabbix_server.log
2863:20180103:033242.719 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
2863:20180103:033242.719 database is down: reconnecting in 10 seconds
2863:20180103:033252.720 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
2863:20180103:033252.720 database is down: reconnecting in 10 seconds
2863:20180103:033302.721 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
2863:20180103:033302.721 database is down: reconnecting in 10 seconds
2863:20180103:033312.722 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
2863:20180103:033312.723 database is down: reconnecting in 10 seconds
2863:20180103:033322.724 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
2863:20180103:033322.724 database is down: reconnecting in 10 seconds
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# vim /etc/zabbix/zabbix_server.conf
搜索/DBHost
在DBName=zabbix上面增加
DBHost=127.0.0.1
在DBuser下面增加
DBPassword=hanfeng-zabbix
保存退出
A机器
[root@hf-01 ~]# systemctl restart zabbix-server
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# ps aux |grep zabbix |wc -l
29
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# netstat -lntp |grep zabbix
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3303/zabbix_server
tcp6 0 0 :::10051 :::* LISTEN 3303/zabbix_server
[root@hf-01 ~]#
A机器
[root@hf-01 ~]# vim /etc/php.ini
搜索 /timezone
将 ;date.timezone 改为如下
date.timezone = Asia/Shanghai
保存退出
[root@hf-01 ~]# systemctl restart httpd
[root@hf-01 ~]#
29.这时再来刷新浏览器,会发现都变成OK了
30.这时再来 Next step ,来配置数据库相关信息
Server=127.0.0.1修改为Server=192.168.133.130 //定义服务端的ip(被动模式)
ServerActive=127.0.0.1修改为ServerActive=192.168.133.130 //定义服务端的ip(主动模式)
Hostname=Zabbix server修改为Hostname=aming-123 //这是自定义的主机名,一会还需要在web界面下设置同样的主机名
B机器
[root@hf-02 ~]# wget wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
B机器
[root@hf-02 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
B机器
[root@hf-02 ~]# vi /etc/zabbix/zabbix_agentd.conf
搜索 /Server
Server=192.168.202.130
# 定义服务端的ip(被动模式),配置文件中默认是本机的IP
搜索 /ServerActive
ServerActive=192.168.133.130
#定义服务端的ip(主动模式)
#这个涉及到一个主动和被动模式;如果这里不填写服务中心的IP,那么就只能使用被动模式;这个IP是主动模式时候用的
搜索 /Hostname
Hostname=Zabbix server修改为Hostname=hf-02
#这是自定义的主机名,一会还需要在web界面下设置同样的主机名
保存退出
[root@hf-02 ~]# systemctl start zabbix-agent
[root@hf-02 ~]#
[root@hf-02 ~]# ps aux |grep zabbix
zabbix 2566 0.0 0.1 80592 1280 ? S 13:16 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 2567 0.0 0.1 80592 1296 ? S 13:16 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 2568 0.0 0.1 80592 1836 ? S 13:16 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 2569 0.0 0.1 80592 1836 ? S 13:16 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 2570 0.0 0.1 80592 1836 ? S 13:16 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 2571 0.0 0.2 80720 2180 ? S 13:16 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 2573 0.0 0.0 112664 972 pts/0 R+ 13:17 0:00 grep --color=auto zabbix
[root@hf-02 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1301/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1997/master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2566/zabbix_agentd
tcp6 0 0 :::22 :::* LISTEN 1301/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1997/master
tcp6 0 0 :::10050 :::* LISTEN 2566/zabbix_agentd
[root@hf-02 ~]#
[root@hf-02 ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@hf-02 ~]#