下面介绍基于ubuntu18.04,使用apt在ubuntu安装zabbix 4.0.x版本。规划在10.0.0.101
主机安装zabbix server,在10.0.0.104
安装提供msyql服务支持zabbix server。
官网文档
# wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb # sudo dpkg -i zabbix-release_4.0-3+bionic_all.deb # sudo apt update
# sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent -y
# apt update # sudo apt -y install mysql-server mysql-client #或者安装mariadb-server,mariadb-client # vim /etc/mysql/mysql.conf.d/mysqld.cnf bind-address =0.0.0.0 #修改监听地址 # systemctl enable --now mysql
# mysql -uroot mysql> create database zabbix character set utf8 collate utf8_bin; mysql> create user zabbix@'10.0.0.%' identified by 'magedu.zabbix'; mysql> grant all privileges on zabbix.* to zabbix@'10.0.0.%'; mysql> quit; # systemctl restart mysql
# apt -y install mysql-client # mysql -uzabbix -pmagedu.zabbix -h 10.0.0.104 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | zabbix | +--------------------+ 2 rows in set (0.01 sec)
##导入基础数据库 # zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pmagedu.zabbix -h 10.0.0.104 zabbix ##在mysql主机检验发现生成很多数据库 mysql> use zabbix; Database changed mysql> show tables; +----------------------------+ | Tables_in_zabbix | +----------------------------+ | acknowledges | | actions | | alerts | | application_discovery | | application_prototype | | application_template | | applications | | auditlog | .....#初始化成功
编辑配置文件,指定zabbix的相关数据库账户密码
# vim /etc/zabbix/zabbix_server.conf # grep -v "^#" /etc/zabbix/zabbix_server.conf|grep DB DBHost=10.0.0.104 DBName=zabbix DBUser=zabbix DBPassword=magedu.zabbix DBPort=3306
# vim /etc/zabbix/apache.conf <IfModule mod_php7.c> .... php_value date.timezone Asia/shanghai
# systemctl restart zabbix-server zabbix-agent apache2 # systemctl enable zabbix-server zabbix-agent apache2 # ss -ntl |grep "10050" LISTEN 0 128 0.0.0.0:10050 0.0.0.0:* LISTEN 0 128 [::]:10050 [::]:* ....省略.....
打开浏览器范文10.0.0.101/zabbix
由此,zabbix serve安装完成