欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

yum安装zabbix4.2

程序员文章站 2022-07-08 10:47:14
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安装zabbix4.2

 

 yum安装zabbix4.2

 

 yum安装zabbix4.2

 

 yum安装zabbix4.2

 

 yum安装zabbix4.2

 

 yum安装zabbix4.2

 

 yum安装zabbix4.2

 

 yum安装zabbix4.2

 

 到这里,yum部署zabbix就完成了。其余配置,请参考zabbix系列文章。