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了php
30.這時再來 Next step ,來配置數據庫相關信息mysql
登陸管理頁,默認的帳號是Admin,密碼爲zabbixlinux
在登陸進zabbix以後,首先須要去更改密碼(由於默認的密碼你們都知道的),如果在線上環境不更改密碼,很容易被別人拿到後臺權限ios
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=192.168.202.130 # 定義服務端的ip(被動模式) ServerActive=192.168.133.130 #定義服務端的ip(主動模式) #這個涉及到一個主動和被動模式;若是這裏不填寫服務中心的IP,那麼就只能使用被動模式;這個IP是主動模式時候用的 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 ~]#
A機器 [root@hf-01 ~]# mysql -uroot -phanfeng Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 342 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>
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>