这里我们使用的是centos7操作系统。
首先我们将网卡设置成DHCP模式,并开启nat模式,让虚拟机能够上网
1.更改网卡,关闭防火墙,关闭selinux
[root@localhost zabbix]# vi /etc/sysconfig/network-scripts/ifcfg-ens34
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens34
UUID=cddf032c-939a-4538-8a22-aeb03da21575
DEVICE=ens34
ONBOOT=no
[root@localhost zabbix]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost zabbix]# systemctl stop firewalld
2.安装LAMP环境,并开启对应的服务
[root@localhost zabbix]# yum -y install mariadb mariadb-server httpd php php-mysql
[root@localhost zabbix]# systemctl enable httpd
[root@localhost zabbix]# systemctl start httpd
[root@localhost zabbix]# systemctl enable mariadb
[root@localhost zabbix]# systemctl start mariadb
初始化MySQL,[root@localhost etc]# mysql_secure_installation,在初始化时,可能会遇到问题
显示找不到这个文件位置,原因是没有配置这个参数,我们进行参数的配置即可:
[root@localhost etc]# vi /etc/my.cnf
[client] 在配置文件中添加这三行即可
port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
重启mariadb服务后就可以进行初始化,进行密码的设置等。
3.安装zabbix程序
[root@localhost zabbix]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@localhost zabbix]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
[root@localhost zabbix]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
创建zabbix数据库,对zabbix数据库进行初始化
[root@localhost zabbix]# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE zabbix DEFAULT character set utf8 collate utf8_bin; 创建zabbix数据库,字符为utf-8
MariaDB [(none)]> GRANT all ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix'; 给zabbix数据库创建用户名和密码,赋予权限,用户名zabbix,密码zabbix
MariaDB [(none)]> flush privileges; 刷新权限
读入数据库
[root@localhost zabbix]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@localhost zabbix-server-mysql-3.2.11]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@localhost zabbix-server-mysql-3.2.11]# zcat create.sql.gz | mysql -uroot -p zabbix
更改zabbix服务器的配置文件,将名字密码写入
[root@localhost zabbix-server-mysql-3.2.11]# cd /etc/zabbix/
[root@localhost zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@localhost zabbix]# vi zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBPassword=zabbix
[root@localhost zabbix]# systemctl restart zabbix-server
4.登入zabbix
打开浏览器输入192.168.150.130/zabbix (ip/zabbix),端口号改为3306,输入密码zabbix,进入,在提示登录zabbix,zabbix默认用户名是Admin,密码是zabbix,登录后就可以看到
我们先把页面修改为中文模式:点击administrator,再点击users
点击admin
下拉找到Chinese,点击update,刷新即可完成
5.添加客户端
[root@localhost zabbix]# cd /etc/zabbix/
[root@localhost zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@localhost zabbix]# vi zabbix_agentd.conf
Server=192.168.150.130
ServerActive=192.168.150.130
Hostname=192.168.150.130
[root@localhost zabbix]# systemctl restart zabbix-agent.service
打开zabbix web页面,点击配置,点击主机
点击创建主机
主机名称必须全英文,可见名称随便,群组必须加,IP地址就是运行zabbix-agent的ip
再点击模板,模板就是所监听的一些协议,点击选择
这里随便勾选,因为我开启了Apache,并且远程登录着,所以我选择了https,ssh等,点击下方的选择
再点击添加,一定要点击添加,否则配置不生效
回到主机选项卡,点击下方的添加,即可完成
点击监测中,点击图形,点击群组,选择相应的群组,点击主机,选择主机,点击图形,选择想查看的信息
这样即可完成,但是我们可以看到下方有字体无法显示,我们可以用本机的字体对zabbix进行配置.
6.zabbix字体更改设置
将本机的字体拷贝到192.168.150.130中,注意,提前安装lrzsz,就可以直接拉过来
[root@localhost ~]# ls
anaconda-ks.cfg SIMFANG.TTF SIMFANG.TTF就是我们拷贝的字体
[root@localhost ~]# mv SIMFANG.TTF /usr/share/zabbix/fonts/song.ttf 放到zabbix/fonts字体库里,并改名字和格式,因为zabbix只是别ttf格式
[root@localhost ~]#
修改zabbix里的php页面的指向字体
[root@localhost ~]# vi /usr/share/zabbix/include/defines.inc.php
找到FONT_NAME, 将后面的名字改为song,保存退出即可
回到zabbix的web页面进行刷新,即可看到字体已经修改成功。