01zabbix centos7官方教程安装zabbix4.0 - 20201130更新 - 含安装mysql5.7

先给上zabbix4.0,centos的rpo链接:Zabbix Official Repository

,
A。安装Zabbix存储库文件  B 。安装Zabbix服务器,前端,代理

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum clean all
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get

# redhat 如果报错参考链接:zabbix-server-mysql [Errno 256] No more mirrors to try_shaoqiu.wu的博客-CSDN博客  

修改yum  zabbix.repo文件如下:


[zabbix]
name=Zabbix Official Repository - $basearch
#baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/ 
#这里我们换成清华的yum源
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
#baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/debuginfo/
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/debuginfo/
#换了上面Zabbix的安装源地址,其组件地址也要记得换! 
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
#baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
#换
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1


C。安装mysql数据库 参考链接Centos7 安装MySQL 5.7 - 张顺海 - 博客园

#  rpm离线安装mysql  Centos 离线安装mysql5.7.32_疏笃-CSDN博客

# 下载并安装MySQL官方的 Yum Repository   有点慢  感觉回头还是考虑找个国内源

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server  # 这步可能会花些时间,安装完成后就会覆盖掉之前的mariadb。

 # 报错解决:

rpm gpg key mysql_记录无法安装mysql-Invalid GPG Key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql的解决办法...

修改gpgcheck=0即可

sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/mysql-community.repo
sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/mysql-community-source.repo 
yum -y install mysql-community-server  # 这步可能会花些时间,安装完成后就会覆盖掉之前的mariadb。

rpm gpg key mysql_记录无法安装mysql-Invalid GPG Key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql的解决办法..._邝彬的博客-CSDN博客

# 首先启动MySQL

systemctl start  mysqld.service

# 查看初始密码

grep "password" /var/log/mysqld.log

# 进入mysql
 mysql -uroot -p
输入password

# 需要先修改root密码

法一:

alter user 'root'@'localhost' identified by 'cy7m0ypu8CpLFperzI45';

法二:

set password for 'root'@'localhost'=password('cy7m0ypu8CpLFperzI45');

法三:

update mysql.user set authentication_string=password('cy7m0ypu8CpLFperzI45') where user='root' and Host = 'localhost';
#记得最后要刷新权限
flush privileges;

D 如果根分区比较小 建议修改数据库存放位置至 /home下:

参考:  Centos 更改MySQL5.7数据库目录位置_酷玩时刻-By Javen-CSDN博客_centos mysql 目录   

有坑参考:centos7 mysql5.7.32 修改存储位置_yuezhilangniao的博客-CSDN博客_centos7修改mysql存储位置

# 创建zabbix数据库和 zabbix用户访问zabbix库权限

create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
quit;

# 系统会提示你输入上面设置的密码“password”
 

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix


D。为Zabbix服务器配置 数据库配置

#vim /etc/zabbix/zabbix_server.conf   添加 DBPassword=password 

 或

echo  "DBPassword=password"   /etc/zabbix/zabbix_server.conf 

或  

sed -e "/126/a DBPassword=Password" -i /etc/zabbix/zabbix_server.conf


即 为Zabbix前端配置PHP
编辑文件/etc/httpd/conf.d/zabbix.conf,取消注释并为您设置正确的时区。
# php_value date.timezone Asia/Shanghai


E。启动Zabbix服务器和代理进程
启动Zabbix服务器和代理程序进程并使其在系统引导时启动:

systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd


现在您的Zabbix服务器已启动并运行!

打开Zabbix前端
关闭防火墙
#vim /etc/selinux/config
   
#setenforce 0
   
#systemctl stop firewalld
  
连接到新安装的Zabbix前端:http:// server_ip_or_name / zabbix

需要几步设置数据库和server的基本信息 这里截图最后两步

# 设置完成后登陆  默认初始账号Admin  密码 zabbix

# 记录一次数据库报错  未解决 

# tail -f /var/log/mysqld
Got an error reading communication packets

摸索文章: Got an error reading communication packets_li66934791的博客-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值