文章目錄
軟件 | 版本號 | 查詢命令 |
---|---|---|
centos7 | CentOS Linux release 7.7.1908 (Core) | cat /etc/redhat-release |
zabbix-server-mysql | zabbix-server-mysql-4.4.5-2.el7.x86_64 | rpm -qa |grep zabbix |
zabbix-release | zabbix-release-4.4-1.el7.noarch | rpm -qa |grep zabbix |
zabbix-web-mysql | zabbix-web-mysql-4.4.5-2.el7.noarch | rpm -qa |grep zabbix |
zabbix-web | zabbix-web-4.4.5-2.el7.noarch | rpm -qa|grep zabbix |
zabbix-agent | zabbix-agent-4.4.5-2.el7.x86_64 | rpm -qa |grep zabbix-agent |
mariadb-server | mariadb-server-5.5.64-1.el7.x86_64 | rpm -qa|grep mariadb-server |
php | php-5.4.16-46.1.el7_7.x86_64 | rpm -qa|grep php |
apache | httpd-2.4.6-90.el7.centos.x86_64 | rpm -qa|grep httpd |
ntp | ntpdate-4.2.6p5-29.el7.centos.x86_64 | rpm -qa |grep ntpdate |
一、linux系統配置
1、臨時關閉seLinux。
setenforce 0
2、永久關閉selinux 需編輯配置文件/etc/selinux/config,設置SELINUX=disabled,重啓系統後生效。
vi /etc/selinux/config
3、關閉防火牆或設置防火牆開放80端口。
systemctl stop firewalld
或
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --query-port=80/tcp
二、yum安裝zabbix-server
1、從zabbix官方的源碼庫https://repo.zabbix.com下載、安裝部署包文件。
wget -c -t 0 https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
rpm -ivh zabbix-release-4.4-1.el7.noarch.rpm
2、安裝zabbix-server-mysql,啓動服務並設置爲開機啓動。
yum install -y zabbix-server-mysql
systemctl start zabbix-server
systemctl enable zabbix-server
3、安裝zabbix-web-mysql。
yum install -y zabbix-web-mysql
4、安裝客戶端zabbix-agent,啓動服務並設置爲開機啓動。
yum install -y zabbix-agent
systemctl start zabbix-agent
systemctl enable zabbix-agent
5、安裝數據庫mysql,啓動服務並設置爲開機啓動,設置數據庫賬戶root密碼。
yum install -y mariadb-server
systemctl start mariadb.service
systemctl enable mariadb.service
mysqladmin -uroot password 'server7'
6、登錄mysql,創建zabbix數據庫,授權用戶zabbix使用密碼zabbix訪問本地zabbix數據庫時擁有所有權限。
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
quit;
7、向數據庫zabbix中導入初始架構和數據。
find / -name "zabbix-server-mysql*"
cd /usr/share/doc/zabbix-server-mysql-4.4.5
zcat create.sql.gz | mysql -uroot -pserver7 zabbix
8、在配置文件zabbix_server.conf中編輯數據庫配置。
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
9、安裝zabbix-web 。
yum install -y zabbix-web
10、安裝apache服務,啓動服務並設置爲開機啓動。
yum install -y httpd
systemctl start httpd
systemctl enable httpd
11、安裝php。
yum install -y php
12、安裝時間同步ntp服務,修改系統時間爲亞洲上海時區。
yum install -y ntpdate
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate us.pool.ntp.org
date
13、修改配置文件/etc/httpd/conf.d/zabbix.conf,時區改成 Asia/Shanghai。
vi /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/ShangHai
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
14、重啓apache,zabbix-server服務。
systemctl restart httpd
systemctl restart zabbix-server
三、配置zabbinx-server
1、瀏覽器輸入http://192.168.43.100/zabbix,進入如下界面。
2、點擊下一步,進入先決條件檢查界面,確保狀態都是OK。
3、點擊下一步,進入配置數據庫連接界面。
4、點擊下一步,進入zabbix服務配置界面。
5、點擊下一步,進入安裝前總結界面。
6、點擊下一步,進入安裝界面,點擊finish,完成安裝。
四、登陸zabbix-server,設置中文語言
1、瀏覽器輸入http://192.168.43.100/zabbix,進入登陸界面,使用默認用戶名/密碼(Admin / zabbix)登陸,A是大寫字母。
2、zabbinx監控界面如下。
3、設置中文語言,如下圖。
五、被監控客戶端部署zabbix-agent
1、從zabbix官方的源碼庫https://repo.zabbix.com下載、安裝部署包文件。
wget -c -t 0 https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
rpm -ivh zabbix-release-4.4-1.el7.noarch.rpm
2、安裝zabbix-agent,啓動服務並設置爲開機啓動。
yum install -y zabbix-agent
systemctl start zabbix-agent
systemctl enable zabbix-agent
systemctl status zabbix-agent
3、編輯配置文件/etc/zabbix/zabbix_agentd.conf,設置zabbix服務器ip,重啓zabbix-agent服務。未正確配置時報錯如下圖:Received empty response from Zabbix Agent at [192.168.43.120]. Assuming that agent dropped connection because of access permissions.
vi /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent
Server=192.168.43.100
ServerActive=192.168.43.100
4、防火牆開放10050端口。未開放端口時報錯如下圖:Get value from agent failed: cannot connect to [[192.168.43.120]:10050]: [113] No route to host
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=public --add-port=10050/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --query-port=10050/tcp
5、如果報錯如下圖:Get value from agent failed: cannot connect to [[127.0.0.1]:10050]: [111] Connection refused,說明zabbix-agent服務未啓動,啓動即可。
systemctl start zabbix-agent
六、添加被監測客戶機
1、瀏覽器輸入http://192.168.43.100/zabbix,進入登陸界面,使用默認用戶名/密碼(Admin / zabbix)登陸。
2、選擇配置->主機->創建主機。
3、設置zabbix-agent主機名稱,根據實際情況選擇合適羣組,設置ip、dns,選中已啓用;點擊模板,選擇合適模板。
4、設置完成點擊添加按鈕,即可在配置->主機看到新添加的設備。
5、然後就可在監控選項內查看各種監控狀態了。