配置IP地址
TYPE="Ethernet"
BOOTPROTO="static"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="c6ccf3d4-1631-4ad8-b106-767335dfd119"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.22.39"
GATEWAY="192.168.22.254"
NETMASK="255.255.255.0"
DNS1="114.114.114.114"
DNS2="8.8.8.8"
设置主机名
[root@localhost ~]# vim /etc/sysconfig/network
# Created by anaconda
HOSTNAME=gzt.linux.org
[root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.22.39 gzt gzt.linux.org
关闭 kdump 与 SELinux
[root@localhost ~]# vim /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 two 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 ~]# systemctl disable kdump
[root@localhost ~]# systemctl stop kdump
[root@localhost ~]# reboot
安装Apache 和 Mariadb
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# yum install mariadb-server -y
[root@gzt ~]# systemctl start httpd.service
[root@gzt ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@gzt ~]# systemctl start mariadb.service
[root@gzt ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
安装php包
[root@localhost ~]# yum -y install php
安装PHP组件,使PHP支持 MariaDB
[root@localhost ~]# yum -y install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
重启MariaDB、 Apache
[root@gzt ~]# systemctl restart mariadb.service
[root@gzt ~]# systemctl restart httpd.service
[root@gzt ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.ox4o84: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.0-2.el7 ################################# [100%]
[root@gzt ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: yum zabbix zabbix-non-supported
Cleaning up everything
Cleaning up list of fastest mirrors
2、安装Zabbix server,Web前端,agent
[root@gzt ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
[root@gzt ~]#yum -y install centos-release-scl
3、对数据库进行初始化并创建Zabbix数据库
[root@gzt ~]# mysqladmin -u root password 123456789
[root@gzt ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by'Z123456789';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
[root@gzt ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.27/create.sql.gz |mysql -uroot zabbix -p (123456789)
[root@gzt ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost //第91行
DBName=zabbix //第101行
DBUser=zabbix //第117行
DBPassword=Z123456789 //第125行
[root@gzt ~]# systemctl start zabbix-server
[root@gzt ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@gzt ~]# vim /etc/httpd/conf.d/zabbix.conf
。。。。。。
php_value date.timezone Asia/Chongqing
。。。。。。
[root@gzt ~]# firewall-cmd --permanent --zone=public --add-port=10051/tcp
success
[root@gzt ~]# firewall-cmd --zone=public --add-port=10051/tcp
success
[root@gzt ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[root@gzt ~]# firewall-cmd --zone=public --add-port=80/tcp
success
[root@gzt ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@gzt ~]# systemctl enable zabbix-server zabbix-agent httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@gzt ~]# firefox http://127.0.0.1/zabbix
WebUI主界面
关闭 kdump 与 SELinux
[root@localhost ~]# vim /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 two 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 ~]# systemctl disable kdump
[root@localhost ~]# systemctl stop kdump
[root@localhost ~]# reboot
Linux Agent的安装与配置
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.6AMf64: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.0-2.el7 ################################# [100%]
[root@localhost ~]# yum -y install zabbix-agent
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.22.222 //第98行
ServerActive=192.168.22.222 //第139行
[root@localhost ~]# systemctl start zabbix-agent.service
[root@localhost ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# netstat -anpt |grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1097/zabbix_agentd
tcp6 0 0 :::10050 :::* LISTEN 1097/zabbix_agentd
右上角“创建主机”——> 主机:添加主机名,群组,客户机IP——>模板:选择模板类型;添加;添加。
1、下载地址https://cdn.zabbix.com/zabbix/binaries/stable/4.0/4.0.27/zabbix_agent-4.0.27-windows-amd64.zip
2、将下载好的安装包解压到C盘根目录下,并将zabbix_agent-4.0.27-windows-amd64\conf\zabbix_agentd.conf 复制到C盘根目录下,如图
3、使用电脑自带写字板工具编辑zabbix_agentd.conf,添加监控服务器IP地址,修改主机名为本机主机名
4、以管理员权在这里插入代码片限运行CMD
5、安装并启动
C:\>cd zabbix_agent-5.0.2-windows-amd64\bin
C:\zabbix_agent-5.0.2-windows-amd64\bin>zabbix_agentd.exe -c c:\zabbix_agentd.conf -i
C:\zabbix_agent-5.0.2-windows-amd64\bin>zabbix_agentd.exe -c c:\zabbix_agentd.conf -s
6、防火墙设置:控制面板——系统和安全——防火墙——高级设置——入站规则——新建规则——端口——TCP;特定本地端口10050——允许连接——下一步——名称自拟——完成