apt源安装
安装mysql
[root@zabbix-mysql ~]# apt install -y mysql-server
配置mysql
[root@zabbix-mysql ~]# vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0
重启并开机启动
[root@zabbix-mysql ~]# systemctl restart mysql
[root@zabbix-mysql ~]# systemctl enable mysql
mysql 进入数据库创建账户并授权
[root@zabbix-mysql ~]# mysql
mysql> create database zabbix_server character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix_server.* to zabbix@'172.31.1.%' identified by 'centos.com';
Query OK, 0 rows affected, 1 warning (0.00 sec)
下载安装zabbix
[root@zabbix-server ~]# wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb
安装zabbix源
[root@zabbix-server ~]# dpkg -i zabbix-release_4.0-3+bionic_all.deb
[root@zabbix-server ~]# apt update
安装Zabbix server,Web前端,agent
[root@zabbix-server ~]# apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
在zabbix server初始化数据库
# 测试zabbix用户登录数据库
[root@zabbix-server ~]# mysql -uzabbix -p'centos.com' -h 172.31.1.21
查看源安装的一个数据库初始化包
[root@zabbix-server ~]# ll /usr/share/doc/zabbix-server-mysql/
total 1312
-rw-r--r-- 1 root root 2698 Jun 11 11:01 changelog.Debian.gz
-rw-r--r-- 1 root root 980 Jun 11 11:01 copyright
-rw-r--r-- 1 root root 1307849 Jun 11 11:01 create.sql.gz
导入数据库:(在zabbix-server)
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p'centos.com' -h 172.31.1.21 zabbix_server
再次进入数据库查看是否有多出zabbix相关的表
[root@zabbix-server ~]# mysql -uzabbix -p'centos.com' -h 172.31.1.21
mysql> use zabbix_server;
mysql> show tables;
+----------------------------+
| Tables_in_zabbix_server |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
...
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
144 rows in set (0.00 sec)
修改zabbix-server的配置文件
[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=172.31.1.21
DBName=zabbix_server
DBUser=zabbix
DBPassword=centos.com
DBPort=3306
修改php配置文件的时区
[root@zabbix-server ~]# vim /etc/zabbix/apache.conf
php_value date.timezone Asia/Shanghai
重启服务
[root@zabbix-server ~]# systemctl restart zabbix-server.service apache2 zabbix-agent.service
浏览器登录:172.31.1.20/zabbix/setup.php
安装中文
[root@zabbix-server ~]# sudo apt-get install language-pack-zh*
设置
[root@zabbix-server ~]# sudo vim /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/loca
l/games"
LANG="zh_CN.UTF-8"
重置(选择zh_CN_UTF-8)
[root@zabbix-server ~]# sudo dpkg-reconfigure locales
重启apache
[root@zabbix-server ~]# systemctl restart apache2
改zabbix界面的乱码问题
[root@zabbix-server fonts]# pwd
/usr/share/zabbix/assets/fonts
[root@zabbix-server fonts]# ls
graphfont.ttf STKAITI.TTF
[root@zabbix-server fonts]# mv graphfont.ttf graphfont.ttf.bak
[root@zabbix-server fonts]# mv STKAITI.TTF graphfont.ttf
[root@zabbix-server fonts]# ll
total 12448
drwxr-xr-x 2 root root 4096 Jul 29 11:01 ./
drwxr-xr-x 5 root root 4096 Jul 29 09:13 ../
-rw-r--r-- 1 root root 12736196 Jul 29 10:59 graphfont.ttf
lrwxrwxrwx 1 root root 38 Jul 29 09:13 graphfont.ttf.bak -> /etc/alternatives/zabbix-frontend-font
|