实验环境:
关掉防火墙和selinux,时间同步,一台192.168.121.30的主机
一、安装zabbix
1.1下载基础安装包
# yum -y install lrzsz tar net-tools chrony
# timedatectl
# rpm -Uvh zabbix-release-7.0-2.el9.noarch.rpm -----上传rpm包,并更新到/etc/yum.repo
1.2更改yum并下载所需要的安装包
[root@node3 ~]# vim /etc/yum.repos.d/zabbix.repo 把zabbix的yum换成阿里源,下载更快
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/7.0/rocky/9/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/9/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-08EFA7DD
gpgcheck=1
[zabbix-sources]
name=Zabbix Official Repository source code - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rocky/9/SRPMS
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
gpgcheck=1
[root@node3 ~]# vim /etc/yum.repos.d/epel.repo -----在第一个gpgkey下一行加下下面的内容
excludepkgs=zabbix*
[root@node3 ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent mariadb-server mariadb -y ----下载zabbix所需要的数据库,nginx网页,selinux,服务端和客户端
[root@node3 ~]# systemctl restart mariadb.service
[root@node3 ~]# systemctl enable mariad
[root@node3 ~]# hostnamectl hostname zabbix.example.com
[root@node3 ~]# bash
[root@zabbix ~]# mysql_secure_installation -----初始化数据库
回车+yynyy
1.3设置数据库
[root@zabbix ~]# mysql -uroot -p123 ---进入数据库
create database zabbix character set utf8mb4 collate utf8mb4_bin; 创建数据库zabbix,设置字符集为中文
create user zabbix@localhost identified by '123'; 创建本地用户zabbix,密码123
grant all privileges on zabbix.* to zabbix@localhost; 赋予权限给zabbix数据库下面所有的表,全部权限
set global log_bin_trust_function_creators = 1; 允许普通用户添加数据
flush privileges; 刷新权限
exit; 退出
# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p123 zabbix ----将zabbix的数据导入数据库,字符集为中文字符集,-u用户zabbix,-p密码123,最后接数据库zabbix,等待十几秒
[root@zabbix ~]# mysql -uroot -p123
set global log_bin_trust_function_creators = 0;
flush privileges;
use zabbix;
show tables; --查看是否导入成功
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
ListenPort=10051 //使用的端口为10051,管理端口
DBHost=localhost //数据库主机
DBName=zabbix //数据库名字
DBUser=zabbix //数据库用户
DBPassword=123 //数据库密码
DBSocket=/var/lib/mysql/mysql.sock //数据库指针
ListenIP=0.0.0.0 //监听所有ip地址
[root@zabbix ~]# vim /etc/nginx/conf.d/zabbix.conf ----第二行和第三行的注释去掉,设置网页
listen 8080;
server_name example.com;
[root@zabbix ~]# systemctl restart zabbix-server.service nginx.service zabbix-agent.service php-fpm ---重启相关服务
[root@zabbix ~]# systemctl enable zabbix-server.service nginx.service zabbix-agent.service php-fpm ----下次开机自启动
[root@zabbix ~]# ss -anlt ---全部端口运行成功
http://192.168.121.30:8080访问并进入
二、添加一台主机下载中文模式和中文设置
[root@zabbix ~]# yum -y install langpacks-zh_CN.noarch glibc-common ---下载中文输入
[root@zabbix ~]# locale -a | grep zh_CN 查看
2.1刷新选择中文模式
查看所有选择都ok
填写mysql数据库的端口3306,和zabbix用户的密码
设置一个自己喜欢的名字
一直下一步,登录默认的管理用户和密码
用户:Admin
密码:zabbix
2.2添加一台主机192.168.121.50
命名为client1.example.com,ping zabbix服务端可以ping通
[root@client1 ~]# ping 192.168.121.30
2.2换源,只需要下载客户端
[root@client1 ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/7.0/rocky/9/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/9/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-08EFA7DD
gpgcheck=1
[zabbix-sources]
name=Zabbix Official Repository source code - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rocky/9/SRPMS
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
gpgcheck=1
[root@client1 ~]# vim /etc/yum.repos.d/epel.repo
excludepkgs=zabbix*
[root@client1 ~]# yum -y install zabbix-agent -----换源前面有,下载客户端
[root@client1 ~]# vim /etc/zabbix/zabbix_agentd.conf
/Server=192.168.121.30 zabbix服务器的IP,agent被动监控(默认模式)
/ServerActive=192.168.121.30 zabbix服务器的IP,agent主动监控
/Hostname=zabbix-agent zabbix服务器的主机名
[root@client1 ~]# systemctl restart zabbix-agent.service
[root@client1 ~]# systemctl enable zabbix-agent.service
2.2、找到windows下的简体 楷体 常规字体,在服务端
到C:\Windows\Fonts
2、将简体 楷体 常规字体文件复制出来
3、上传到Linux系统中的/usr/share/zabbix/assets/fonts
4、替换原先的字体文件即可
[root@zabbix ~]# cd /usr/share/zabbix/assets/fonts/
#mv simkai.ttf graphfont.ttf
[root@zabbix fonts]# systemctl restart zabbix-server.service
[root@zabbix fonts]# systemctl restart zabbix-agent.service
改变字体