Install Zabbix repository
wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb sudo apt update
安装Zabbix server,Web前端,agent
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent mysql-server
创建初始数据库
mysql_secure_installation
创建数据库
root@i-o1ms6u18:~# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu) Copyright (c) 2000, 2023, 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> create database zabbix character set utf8mb4 collate utf8mb4_bin; Query OK, 1 row affected (0.00 sec) mysql> create user zabbix@localhost identified by 'password'; Query OK, 0 rows affected (0.01 sec) mysql> grant all privileges on zabbix.* to zabbix@localhost; Query OK, 0 rows affected (0.00 sec) mysql> set global log_bin_trust_function_creators = 1; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> quit; Bye
导入初始架构和数据,系统将提示您输入新创建的密码。
root@i-o1ms6u18:~# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Disable log_bin_trust_function_creators option after importing database schema.
root@i-o1ms6u18:~# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu) Copyright (c) 2000, 2023, 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> set global log_bin_trust_function_creators = 0; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> quit; Bye
d. 为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
root@i-o1ms6u18:~# vim /etc/zabbix/zabbix_server.conf DBPassword=password
为Zabbix前端配置PHP
编辑配置文件 /etc/zabbix/nginx.conf uncomment and set 'listen' and 'server_name' directives.
root@i-o1ms6u18:~# vim /etc/zabbix/nginx.conf listen 80; server_name 139.198.34.146;
启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
root@i-o1ms6u18:~# systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm root@i-o1ms6u18:~# systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm Synchronizing state of zabbix-server.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable zabbix-server Synchronizing state of zabbix-agent.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable zabbix-agent Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable nginx Synchronizing state of php8.1-fpm.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable php8.1-fpm Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /lib/systemd/system/zabbix-server.service.
继续阅读
评论