yum部署zabbix-server4.2前面寫到過(guò)在已有的lnmp環(huán)境下源碼部署zabbix-server4.0,這次就寫一篇yum部署zabbix-server+mysql的結(jié)合。 環(huán)境說(shuō)明: 1.這里我所使用的MySQL版本為8版本,系統(tǒng)版本為CentOS7.4系列操作系統(tǒng) 部署MySQL1、配置MySQL yum源,由于官網(wǎng)源下載很慢,所以這里使用清華大學(xué)的鏡像源 # 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、啟動(dòng)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、創(chuàng)建zabbix數(shù)據(jù)庫(kù)并創(chuàng)建用戶及授權(quán) 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-server1、安裝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配置文件,配置數(shù)據(jù)庫(kù)賬戶密碼 # 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,將時(shí)區(qū)進(jìn)行更改(20行) # grep timezone /etc/httpd/conf.d/zabbix.conf php_value date.timezone Asia/Shanghai 5、導(dǎo)入zabbix數(shù)據(jù)庫(kù)文件 # zcat /usr/share/doc/zabbix-server-mysql-4.2.8/create.sql.gz |mysql -u root -pNewPass#123 zabbix # 驗(yàn)證zabbix庫(kù)中是否有表結(jié)構(gòu) # mysql -u root -pNewPass#123 -e "show tables from zabbix" 6、啟動(dòng)服務(wù)并加入開(kāi)機(jī)自啟動(dòng) # systemctl start zabbix-server # systemctl start httpd # systemctl enable zabbix-server # systemctl enable httpd 7、web訪問(wèn)并進(jìn)行安裝,默認(rèn)訪問(wèn):IP/zabbix
到這里,yum部署zabbix就完成了。其余配置,請(qǐng)參考zabbix系列文章。
|
|