character_set_server = utf8
DBHost=127.0.0.1 //在DBName=zabbix上面增長 DBPassword=yong-zabbix //在DBuser下面增長
A機器 [root@yong-01 ~]# wget wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm B機器 [root@yong-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@yong-01 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm B機器安裝rpm包 [root@yong-02 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
[root@yong-01 ~]# ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo epel-testing.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo zabbix.repo [root@yong-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
A機器 [root@yong-01 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql B機器 [root@yong-02 ~]# yum install -y zabbix-agent
A機器(由於以前安裝過mysql) [root@yong-01 ~]# ps aux|grep mysql root 1252 0.0 0.0 115388 1688 ? S 20:47 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/yong-01.pid mysql 1412 0.1 24.3 1189580 457612 ? Sl 20:47 0:02 /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/yong-01.err --pid-file=/data/mysql/yong-01.pid --socket=/tmp/mysql.sock root 1862 0.0 0.0 112676 984 pts/0 R+ 21:14 0:00 grep --color=auto mysql
A機器 [root@yong-01 ~]# vim /etc/my.cnf 在[mysqld]下添加字符集 character_set_server = utf8
A機器 [root@yong-01 ~]# /etc/init.d/mysqld restart Shutting down MySQL.... SUCCESS! Starting MySQL. SUCCESS!
A機器 [root@yong-01 ~]# mysql -uroot -p111111 mysql> create database zabbix character set utf8; //建立zabbix庫,並指定編碼爲utf8 Query OK, 1 row affected (0.00 sec)
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'yong-zabbix'; Query OK, 0 rows affected (0.00 sec)
A機器 [root@yong-01 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/ [root@yong-01 zabbix-server-mysql-3.2.11]#
A機器 [root@yong-01 zabbix-server-mysql-3.2.11]# ls AUTHORS ChangeLog COPYING create.sql.gz NEWS README [root@yong-01 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz [root@yong-01 zabbix-server-mysql-3.2.11]# ls AUTHORS ChangeLog COPYING create.sql NEWS README
A機器 [root@yong-01 zabbix-server-mysql-3.2.11]# mysql -uroot -p111111 zabbix < create.sql Warning: Using a password on the command line interface can be insecure.
[root@yong-01 ~]# systemctl start zabbix-server
[root@yong-01 ~]# systemctl stop nginx [root@yong-01 ~]# systemctl start httpd [root@yong-01 ~]# netstat -lntp |grep 80 tcp6 0 0 :::80 :::* LISTEN 2179/httpd
A機器 [root@yong-01 ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@yong-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@yong-01 ~]# systemctl disable nginx nginx.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig nginx off
[root@yong-01 ~]# ps aux |grep zabbix zabbix 2255 0.0 0.1 254588 3488 ? S 21:31 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf root 2387 0.0 0.0 112676 980 pts/0 R+ 21:33 0:00 grep --color=auto zabbix
[root@yong-01 ~]# 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:111 0.0.0.0:* LISTEN 724/rpcbind tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 1068/rpc.mountd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1045/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1452/master tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:56997 0.0.0.0:* LISTEN 1063/rpc.statd tcp 0 0 0.0.0.0:32838 0.0.0.0:* LISTEN - tcp6 0 0 :::45355 :::* LISTEN - tcp6 0 0 :::111 :::* LISTEN 724/rpcbind tcp6 0 0 :::80 :::* LISTEN 2179/httpd tcp6 0 0 :::20048 :::* LISTEN 1068/rpc.mountd tcp6 0 0 :::22 :::* LISTEN 1045/sshd tcp6 0 0 ::1:25 :::* LISTEN 1452/master tcp6 0 0 :::36508 :::* LISTEN 1063/rpc.statd tcp6 0 0 :::2049 :::* LISTEN - tcp6 0 0 :::3306 :::* LISTEN 2108/mysqld
[root@yong-01 ~]# tail /var/log/zabbix/zabbix_server.log 2255:20180708:214413.675 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 2255:20180708:214413.675 database is down: reconnecting in 10 seconds 2255:20180708:214423.676 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 2255:20180708:214423.677 database is down: reconnecting in 10 seconds 2255:20180708:214433.677 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 2255:20180708:214433.677 database is down: reconnecting in 10 seconds 2255:20180708:214443.678 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 2255:20180708:214443.678 database is down: reconnecting in 10 seconds 2255:20180708:214453.679 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 2255:20180708:214453.679 database is down: reconnecting in 10 seconds
A機器 [root@yong-01 ~]# vim /etc/zabbix/zabbix_server.conf 搜索/DBHost 在DBName=zabbix上面增長 DBHost=127.0.0.1 在DBuser下面增長 DBPassword=yong-zabbix
A機器 [root@yong-01 ~]# systemctl restart zabbix-server.service
A機器 [root@yong-01 ~]# ps aux |grep zabbix |wc -l 29
A機器 [root@yong-01 ~]# netstat -lntp|grep zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2813/zabbix_server tcp6 0 0 :::10051 :::* LISTEN 2813/zabbix_server
A機器 [root@yong-01 ~]# vim /etc/php.ini 搜索 /timezone 將 ;date.timezone 改成以下 date.timezone = Asia/Shanghai
[root@yong-01 ~]# systemctl restart httpd
30.這時再來 Next step ,來配置數據庫相關信息php
登陸管理頁,默認的帳號是Admin,密碼爲zabbixmysql
在登陸進zabbix以後,首先須要去更改密碼(由於默認的密碼你們都知道的),如果在線上環境不更改密碼,很容易被別人拿到後臺權限linux
Server=127.0.0.1修改成Server=192.168.180.134 //定義服務端的ip(被動模式) ServerActive=127.0.0.1修改成ServerActive=192.168.180.134 //定義服務端的ip(主動模式) Hostname=Zabbix server修改成Hostname=yong-02 //這是自定義的主機名,一會還須要在web界面下設置一樣的主機名
B機器 [root@yong-02 ~]# wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
B機器 [root@yong-02 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
B機器 [root@yong-02 ~]# vi /etc/zabbix/zabbix_agentd.conf Server=192.168.180.134 # 定義服務端的ip(被動模式) ServerActive=192.168.180.134 #定義服務端的ip(主動模式) #這個涉及到一個主動和被動模式;若是這裏不填寫服務中心的IP,那麼就只能使用被動模式;這個IP是主動模式時候用的 Hostname=Zabbix server修改成Hostname=yong-02 #這是自定義的主機名,一會還須要在web界面下設置一樣的主機名
[root@yong-02 ~]# systemctl start zabbix-agent.service
[root@yong-02 ~]# ps aux |grep zabbix zabbix 2036 0.0 0.0 80664 1264 ? S 22:14 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf zabbix 2037 0.0 0.0 80664 1300 ? S 22:14 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec] zabbix 2038 0.0 0.0 80664 1844 ? S 22:14 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] zabbix 2039 0.0 0.0 80664 1844 ? S 22:14 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] zabbix 2040 0.0 0.0 80664 1844 ? S 22:14 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] zabbix 2041 0.0 0.1 80796 2208 ? S 22:14 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec] root 2043 0.0 0.0 112676 980 pts/0 R+ 22:14 0:00 grep --color=auto zabbix
[root@yong-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.
A機器 [root@yong-01 ~]# mysql -uroot -p111111
mysql> use zabbix Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql>
show tables;
mysql> desc users; +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ | userid | bigint(20) unsigned | NO | PRI | NULL | | | alias | varchar(100) | NO | UNI | | | | name | varchar(100) | NO | | | | | surname | varchar(100) | NO | | | | | passwd | char(32) | NO | | | | | url | varchar(255) | NO | | | | | autologin | int(11) | NO | | 0 | | | autologout | int(11) | NO | | 900 | | | lang | varchar(5) | NO | | en_GB | | | refresh | int(11) | NO | | 30 | | | type | int(11) | NO | | 1 | | | theme | varchar(128) | NO | | default | | | attempt_failed | int(11) | NO | | 0 | | | attempt_ip | varchar(39) | NO | | | | | attempt_clock | int(11) | NO | | 0 | | | rows_per_page | int(11) | NO | | 50 | | +----------------+---------------------+------+-----+---------+-------+ 16 rows in set (0.01 sec) mysql>
mysql> update users set passwd=md5('aminglinux') where alias='Admin'; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql>
mysql> select * from users\G; *************************** 1. row *************************** userid: 1 alias: Admin name: Zabbix surname: Administrator passwd: 683cb8e76a8889fdc5161e3fa7e51f2d url: autologin: 1 autologout: 0 lang: zh_CN refresh: 30 type: 3 theme: default attempt_failed: 0 attempt_ip: attempt_clock: 0 rows_per_page: 50 *************************** 2. row *************************** userid: 2 alias: guest name: surname: passwd: d41d8cd98f00b204e9800998ecf8427e url: autologin: 0 autologout: 900 lang: en_GB refresh: 30 type: 1 theme: default attempt_failed: 0 attempt_ip: attempt_clock: 0 rows_per_page: 50 2 rows in set (0.00 sec) ERROR: No query specified mysql>