正文

中科方德 操作系统镜像下载_服务器

5.安装数据库

[root@pdsyw-server ~]# dnf install mariadb-server -y

中科方德 操作系统镜像下载_中科方德 操作系统镜像下载_02

6.启动数据库

[root@pdsyw-server ~]# systemctl start mariadb
[root@pdsyw-server ~]# systemctl enable mariadb
[root@pdsyw-server ~]# mysql_secure_installation

Enter current password for root (enter for none):

Switch to unix_socket authentication [Y/n] n

Change the root password? [Y/n] n

Remove anonymous users? [Y/n] Y

Disallow root login remotely? [Y/n] n

Remove test database and access to it? [Y/n] Y

Reload privilege tables now? [Y/n] Y
[root@pdsyw-server ~]#

Switch to unix_socket authentication [Y/n] n
这个提示问的是,您是否希望将 MySQL 的 root 用户认证方式切换到 unix_socket 插件。使用 unix_socket 认证允许通过操作系统用户凭证来控制对 MySQL 数据库的访问,这意味着如果您作为操作系统的 root 用户,您可以不需要密码就通过 UNIX socket 访问 MySQL。

选择 “Y” (是): 这将配置 MySQL 的 root 用户使用 UNIX socket 认证,当您作为相同的 UNIX 用户(例如,操作系统的 root 用户)尝试连接 MySQL 时,不需要密码。

选择 “n” (否): 如果您选择不使用 unix_socket 认证,MySQL 的 root 用户将保持使用密码认证。

哪个选项更适合您?
如果您计划在本地机器上管理 MySQL 且更重视便捷性,且不太担心本地安全问题,使用 unix_socket 认证是个不错的选择。这在许多默认安装和配置中是推荐的方式,尤其是当 MySQL 服务器不对外暴露时。

如果您需要通过网络连接到 MySQL 服务器,或者有使用密码认证的特定需求(例如,自动化脚本需要使用密码连接数据库),可能需要保留密码认证方式。

总之,选择是否切换到 unix_socket 认证取决于您的具体需求和安全考虑。在多数情况下,对于本地开发环境,启用 unix_socket 认证提供了方便的同时也保持了安全性。对于生产环境,您可能需要更细致地考虑这个选项。

中科方德 操作系统镜像下载_linux_03


中科方德 操作系统镜像下载_服务器_04

7.安装 PHP 及扩展

[root@pdsyw-server ~]# dnf install php php-cli php-common php-mysqlnd php-gd php-mbstring php-xml php-bcmath php-json -y

中科方德 操作系统镜像下载_服务器_05

8.添加 Zabbix 仓库

[root@pdsyw-server ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
[root@pdsyw-server ~]# dnf clean all

中科方德 操作系统镜像下载_运维_06

9.安装 Zabbix 服务器、前端和代理

[root@pdsyw-server ~]# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent -y

中科方德 操作系统镜像下载_linux_07

10.创建初始数据库

[root@pdsyw-server ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.5.22-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '1qaz@WSX';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> exit;
Bye
[root@pdsyw-server ~]#

中科方德 操作系统镜像下载_服务器_08

11.导入初始架构和数据到 Zabbix 数据库

[root@pdsyw-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

中科方德 操作系统镜像下载_中科方德 操作系统镜像下载_09

12.配置 Zabbix 服务器

[root@pdsyw-server ~]# vim /etc/zabbix/zabbix_server.conf
[root@pdsyw-server ~]#
[root@pdsyw-server ~]# grep DBHost= /etc/zabbix/zabbix_server.conf
# DBHost=localhost
DBHost=localhost
[root@pdsyw-server ~]# grep DBName= /etc/zabbix/zabbix_server.conf
# DBName=
DBName=zabbix
[root@pdsyw-server ~]# grep DBUser= /etc/zabbix/zabbix_server.conf
# DBUser=
DBUser=zabbix
[root@pdsyw-server ~]#
[root@pdsyw-server ~]# grep DBPassword= /etc/zabbix/zabbix_server.conf
# DBPassword=
DBPassword=1qaz@WSX
[root@pdsyw-server ~]#

中科方德 操作系统镜像下载_运维_10

13.启动 Zabbix 服务器和代理

[root@pdsyw-server ~]# systemctl start zabbix-server zabbix-agent
[root@pdsyw-server ~]# systemctl enable zabbix-server zabbix-agent
[root@pdsyw-server ~]# systemctl status zabbix-server zabbix-agent

中科方德 操作系统镜像下载_运维_11

14.配置 PHP 为 Zabbix 前端

[root@pdsyw-server ~]# vim /etc/php-fpm.d/zabbix.conf
[root@pdsyw-server ~]#
[root@pdsyw-server ~]# cat /etc/php-fpm.d/zabbix.conf
[zabbix]
user = apache
group = apache

listen = /run/php-fpm/zabbix.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200

php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session

php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Shanghai
[root@pdsyw-server ~]#

中科方德 操作系统镜像下载_运维_12

15.重启 Apache 和 PHP-FPM

[root@pdsyw-server ~]# systemctl restart httpd php-fpm
[root@pdsyw-server ~]# systemctl status httpd php-fpm

中科方德 操作系统镜像下载_服务器_13

16.放开防火墙

中科方德 操作系统镜像下载_运维_14