1. 程式人生 > 其它 >zabbix 5.0快速安裝步驟記錄

zabbix 5.0快速安裝步驟記錄

Mysql安裝

安裝mysql 5.6.28

安裝zabbix

rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
yum makecache
yum install zabbix-server-mysql zabbix-agent -y

安裝Zabbix frontend

yum
install centos-release-scl -y

編輯配置檔案 /etc/yum.repos.d/zabbix.repo

vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...

安裝 Zabbix frontend packages

yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl

zabbix使用者及資料庫建立

mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql
> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';

解決報錯(測試好像沒用,可略過看下一步方法)

vim /etc/my.cnf
[mysqld]
# solve this problem "index column size too large. the maximum column size is 767 bytes" 
default-storage-engine = INNODB
innodb_file_per_table = ON
innodb_large_prefix = ON
innodb_file_format 
= BARRACUDA


zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
#執行這一步可能會報錯"index column size too large. the maximum column size is 767 bytes"
#如下操作可解決

cp -rp /usr/share/doc/zabbix-server-mysql*/create.sql.gz ./
gunzip create.sql.gz
#sed -i 's/ENGINE=InnoDB/ENGINE=InnoDB ROW_FORMAT=DYNAMIC/g' ./create.sql
mysql -uroot -p
mysql> use zabbix
mysql> source /tools/create.sql

修改/etc/zabbix/zabbix_server.conf

sed -i "s@# DBPassword=@DBPassword=zabbix@g" /etc/zabbix/zabbix_server.conf

修改/etc/zabbix/zabbix_agentd.conf,這裡的IP地址寫的是zabbix_server的IP地址,即12.1.1.1

sed -i "s@Server=127.0.0.1@Server=127.0.0.1,12.1.1.1@g" /etc/zabbix/zabbix_agentd.conf
sed -i "s@ServerActive=127.0.0.1@ServerActive=12.1.1.1@g" /etc/zabbix/zabbix_agentd.conf
sed -i "s@^# UnsafeUserParameters=0@UnsafeUserParameters=1\n@g" /etc/zabbix/zabbix_agentd.conf


為Zabbix前端配置PHP
編輯配置檔案 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

啟動Zabbix server和agent程序,併為它們設定開機自啟

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

注意:如果啟動後檢視沒有10051埠,可以檢視zabbix_server日誌繼而解決

網頁安裝操作,開啟http:IP/zabbix

a.檢查php配置,各項通過才可以下一步; b.配置db連線資訊: type:mysql,host:localhost,port:3306,db_name:zabbix,user:zabbix,password:zabbix; Test connection 看到OK後下一步。 c.zabbix伺服器配置:host:localhost,port:10051,name:danny-zabbix(名稱隨意) d.一路下一步,完成。 登陸 http://xxx/zabbix/index.php 預設賬號:Admin,密碼:zabbix (預設的賬號密碼儲存在mysql的zabbix庫的users表中,如需修改更新Mysql中其的資料即可。)

客戶端zabbix-agent安裝

安裝基礎軟體:

yum install wget vim tree gcc gcc-c++ -y

更新yum源

rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo

yum makecache

安裝客戶端:

yum install zabbix-agent -y

配置vim /etc/zabbix/zabbix_agentd.conf 。修改zabbix-server的IP

#####被動模式:允許server的ip來本機取資料
Server=ServerIP
 
#####主動模式:本機主動給哪臺server傳送資料
ServerActive=ServerIP
 
#####主機名
Hostname=Client_12.1.1.2     //很重要,server監控頁面判別監控主機的主要指標
 
Include=/etc/zabbix/zabbix_agentd.conf.d/
UnsafeUserParameters=1           ###啟用自定義key
 
#設定zabbix_agentd開機自動啟動,並啟動zabbix_agentd服務
systemctl enable zabbix-agent 
systemctl restart zabbix-agent
在zabbix_server監控頁面中新增主機即可

OK,完成!

好記性不如爛筆頭,最難不過堅持