[root@Node3 ~]# cat /etc/redhat-release //查看系統版本 CentOS Linux release 7.4.1708 (Core) [root@Node3 ~]# ip -4 addr | grep 172.17 //查看IP地址 inet 172.17.21.208/24 brd 172.17.21.255 scope global ens192
[root@Node3 ~]# cd /usr/src/zabbix3.4.5/ //軟件包下載目錄 [root@Node3 zabbix3.4.5]# ls zabbix-agent-3.4.5-1.el7.x86_64.rpm zabbix-proxy-sqlite3-3.4.5-1.el7.x86_64.rpm zabbix-web-japanese-3.4.5-1.el7.noarch.rpm zabbix-get-3.4.5-1.el7.x86_64.rpm zabbix-sender-3.4.5-1.el7.x86_64.rpm zabbix-web-mysql-3.4.5-1.el7.noarch.rpm zabbix-java-gateway-3.4.5-1.el7.x86_64.rpm zabbix-server-mysql-3.4.5-1.el7.x86_64.rpm zabbix-web-pgsql-3.4.5-1.el7.noarch.rpm zabbix-proxy-mysql-3.4.5-1.el7.x86_64.rpm zabbix-server-pgsql-3.4.5-1.el7.x86_64.rpm zabbix-proxy-pgsql-3.4.5-1.el7.x86_64.rpm zabbix-web-3.4.5-1.el7.noarch.rpm
[root@Node3 ~]# systemctl stop firewalld.service //停掉防火牆 [root@Node3 ~]# systemctl disable firewalld.service //禁止防火牆開機自啓動 Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@Node3 ~]# iptables -X [root@Node3 ~]# iptables -Z [root@Node3 ~]# iptables -F [root@Node3 ~]# iptables -vnL Chain INPUT (policy ACCEPT 228 packets, 15806 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 252 packets, 19733 bytes) pkts bytes target prot opt in out source destination
[root@Node3 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config //在/etc/selinux/config 把SELNUX=enforcing換成SELINUX=disabled [root@Node3 ~]# setenforce 0 setenforce: SELinux is disabled [root@Node3 ~]# getenforce Disabled [root@Node3 ~]# systemctl reboot
注:部署官方文檔
rpm包安裝3.4手冊:https://www.zabbix.com/documentation/3.4/zh/manual/installation/getting_zabbix
從源代碼安裝zabbix 3.4: https://www.zabbix.com/documentation/3.4/zh/manual/installation/install#installation_from_sources php
[root@Node3 ~]# yum install mariadb-server mariadb –y //yum安裝mariadb [root@Node3 ~]# rpm -qa | grep mariadb mariadb-5.5.56-2.el7.x86_64 mariadb-server-5.5.56-2.el7.x86_64 mariadb-libs-5.5.56-2.el7.x86_64
二)設置MariaDB並啓動:
一、編輯my.cnf文件,增長如下內容:html
[root@Node3 ~]# vim /etc/my.cnf //編輯my.cnf文件
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock innodb_file_per_table = on //每一個表使用一張單獨的表 skip_name_resolve = on //跳過名稱反解 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid # # include all files from the config directory # !includedir /etc/my.cnf.d
二、啓動數據庫,並設置開機自啓動前端
[root@Node3 ~]# systemctl start mariadb.service //啓動數據庫 [root@Node3 ~]# systemctl enable mariadb.service //設置開機自啓動 Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. [root@Node3 ~]# systemctl status mariadb.service //查看狀態 ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2018-01-16 12:53:17 CST; 17s ago Main PID: 8736 (mysqld_safe) CGroup: /system.slice/mariadb.service ├─8736 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─8921 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/ma... Jan 16 12:53:15 Node3.contoso.com mariadb-prepare-db-dir[8655]: MySQL manual for more instructions. Jan 16 12:53:15 Node3.contoso.com mariadb-prepare-db-dir[8655]: Please report any problems at http://mariadb.org/jira Jan 16 12:53:15 Node3.contoso.com mariadb-prepare-db-dir[8655]: The latest information about MariaDB is available at http://mariadb.org/. Jan 16 12:53:15 Node3.contoso.com mariadb-prepare-db-dir[8655]: You can find additional information about the MySQL part at: Jan 16 12:53:15 Node3.contoso.com mariadb-prepare-db-dir[8655]: http://dev.mysql.com Jan 16 12:53:15 Node3.contoso.com mariadb-prepare-db-dir[8655]: Consider joining MariaDB's strong and vibrant community: Jan 16 12:53:15 Node3.contoso.com mariadb-prepare-db-dir[8655]: https://mariadb.org/get-involved/ Jan 16 12:53:15 Node3.contoso.com mysqld_safe[8736]: 180116 12:53:15 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. Jan 16 12:53:16 Node3.contoso.com mysqld_safe[8736]: 180116 12:53:16 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql Jan 16 12:53:17 Node3.contoso.com systemd[1]: Started MariaDB database server. [root@Node3 ~]# ss -tnl | grep 3306 //查看3306端口是否正常 LISTEN 0 50 *:3306 *:*
三) 建立數據庫:java
[root@Node3 ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, 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 CHARSET 'utf8' COLLATE 'utf8_bin'; //建立數據庫,並設置字符集 Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON zabbix.* TO 'zbxuser'@'172.17.21.%' IDENTIFIED BY 'zbxpass'; //受權用戶對其數據庫的權限 Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye [root@Node3 ~]# mysql -uzbxuser -pzbxpass -h 172.17.21.208 //測試數據庫是否登陸正常 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
一、設置zabbix yum源倉庫mysql
[root@Node3 ~]# rpm -Uvh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm //鏈接外網能夠安裝yum源的rpm包,讓其自動生成zabbix倉庫 Retrieving http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm Preparing... ################################# [100%] Updating / installing... 1:zabbix-release-3.4-1.el7.centos ################################# [100%] [root@Node3 ~]# ls /etc/yum.repos.d/ //查看倉庫是否自動生成 cdrom.repo repo zabbix.repo CentOS-Base.repo [root@Node3 ~]#
二、安裝 zabbix3.4.5linux
[root@Node3 zabbix3.4.5]# yum -y install zabbix-server-mysql-3.4.5-1.el7.x86_64.rpm zabbix-web-mysql-3.4.5-1.el7.noarch.rpm zabbix-get-3.4.5-1.el7.x86_64.rpm //安裝zabbix服務端
Loaded plugins: fastestmirror, langpacks
Examining zabbix-server-mysql-3.4.5-1.el7.x86_64.rpm: zabbix-server-mysql-3.4.5-1.el7.x86_64
Marking zabbix-server-mysql-3.4.5-1.el7.x86_64.rpm to be installed
Examining zabbix-web-mysql-3.4.5-1.el7.noarch.rpm: zabbix-web-mysql-3.4.5-1.el7.noarch
Marking zabbix-web-mysql-3.4.5-1.el7.noarch.rpm to be installed
Examining zabbix-get-3.4.5-1.el7.x86_64.rpm: zabbix-get-3.4.5-1.el7.x86_64
Marking zabbix-get-3.4.5-1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package zabbix-get.x86_64 0:3.4.5-1.el7 will be installed
---> Package zabbix-server-mysql.x86_64 0:3.4.5-1.el7 will be installed
--> Processing Dependency: fping for package: zabbix-server-mysql-3.4.5-1.el7.x86_64
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/4): base/7/x86_64/group_gz | 156 kB 00:00:00
(2/4): extras/7/x86_64/primary_db | 145 kB 00:00:01
(3/4): base/7/x86_64/primary_db | 5.7 MB 00:00:12
(4/4): updates/7/x86_64/primary_db | 5.2 MB 00:00:55
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com ...........................安裝過程省略............................ Installed: zabbix-get.x86_64 0:3.4.5-1.el7 zabbix-server-mysql.x86_64 0:3.4.5-1.el7 zabbix-web-mysql.noarch 0:3.4.5-1.el7 Dependency Installed: //安裝所需的依賴包 OpenIPMI-libs.x86_64 0:2.0.19-15.el7 OpenIPMI-modalias.x86_64 0:2.0.19-15.el7 fping.x86_64 0:3.10-1.el7 httpd.x86_64 0:2.4.6-67.el7.centos.6 httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 iksemel.x86_64 0:1.4-2.el7.centos libzip.x86_64 0:0.10.1-8.el7 mailcap.noarch 0:2.1.41-2.el7 php.x86_64 0:5.4.16-43.el7_4 php-bcmath.x86_64 0:5.4.16-43.el7_4 php-cli.x86_64 0:5.4.16-43.el7_4 php-common.x86_64 0:5.4.16-43.el7_4 php-gd.x86_64 0:5.4.16-43.el7_4 php-ldap.x86_64 0:5.4.16-43.el7_4 php-mbstring.x86_64 0:5.4.16-43.el7_4 php-mysql.x86_64 0:5.4.16-43.el7_4 php-pdo.x86_64 0:5.4.16-43.el7_4 php-xml.x86_64 0:5.4.16-43.el7_4 t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7 zabbix-web.noarch 0:3.4.5-1.el7 Complete!
三、導入zabbix數據庫web
[root@Node3 zabbix3.4.5]# zcat /usr/share/doc/zabbix-server-mysql-3.4.5/create.sql.gz |mysql -uzbxuser -pzbxpass -h172.17.21.208 zabbix //導入數據庫
四、配置數據庫用戶及密碼sql
[root@Node3 ~]# vim /etc/zabbix/zabbix_server.conf //修改zabbix_server.conf配置文件紅色部分 [root@Node3 ~]# grep -n '^[a-Z]' /etc/zabbix/zabbix_server.conf //查看修改部分 38:LogFile=/var/log/zabbix/zabbix_server.log 49:LogFileSize=0 72:PidFile=/var/run/zabbix/zabbix_server.pid 82:SocketDir=/var/run/zabbix
91:DBHost=172.17.21.208 //修改數據庫地址 101:DBName=zabbix //修改數據庫名 117:DBUser=zbxuser //修改數據庫帳號 125:DBPassword=zbxpass //修改數據庫密碼 330:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log 448:Timeout=4 490:AlertScriptsPath=/usr/lib/zabbix/alertscripts //Zabbix運行腳本存放目錄 500:ExternalScripts=/usr/lib/zabbix/externalscripts 536:LogSlowQueries=3000 [root@Node3 ~]#
五、編輯Zabbix前端PHP配置,更改時區數據庫
[root@Node3 zabbix]# vim +19 /etc/httpd/conf.d/zabbix.conf //將#去掉,修改成Asia/Shanghai
六、SELinux配置vim
[root@Node3 zabbix]# setsebool -P httpd_can_connect_zabbix on setsebool: SELinux is disabled. [root@Node3 zabbix]# setsebool -P httpd_can_cetwork_connect_db on setsebool: SELinux is disabled. [root@Node3 zabbix]#
七、開啓httpd服務,並設置開機自啓動
[root@Node3 zabbix]# systemctl start httpd.service
[root@Node3 zabbix]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@Node3 zabbix]# ss -tnl | grep 80
LISTEN 0 128 :::80 :::*
八、開啓zabbix- server服務,並設置爲開機自啓動
[root@Node3 zabbix]# systemctl start zabbix-server.service [root@Node3 zabbix]# systemctl enable zabbix-server.service Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service. [root@Node3 zabbix]# ss -tnl | grep 10051 LISTEN 0 128 *:10051 *:* LISTEN 0 128 :::10051 :::* [root@Node3 zabbix]#
一、瀏覽器訪問,並進行安裝http://172.17.21.178/zabbix/
二、點擊Next setp
三、查看沒有相關的報錯信息,而後再點擊Next step
四、設置數據庫地址,數據庫,數據用戶及密碼、端口號等(端口號0表明默認端口)
五、設置Zabbix平臺名稱,點擊Next step
完成安裝,會將在/etc/zabbix/web/zabbix.conf.php生成配置文件
Congratulations! You have successfully installed Zabbix frontend.
Configuration file "/etc/zabbix/web/zabbix.conf.php" created.
六、看到以上安裝 成功的字樣,表明安裝成功,點擊Finish結束安裝,打開登陸界面,默認帳號爲:Admin 密碼爲:zabbix,點擊Sign in
七、登陸成功以後,看到如下界面,表明安裝結束