我这次的安装环境:
zabbix:5.0 LTS版;
操作系统:centos 7;
数据库:mysql 5.7(建议不要用版本8,会碰到很多故障,比如加密方式等,我们就存储个监控数据,不需要那么新,用5.7版即可,而且这个版本也是比较推荐的版本)。
整体安装流程,其实也就2步:
1、安装mysql数据库:
2、安装zabbix:根据下面这个链接选择自己的系统版本,然后会生成对应的操作步骤,根据说明操作即可。
https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=apache
详细步骤:
写在前面:最好把centos的selinux和Firewall关掉,能避免很多问题。如果你觉得不安全,可以这样安装成功后,再打开他们,并设置想要的放行规则即可。
systemctl status firewalld.service #查询防火墙当前状态
systemctl stop firewalld.service #临时禁用防火墙,下次重启系统会恢复
systemctl disable firewalld.service #永久禁用防火墙
[root@localhost ~]# getenforce #查询当前selinux状态。
Enforcing
[root@localhost ~]# setenforce 0 #临时关闭selinux。
[root@localhost ~]#
[root@localhost ~]# getenforce
Permissive
永久关闭selinux需要修改配置文件:/etc/selinux/config
[root@localhost ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing 修改为"SELINUX=disabled"
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
————————————————
版权声明:本文为CSDN博主「neo_will_mvp」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_33468857/article/details/124489504
1、安装mysql:官网:https://downloads.mysql.com/archives/community/。
(按下面的命令顺序操作,或者参考这篇文章:https://blog.csdn.net/Tiger_Paul/article/details/123044609
[root@localhost~]wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
[root@localhost~]# rpm -aq | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost~]# rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps
[root@localhost~]# tar -xvf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar -C /tmp
[root@localhost tmp]# cd /tmp/
建议按顺序安装:common --> libs --> clients --> server
[root@localhost tmp]# rpm -ivh mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
#一个都不能少,不然后面会出问题。这个如果不装,在执行zabbix教程中的:zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix整条命令时,会报错:no such file or directory。此时,只需要补充安装这个包即可。
[root@localhost tmp]# rpm -ivh mysql-community-common-5.7.37-1.el7.x86_64.rpm
[root@localhost tmp]# rpm -ivh mysql-community-libs-5.7.37-1.el7.x86_64.rpm
[root@localhost tmp]# rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm
[root@localhost tmp]# rpm -ivh mysql-community-server-5.7.37-1.el7.x86_64.rpm
2、查看mysql是否安装好了
[root@localhost ~]# which mysql #看下mysql安装到哪里了?
/usr/bin/mysql
[root@localhost ~]# systemctl start mysqld #启动mysql服务
[root@localhost ~]# systemctl status mysqld #查看mysql运行状态
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-07-08 10:54:53 CST; 5s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 4660 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 4602 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 4663 (mysqld)
Tasks: 27
CGroup: /system.slice/mysqld.service
└─4663 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Jul 08 10:54:48 localhost.localdomain systemd[1]: Starting MySQL Server...
Jul 08 10:54:53 localhost.localdomain systemd[1]: Started MySQL Server.
[root@localhost ~]#
[root@localhost ~]# cat /var/log/mysqld.log | grep password #查看mysql初始密码
2022-07-08T02:54:51.847741Z 1 [Note] A temporary password is generated for root@localhost: JkU;NHsqA362
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.37
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> #成功进入mysql,先把密码改了。
mysql> set password for root@localhost = password('你自己的密码');
#查看mysql当前用户及加密规则,mysql18之前的版本的加密规则是mysql_native_password,但是mysql18的是caching_sha2_password。
#修改加密规则的方式(但我们不需要):ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你自己的密码';
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host,plugin from mysql.user;
+---------------+-----------+-----------------------+
| user | host | plugin |
+---------------+-----------+-----------------------+
| root | localhost | mysql_native_password |
| mysql.session | localhost | mysql_native_password |
| mysql.sys | localhost | mysql_native_password |
+---------------+-----------+-----------------------+
3 rows in set (0.00 sec)
mysql>
mysql> flush privileges; #刷新权限
mysql> exit #退出数据库状态
Bye
[root@localhost ~]#
mysql数据库安装到此完成,下面就开始安装zabbix。
安装zabbix比较简单,按照下面这个官方文档复制粘贴命令即可:
https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=apache
如果你严格按照我上面说的做,在安装zabbix的时候是不会出任何问题的。好,到此zabbix就安装好了,下面就可以用ip登录zabbix了!
如果出现时区问题,可以重新修改timezone,把前面的那个分号去掉。然后在重启下相关服务:
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
做好步骤g后,就可以了,然后根据这个:https://www.zabbix.com/documentation/5.0/zh/manual/quickstart/login,登录zabbix。初始管理员为:Admin,密码:zabbix。