Zabbix 3.4 在CentOS 7.2 上安裝詳細步驟
阿新 • • 發佈:2020-10-09
一、環境準備
作業系統: [[email protected]~]#cat/etc/redhat-release CentOSLinuxrelease7.3.1611(Core) 修改主機名: [[email protected]~]#hostnamectlset-hostnamezabbix-server [[email protected]~]#logout 配置hosts: [[email protected]~]#cat>>/etc/hosts<<EOF 10.10.172.235zabbix-server EOF 伺服器IP: [[email protected]~]#ipaddr 1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWNqlen1 link/loopback00:00:00:00:00:00brd00:00:00:00:00:00 inet127.0.0.1/8scopehostlo valid_lftforeverpreferred_lftforever inet6::1/128scopehost valid_lftforeverpreferred_lftforever 2:eth0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscmqstateUPqlen1000 link/ether00:0c:29:d6:33:8fbrdff:ff:ff:ff:ff:ff inet10.10.172.235/24brd10.10.172.255scopeglobaleth0 valid_lftforeverpreferred_lftforever inet6fe80::20c:29ff:fed6:338f/64scopelink valid_lftforeverpreferred_lftforever 關閉防火牆: [[email protected]~]#systemctlstopfirewalld [[email protected]~]#systemctldisablefirewalld Removedsymlink/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removedsymlink/etc/systemd/system/basic.target.wants/firewalld.service. 關閉selinux: [[email protected]~]#getenforce Disabled [[email protected]~]#cat/etc/selinux/config #ThisfilecontrolsthestateofSELinuxonthesystem. #SELINUX=cantakeoneofthesethreevalues: #enforcing-SELinuxsecuritypolicyisenforced. #permissive-SELinuxprintswarningsinsteadofenforcing. #disabled-NoSELinuxpolicyisloaded. SELINUX=disabled #SELINUXTYPE=cantakeoneofthreetwovalues: #targeted-Targetedprocessesareprotected, #minimum-Modificationoftargetedpolicy.Onlyselectedprocessesareprotected. #mls-MultiLevelSecurityprotection. SELINUXTYPE=targeted 解決yum舊版本的GPGkeys問題 [[email protected]~]#rpm--import/etc/pki/rpm-gpg/RPM*
二、安裝步驟
1、安裝zabbix源
[[email protected]~]#rpm-ivhhttp://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm [[email protected]~]#yumcleanall [[email protected]~]#yummakecache
2、安裝zabbix server
[[email protected]~]#yuminstall-yzabbix-server-mysqlzabbix-web-mysql 安裝過程省略...... Installed: zabbix-server-mysql.x86_640:3.4.11-1.el7zabbix-web-mysql.noarch0:3.4.11-1.el7 DependencyInstalled: OpenIPMI-libs.x86_640:2.0.23-2.el7OpenIPMI-modalias.x86_640:2.0.23-2.el7dejavu-fonts-common.noarch0:2.33-6.el7 dejavu-sans-fonts.noarch0:2.33-6.el7fping.x86_640:3.10-1.el7httpd.x86_640:2.4.6-80.el7.centos httpd-tools.x86_640:2.4.6-80.el7.centosiksemel.x86_640:1.4-2.el7.centoslibXpm.x86_640:3.5.12-1.el7 libevent.x86_640:2.0.21-4.el7libtool-ltdl.x86_640:2.4.2-22.el7_3libxslt.x86_640:1.1.28-5.el7 libzip.x86_640:0.10.1-8.el7mailcap.noarch0:2.1.41-2.el7net-snmp-libs.x86_641:5.7.2-33.el7_5.2 php.x86_640:5.4.16-45.el7php-bcmath.x86_640:5.4.16-45.el7php-cli.x86_640:5.4.16-45.el7 php-common.x86_640:5.4.16-45.el7php-gd.x86_640:5.4.16-45.el7php-ldap.x86_640:5.4.16-45.el7 php-mbstring.x86_640:5.4.16-45.el7php-mysql.x86_640:5.4.16-45.el7php-pdo.x86_640:5.4.16-45.el7 php-xml.x86_640:5.4.16-45.el7t1lib.x86_640:5.1.2-14.el7unixODBC.x86_640:2.3.1-11.el7 zabbix-web.noarch0:3.4.11-1.el7 DependencyUpdated: openssl.x86_641:1.0.2k-12.el7openssl-libs.x86_641:1.0.2k-12.el7 Complete!
3、安裝啟動 mariadb資料庫
基於YUM安裝Mariadb:
[[email protected]~]#yuminstall-ymariadb-server [[email protected]~]#systemctlstartmariadb.service
基於YUM安裝MySQL:
1).安裝mysql社群版官方源 wgethttp://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm rpm-ivhmysql-community-release-el7-5.noarch.rpm 2).檢視可以安裝的mysql版本 yumrepolistenabled|grepmysql mysql-connectors-community/x86_64MySQLConnectorsCommunity24 mysql-tools-community/x86_64MySQLToolsCommunity38 mysql56-community/x86_64MySQL5.6CommunityServer289 3).安裝 yuminstall-ymysql-community-server 4).啟動mysql systemctlenablemysqld systemctlstartmysqld 5).嘗試進入mysql mysql-uroot-p密碼為空
4、建立資料庫並分配許可權
[[email protected]~]#mysql-e'createdatabasezabbixcharactersetutf8collateutf8_bin;' [[email protected]~]#mysql-e'grantallprivilegesonzabbix.*to[email protected]identifiedby"zabbix";'
5、建立zabbix相關庫表結構並匯入資料
[[email protected]~]#zcat/usr/share/doc/zabbix-server-mysql-3.4.11/create.sql.gz|mysql-uzabbix-pzabbixzabbix
6、配置zabbix server 連線mysql資料庫
[[email protected]~]#sed-i.ori'126aDBPassword=zabbix'/etc/zabbix/zabbix_server.conf [[email protected]~]#grep-Ev"#|^$"/etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid SocketDir=/var/run/zabbix DBName=zabbix DBUser=zabbix DBPassword=zabbix SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000
7、修改zabbix的時區
[[email protected]~]#sed-i.ori'18aphp_valuedate.timezoneAsia/Shanghai'/etc/httpd/conf.d/zabbix.conf
8、解決中文亂碼
[[email protected]~]#yum-yinstallwqy-microhei-fonts [[email protected]~]#cp/usr/share/fonts/wqy-microhei/wqy-microhei.ttc/usr/share/fonts/dejavu/DejaVuSans.ttf cp:overwrite‘/usr/share/fonts/dejavu/DejaVuSans.ttf’?y 或者從C:\Windows\Fonts下拷貝字型到/usr/share/fonts/dejavu/之下,並替換DejaVuSans.ttf
9、設定開機自啟動
[[email protected]~]#systemctlenablemariadb.service [[email protected]~]#systemctlenablehttpd.service [[email protected]~]#systemctlenablezabbix-server.service
10、啟動服務
[[email protected]~]#systemctlstartzabbix-server [[email protected]~]#systemctlstarthttpd
11、安裝zabbix agent
[[email protected]~]#yuminstall-yzabbix-agent
12、在agent上配置上server ip
[[email protected]~]#sed-i.ori's#Server=127.0.0.1#Server=10.10.172.235#'/etc/zabbix/zabbix_agentd.conf [[email protected]~]#grep-Ev"#|^$"/etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 Server=10.10.172.235 ServerActive=127.0.0.1 Hostname=Zabbixserver Include=/etc/zabbix/zabbix_agentd.d/*.conf
13、agent設定開機啟動
[[email protected]~]#systemctlenablezabbix-agent.service
14、開啟agent
[[email protected]~]#systemctlstartzabbix-agent.service
三、訪問web
http://10.10.172.235/zabbix/setup.php
點選下一步
以上檢測項,哪些有問題可根據提示資訊進行解決,所有專案都OK 點選下一步
選擇mysql資料庫,輸入密碼即可
預設即可,點選下一步
安裝清單彙總,點選下一步
點選Finish就進入zabbix登入頁面了,預設的使用者名稱為Admin,密碼為zabbix.
zabbix GUI主頁-->Configuration ---->Hosts,點選Zabbix server,修改可見名稱和 agent ip
更新並啟用即可。
Monitoring-->Graphs-->主機(10.10.172.235)-->Granph(Memory usage)
到此為止zabbix安裝配置成功。
轉載於:https://blog.51cto.com/dengaosky/2134261