安装准备工作
我们可能需要的很多包不可用,为了避免在处理zabbix Server安装时出现任何问题,我们需要修改sources.list文件如下:
~# vi /etc/apt/sources.list deb http://archive.ubuntu.com/ubuntu bionic main universe deb http://archive.ubuntu.com/ubuntu bionic-security main universe deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
Zabbix 服务器需要一个 Apache2 ,一些 PHP 包和 Mysql/Mariadb ,执行以下命令:
~# apt update ~# apt install apache2 libapache2-mod-php ~# apt install php php-pear php-cgi php-common libapache2-mod-php php-mbstring php-net-socket php-gd php-xml-util php-mysql php-gettext php-bcmath ~# apt install mariadb-server
启动并启用 Apache2 和 Mariadb 服务器以在引导系统上运行:
~# systemctl enable apache2 && systemctl start apache2 ~# systemctl enable mariadb && systemctl start mariadb
不要忘记使用 mysql_secure_installtion 为 root 设置密码
步骤 5 – 配置 Zabbix 前端
导航到 http://ip_address/zabbix 或者 http://host_name/zabbix
确保满足所有软件准备工作。
输入连接到数据库的详细信息。
Zabbix 数据库必须已经创建。
输入 Zabbix 服务器详细信息。
查看设置摘要。
完成安装。
现在你将被重定向到 zabbix web 控制台页面。
默认用户名为 Admin ,密码为 zabbix 。
步骤 1 – 使用 MySQL 安装 Zabbix Server
在开始安装之前,我们需要使用以下命令安装 zabbix 存储库:
~# wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.deb ~# dpkg -i zabbix-release_4.0-2+bionic_all.deb
现在使用以下命令安装 Zabbix 和必要的包
~# apt update ~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent zabbix-get
关于 Zabbix
Zabbix 是一款免费的开源网络监控软件工具,用于监控和跟踪 IT 基础设施的可用性和性能:服务器、网络设备和其他 IT 资产。
在本文中,我们将在 Ubuntu 18.04 LTS 上安装 Zabbix Server 4.x,为了使用 Zabbix,我们需要一个 Web 服务器(Apache)、数据库服务器(Mysql、Mariadb、Postgresql ...)和 PHP 才能工作。
步骤 3 – 创建并导入初始 zabbix 数据库和用户
首先我们需要创建zabbix数据库(zabbixdb)并创建一个zabbix用户(zabbixuser)。
~# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 49 Server version: 10.1.34-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04 Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database zabbixdb character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on zabbixdb.* to jack@onitroad identified by 'Password'; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit; Bye
创建 zabbix Server 数据库和用户后,我们需要使用以下命令导入 zabbix Server 初始数据库:
~# zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbixuser -p zabbixdb Enter password:
现在打开 /etc/zabbix/zabbix_server.conf 文件并指定 zabbix 数据库名称、zabbix 用户名和密码,如下所示:
DBHost=localhost DBName=zabbixdb DBUser=zabbixuser DBPassword=Password
配置数据库连接后,我们需要在启动时使用以下命令启用并启动 zabbix-server 服务和 zabbix-agent 服务:
~# systemctl enable zabbix-server && systemctl start zabbix-server ~# systemctl enable zabbix-agent && systemctl start zabbix-agent
步骤 2 - 编辑 PHP 时区
用你喜欢的编辑器打开 Zabbix 创建的 /etc/zabbix/apache.conf 文件
~# vi /etc/zabbix/apache.conf
有必要取消注释“date.timezone”设置并设置正确的时区。
php_value date.timezone Europe/Rome
还需要在 php.ini 文件中设置正确的时区
~# vi /etc/php/7*/apache2/php.ini [...] date.timezone = Europe/Rome [...]
保存文件,不要忘记使用以下命令重新加载 apache2 服务:
~# systemctl reload apache2
步骤 4 – 调整防火墙
执行以下命令开启Zabbix server和agent之间的http服务和连接
~# ufw allow http ~# ufw allow proto tcp from any to any port 10050,10051 ~# ufw reload