Zabbix 监控服务部署

2023-05-02 10:14:22 浏览数 (3)

系统环境:Rocky Linux 9 Zabbix 版本:6.0.3

1、配置环境

1.关闭 Selinux
代码语言:javascript复制
setenforce 0
sed -i "s%SELINUX=enforcing%SELINUX=disabled%" /etc/selinux/config
2.配置 yum 源
代码语言:javascript复制
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-3.el9.noarch.rpm

2、安装Zabbix 服务

代码语言:javascript复制
dnf install vim zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent -y

3、安装数据库

1.安装 Mariadb
代码语言:javascript复制
dnf install mariadb-server mariadb -y
2.启动 Mariadb
代码语言:javascript复制
systemctl start mariadb && sudo systemctl enable mariadb
3.初始化 Mariadb
代码语言:javascript复制
mariadb-secure-installation 
 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
 
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
 
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
 
You already have your root account protected, so you can safely answer 'n'.
 
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!
 
 
You already have your root account protected, so you can safely answer 'n'.
 
Change the root password? [Y/n] n
 ... skipping.
 
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n] y
 ... Success!
 
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n] n
 ... skipping.
 
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] y
 ... Success!
 
Cleaning up...
 
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
 
Thanks for using MariaDB!
4.创建Zabbix数据库
代码语言:javascript复制
mysql -uroot -p'123456'
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8mb4 collate utf8mb4_bin;
MariaDB [(none)]> CREATE USER zabbix@localhost IDENTIFIED by 'zabbix@rocky';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> QUIT
5.导入初始化数据库文件
代码语言:javascript复制
zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p'zabbix@rocky' zabbix

4、配置 Zabbix

此处内容需要评论回复后方可阅读

8、运维

代码语言:javascript复制
## 启动服务
systemctl start mariadb
systemctl start php-fpm
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl start httpd
## 关闭服务
systemctl stop mariadb
systemctl stop php-fpm
systemctl stop zabbix-server
systemctl stop zabbix-agent
systemctl stop httpd
## 查询服务状态
systemctl status mariadb
systemctl status php-fpm
systemctl status zabbix-server
systemctl status zabbix-agent
systemctl status httpd

参考

Install Zabbix Server on Rocky Linux 9 / AlmaLinux 9

0 人点赞