首页 🙇‍♂️ DevOps

系统环境:Rocky Linux 9

Zabbix 版本:6.0.3

1 配置环境

1.1 关闭 Selinux

setenforce 0
sed -i "s%SELINUX=enforcing%SELINUX=disabled%" /etc/selinux/config

1.2 配置 yum 源

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-3.el9.noarch.rpm

2 安装 Zabbix 服务

dnf install vim zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent -y

3 安装数据库

3.1 安装 Mariadb

dnf install mariadb-server mariadb -y

3.2 启动 Mariadb

systemctl start mariadb && sudo systemctl enable mariadb

3.3 初始化 Mariadb

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!

3.4 创建 Zabbix 数据库

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

3.5 导入初始化数据库文件

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p'zabbix@rocky' zabbix

4 配置 Zabbix

编辑数据库连接配置文件:

vim /etc/zabbix/zabbix_server.conf

调整以下值:

DBName=zabbix
DBUser=zabbix
DBPassword=zabbix@rocky

重启 Zabbix Server 服务:

systemctl restart zabbix-server

编辑配置文件修改时区:

vim /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

编辑 agent 配置文件对接 server 地址:

vim /etc/zabbix/zabbix_agentd.conf
Hostname=192.168.2.109

重启所有服务:

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

防火墙开放必要端口:

firewall-cmd --add-service={http,https} --permanent
firewall-cmd --add-port={10051/tcp,10050/tcp} --permanent
firewall-cmd --reload

5 Web 页面安装

浏览器访问地址:http://192.168.2.109/zabbix

image-20220918154847719

继续下一步:

image-20220918154921324

配置数据库连接信息:

image-20220918155044278

配置 Zabbix 服务器名称和主题:

image-20220918155219190

回显已配置信息:

image-20220918155250487

完成:

image-20220918155321237

默认登录凭据是:

  • Username:Admin
  • Password:zabbix

image-20220918155359405

通过验证后登录首页如下:

image-20220918155518248

更改密码:

Administration > Users > Admin > Change password > 输入两次新密码 > 123456@zs > update

6 配置监控

6.1 监控自身

Configuration > Hosts

会发现自身已经被配置监控了:

image-20220918160637070

7 修改语言

点击 User settings > Profile > Language,我们发现 Chinese (zh_CN) 无法选择,提示:You are not able to choose some of the languages, because locales for them are not installed on the web server.,这是由于系统未设置中文语言,因此无法在 Zabbix 中设置中文。

image-20220918161023897

执行以下步骤进行系统中文环境设置:

dnf install glibc-langpack-zh.x86_64 -y
localectl list-locales
localectl set-locale LANG="zh_CN.utf8"
source /etc/locale.conf
echo $LANG

回到浏览器 Zabbix 页面重新刷新:

image-20220918161807695

此时已经有中文了,我们选择 Chinese (zh_CN),点击 update 即可:

image-20220918161928196

8 运维

## 启动服务
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

9 参考

Install Zabbix Server on Rocky Linux 9 / AlmaLinux 9




文章评论

    gtrfd 访客FireFoxWindows
    2022-10-8 9:04   回复

    谢谢分享

目录