Centos7部署zabbix
第一部分:安装MySQL
1、rpm -qa | grep -i mariadb #查找mysql的安装包
2、rpm -e --nodeps ?#删除查找出来的安装包,?代表安装包
3、rpm -qa | ``grep
mysql #确认是否删除干净没
4、https://repo.mysql.com,上这个网站下载自己需要的yum源安装包并上传到你要安装MySQL的主机上
5、yum -y install ? #安装yum源,?代表你上步下载的yum源
6、yum -y install mysql-community-server #安装MySQL
7、systemctl start MySQLD #启动MySQL
8、cat /var/log/mysqld.log | grep password #查找临时密码
9、ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘?’; #修改root用户密码
10、flush privileges; #刷新
第二部分:部署zabbix
1、systemctl stop firewalld #停止防火墙
2、systemctl disable firewalld #设为开机不自启
3、sed -i ``‘s/SELINUX=enforcing/SELINUX=disabled/’
/etc/selinux/config #关闭SELinux
4、reboot #重启设备
5、rpm -Uvh https:``//mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm #下载zabbix5的yum源
6、sed -i ``‘s#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#’
/etc/yum.repos.d/zabbix.repo #修改zabbix的yum源为阿里的
7、yum clean all #清除缓存
8、yum install zabbix-server-mysql zabbix-agent -y #安装 zabbix server 和 agent
9、yum install centos-release-scl -y #安装 Software Collections,便于后续安装高版本的 php,默认 yum 安装的 php 版本为 5.4 过低
10、启用 zabbix 前端源,修改vi /etc/yum.repos.d/zabbix.repo,将[zabbix-frontend]下的 enabled 改为 1
11、yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y #安装 zabbix 前端和相关环境
12、登录mysql执行下面命令
create database zabbix character ``set` `utf8 collate utf8_bin;
create user zabbix@localhost identified ``by` `'?'``;#?代表设置自己的密码
grant all privileges ``on` `zabbix.* to zabbix@localhost;
quit;
#用于mysql8修改了用户认证令牌需要执行这一步,mysql5不受影响
mysql> use mysql;
mysql> select user,host,plugin from user; # 查看身份验证插件是否为mysql_native_password
mysql>flush privileges;
mysql> alter user 'zabbix'@'loaclhost' identified with mysql_native_password by '?';#?代表zabbix的密码,这一步可能会执行失败,你需要先执行 flush privileges在执行这一步;
mysql> select user,host,plugin from user;
13、zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p # 他会让你输入密码,这个密码就是上一步你设置的密码
14、修改 zabbix server 配置文件vi /etc/zabbix/zabbix_server.conf 里的数据库密码 DBPassword=? 设置为zabbix用户的密码,也是上上一步设置的密码
15、修改 zabbix 的 php 配置文件vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 里的时区,改成 Asia/Shanghai,php_value[date.timezone] = Asia/Shanghai,这一步你在修改时会发现前面有个;,你把这个分号删除与其他对齐就行。
16、systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm #开启服务
17、systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm #设为开启
18、使用浏览器访问http://ip/zabbix 即可访问 zabbix 的 web 页面ip为你安装zabbix的主机的ip