Skip to the content.

1. install zabbix server

1.1 使用网络源

[root@zabbix-server yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@zabbix-server ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
[root@zabbix-server yum.repos.d]# cat zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch 
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0

1.2 使用本地源

# download pkgs for zabbix
yum install --downloadonly --downloaddirectory=/mnt zabbix-* mariadb-server

# make a repo
cd /mnt/
createrepo .

# make a repo file 
cat >/etc/yum.repos.d/zabbix.repo <<EOF
[zabbix-local]
name=zabbix local host
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF

1.3 开始安装配置

[root@zabbix-server yum.repos.d]# yum install wget vim tree -y
[root@zabbix-server yum.repos.d]# yum install zabbix-server-mysql zabbix-web-mysql mariadb-server httpd
[root@zabbix-server yum.repos.d]# systemctl start mariadb-server
[root@zabbix-server yum.repos.d]# systemctl enable mariadb-server
[root@zabbix-server yum.repos.d]# mysql_secure_installation 

# 创建数据库和用户
[root@zabbix-server yum.repos.d]# mysql -u root -p
MariaDB [(none)]> create database zabbix character set utf8;
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
MariaDB [(none)]> flush privileges;

# 导入数据,导入看了默认的用户名和密码(Admin/zabbix)
[root@zabbix-server yum.repos.d]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

# 如果没有这个脚本的话,可以下载源码,分别导入
[root@zabbix-server mysql]# cat schema.sql |mysql -uzabbix -p zabbix
Enter password:
[root@zabbix-server mysql]# cat images.sql |mysql -uzabbix -p zabbix
Enter password:
[root@zabbix-server mysql]# cat data.sql |mysql -uzabbix -p zabbix
Enter password:


修改中文界面

2. Install Agent

2.1 准备客户端

2.2 RHEL/CentOS

使用yum或rpm进行安装,agent包依赖很少,几乎不需要单独安装依赖包;

rpm -ivh zabbix-agent-4.0.26-1.el7.x86_64.rpm
vim /etc/zabbix/zabbix-agent.conf
systemctl enable zabbix-agent.service
systemctl start zabbix-agent.service

zabbix-agent.conf需要修改的几个参数,类似下面这几个

PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=172.16.102.101
ServerActive=172.16.102.101
Include=/etc/zabbix/zabbix_agentd/*.conf
Hostname=node1
HostMetadata=linux

2.3 AIX

有些版本的客户端需要包比较特殊,所以尽量选择不需要单独安装额外依赖的客户端

配置文件/etc/zabbix/zabbix_agentd.conf

-bash-4.2# cat /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=172.16.102.101
ServerActive=172.16.102.101
Include=/etc/zabbix/zabbix_agentd/*.conf
Hostname=hanode2
HostMetadata=aix

自启动文件/etc/rc.d/rc2.d/Szabbixagentd

-bash-4.2# cat /etc/rc.d/rc2.d/Szabbixagentd
#!/bin/sh
##########################################################
###### Zabbix agent daemon init script
##########################################################
case $1 in
start)
    su zabbix -c "/usr/local/bin/zabbix/zabbix_agentd" ;;
stop)
    kill -TERM `cat /var/run/zabbix/zabbix_agentd.pid` ;;
restart)
    $0 stop
    sleep 5
    $0 start
    ;;
stat)
    [ -f /var/run/zabbix/zabbix_agentd.pid ] &&
            echo "Zabbix agent is running." ||
            echo "Zabbix agent is NOT running."
    ;;
*)
    echo "Usage: $0 start|stop|restart"
    exit 1
esac

附录aix客户端自动安装脚本

2.4 Windows

二进制文件

/cygdrive/c/zabbix_agent $ ls
dev  zabbix_agentd.conf  zabbix_agentd.exe  zabbix_agentd.log  zabbix_get.exe  zabbix_sender.exe

配置文件

$ cat zabbix_agentd.conf
LogFile=c:\zabbix_agent\zabbix_agentd.log
Server=172.16.102.101
ServerActive=172.16.102.101
Hostname=mywindows
HostMetadata=win

自启动

zabbix_agentd.exe -i  -c c:\zabbix_agent\zabbix_agentd.conf   # 安装服务 默认conf为c:\zabbix_agentd.conf
zabbix_agentd.exe  -s   # 启动服务

附录