centos7安装Zabbix4.2

安装真的是越来越简单了,但是也偶有失误的时候,之前遇到了这个错误

One of the configured repositories failed (MySQL Connectors Community),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=mysql-connectors-community ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable mysql-connectors-community
        or
            subscription-manager repos --disable=mysql-connectors-community

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=mysql-connectors-community.skip_if_unavailable=true

failure: repodata/repomd.xml from mysql-connectors-community: [Errno 256] No more mirrors to try.
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: repo.mysql.com; Unknown error"
[root@localhost www]#  rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
Preparing...                          ################################# [100%]
	package zabbix-release-4.2-1.el7.noarch is already installed

后面是用更新yum解决的

# yum update

然后就是下载并且安装zabbix4.2了

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

如果这些步骤遇见问题都可以采用我的更新yum来解决,接下来就是配置mysql了。

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix identified by 'Aggy2019.';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> flush privileges;
mysql> quit;

导入初始架构和数据。 系统将提示您验证密码。

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

编辑文件/etc/zabbix/zabbix_server.conf

DBPassword=password

在这里插入图片描述

设置正确的时区。去掉注释改代码写上你所在的时区就可以了,红框的位置

vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Beijing

在这里插入图片描述
启用服务和开启开机启动。

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

遇到错误,agent和server都失败了,httpd是成功的。接下来排错,第一个可能的原因是开启了selinux。

zabbix-server.service never wrote its PID file. Failing.
getenforce
sestatus
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          error (Success)
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

证明与selinux无关。
查看日志发现了这个错误!!!日志在/var/log/zabbix。

 22491:20190425:033831.771 [Z3001] connection to database 'zabbix' failed: [2059] Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

更改了mysql用户名密码的plugin。随后成功显示web端。

mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | caching_sha2_password |
| localhost | zabbix           | mysql_native_password |
+-----------+------------------+-----------------------+

mysql> alter user 'zabbix'@'localhost' identified by 'password';
mysql> alter user 'zabbix'@'localhost' identified with mysql_native_password by 'password';

成功。
注意第一个代码是改密码,第二个代码是改plugin。
在这里插入图片描述
说一下心得吧,这个东西感觉难度都没什么就是在连接数据库的时候好糟心,如果后续遇到服务器来但是web不显示的问题。更改验证码之后还不行。建议把数据库建设的流程重新走一遍。看了很多网上的文档之后的总结。

高兴早了。
在这里插入图片描述

php_value date.timezone Asia/Beijing

好像忘记保存了。
在这里插入图片描述
下一步要输入一个数据库密码,其他就别动了下一步就好了。然后成功界面。
在这里插入图片描述
默认用户名为Admin,密码为zabbix,注意账户大写。
在这里插入图片描述

php_value date.timezone Asia/Shanghai

再回去改一下,好像中国的时区是Shanghai。
成功了。
在这里插入图片描述

欢迎指教qq79723521.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aggy阿吉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值