一、环境准备
1.安装MySQL5.7
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm [root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm [root@localhost ~]# yum -y install mysql-community-server
2.修改默认的数据文件位置
[root@localhost ~]# vim /etc/my.cnf datadir=/workspace/mysql //数据存放路径,推荐写数据盘路径 socket=/workspace/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [client] socket=/workspace/mysql/mysql.sock //不指定客户端连接路径登录数据库会报错Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock
3.启动MySQL服务
[root@localhost ~]# systemctl start mysqld 查看MySQL日志获取登录密码 [root@localhost ~]# tail -100f /var/log/mysqld.log 找到密码所在位置 2021-05-27T03:14:23.481320Z 1 [Note] A temporary password is generated for root@localhost: 9gK2dL%pnd>H [root@localhost ~]# mysql -uroot -p 准备创建zabbix的数据库,在此之前需要重新设置密码 mysql> set password = password('Password@123'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> alter user 'root'@'localhost' password expire never; Query OK, 0 rows affected (0.01 sec) mysql> mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) 创建zabbix数据库 mysql> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 sec) mysql> grant all on zabbix.* to zabbix@'localhost' identified by 'Password@123'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> select user,host from mysql.user; +---------------+-----------+ | user | host | +---------------+-----------+ | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | | zabbix | localhost | +---------------+-----------+ 4 rows in set (0.01 sec)
4.安装zabbix
[root@localhost ~]# yum install -y zabbix-agent zabbix-server-mysql [root@localhost ~]# vim /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=Password@123
导入zabbix数据表结构
mysql> source /usr/share/doc/zabbix-server-mysql-5.0.12/create.sql
5.安装PHP7.2
[root@localhost ~]# yum -y install centos-release-scl [root@localhost ~]# yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl 配置前端PHP vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf php_value[date.timezone] = Asia/Shanghai #同时改为上海
启动http服务及php-fpm及设置为开机启动
[root@localhost ~]# systemctl restart httpd rh-php72-php-fpm
[root@localhost ~]# systemctl enable httpd rh-php72-php-fpm
6.启动zabbix