yum部署zabbix-server4.2 前面寫到過在已有的lnmp環境下源碼部署zabbix-server4.0,這次就寫一篇yum部署zabbix-server+mysql的結合。 環境說明: 1.這裡我所使用的MySQL版本為8版本,系統版本為CentOS7.4系列操作系統 部署MySQL ...
yum部署zabbix-server4.2
前面寫到過在已有的lnmp環境下源碼部署zabbix-server4.0,這次就寫一篇yum部署zabbix-server+mysql的結合。
環境說明:
1.這裡我所使用的MySQL版本為8版本,系統版本為CentOS7.4系列操作系統
部署MySQL
1、配置MySQL yum源,由於官網源下載很慢,所以這裡使用清華大學的鏡像源
# cat > /etc/yum.repos.d/mysql-community.repo <<EOF [mysql-connectors-community] name=MySQL Connectors Community baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql80-community] name=MySQL 8.0 Community Server baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql EOF
2、更新yum源
# yum clean all # yum makecache
3、安裝MySQL
# yum install mysql-community-server -y
4、啟動MySQL
# systemctl start mysqld
# systemctl enable mysqld
5、查看初始密碼並修改密碼
# grep password /var/log/mysqld.log 2020-03-31T08:46:17.270127Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: iwZgfDKdc1-N # mysql -u root -p ... mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY "NewPass#123"; Query OK, 0 rows affected (0.01 sec)
6、創建zabbix資料庫並創建用戶及授權
mysql> create database zabbix character set utf8mb4; Query OK, 1 row affected (0.02 sec) mysql> create user 'zabbix'@'localhost' identified by 'Zabbix@123'; Query OK, 0 rows affected (0.01 sec) mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' with grant option; Query OK, 0 rows affected (0.01 sec) mysql> alter user 'zabbix'@'localhost' identified with mysql_native_password by "Zabbix@123"; Query OK, 0 rows affected (0.01 sec)
部署zabbix-server
1、安裝zabbix鏡像源
# rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm
2、安裝zabbix
# yum-config-manager --enable rhel-7-server-optional-rpms # yum install zabbix-server-mysql zabbix-web-mysql zabbix-get -y
3、編輯zabbix-server配置文件,配置資料庫賬戶密碼
# cp /etc/zabbix/zabbix_server.conf{,.bck} # cat > /etc/zabbix/zabbix_server.conf <<EOF 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@123 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000 StatsAllowedIP=127.0.0.1 EOF
4、編輯httpd的子配置文件zabbix.conf,將時區進行更改(20行)
# grep timezone /etc/httpd/conf.d/zabbix.conf php_value date.timezone Asia/Shanghai
5、導入zabbix資料庫文件
# zcat /usr/share/doc/zabbix-server-mysql-4.2.8/create.sql.gz |mysql -u root -pNewPass#123 zabbix # 驗證zabbix庫中是否有表結構 # mysql -u root -pNewPass#123 -e "show tables from zabbix"
6、啟動服務並加入開機自啟動
# systemctl start zabbix-server # systemctl start httpd # systemctl enable zabbix-server # systemctl enable httpd
7、web訪問併進行安裝,預設訪問:IP/zabbix
到這裡,yum部署zabbix就完成了。其餘配置,請參考zabbix系列文章。