Ubuntu安装 Zabbix 3.4

 

1. Zabbix Server安装

1) 部署Zabbix需要LAMP环境(Linux、Apache、MySQL、PHP),所以首先要安装Apache(当然,nginx也可以)、MySQL和PHP

#安装apahce2
sudo apt-get install apache2 
#安装mysql
sudo apt-get install mysql-server
#安装php
sudo apt-get install php7.0 php7.0-gd libapache2-mod-php7.0   php7.0-mysql php7.0-bcmath php7.0-mbstring php7.0-xml

2)获取3.4zabbix安装包

wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb

3) 安装zabbix Server

#使用dpkg安装3.4deb包
dpkg -i zabbix-release_3.4-1+xenial_all.deb
#更新apt
apt update
#安装zabbix web程序
apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
#拷贝web程序到apache2
sudo cp -r /usr/share/zabbix /var/www/html/zabbix

4) 建立zabbix的库表,并导入数据

mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;

5)初始化导入表结构
导入表结构和数据,官网的/usr/share/doc/zabbix-server-mysql*/create.sql.gz目录是错误的,并不是doc下

zcat /usr/share/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

6)修改zabbix_server.conf文件

sudo vim /etc/zabbix/zabbix_server.conf


配置参考如下,主要是修改密码

DBHost=localhost
DBName=zabbix 
DBUser=zabbix  
DBPassword=zabbix12345

7) 重启zabbix

sudo /etc/init.d/zabbix-server restart

8) 添加开启运行服务

systemctl restart zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2

2. 安装web控制台

https://blog.csdn.net/yannanxiu/article/details/54924198

3.Zabbix Agent安装

1)获取agent3.4.10包

wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix/zabbix-agent_3.4.10-1%2Bxenial_amd64.deb

2) 使用dpkg安装3.4deb包

dpkg -i zabbix-agent_3.4.10-1+xenial_amd64.deb 

3) 配置agent配置文件

vim /etc/zabbix/zabbix_agentd.conf

修复以下三个配置项目:

Server=10.0.16.3
ServerActive=10.0.16.3
Hostname=worker-test-01

4)启动agnet

/etc/init.d/zabbix-agent start

5) 配置开机自动启动

systemctl enable zabbix-agent

4.故障排除:

1.zabbix-agent启动报错
systemctl restart zabbix-agent.service

Job for zabbix-agent.service failed because the control process exited with error code.

See "systemctl status zabbix-agent.service" and "journalctl -xe" for details.

通过命令查看日志

journalctl -xe 



-- Subject: Unit zabbix-agent.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit zabbix-agent.service has begun starting up.
Jul 23 17:37:45 gateway-prod-01 zabbix_agentd[3207]: /usr/sbin/zabbix_agentd: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or direct
Jul 23 17:37:45 gateway-prod-01 systemd[1]: zabbix-agent.service: Control process exited, code=exited status=127
Jul 23 17:37:45 gateway-prod-01 systemd[1]: Failed to start Zabbix Agent.
-- Subject: Unit zabbix-agent.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit zabbix-agent.service has failed.
-- 
-- The result is failed.
Jul 23 17:37:45 gateway-prod-01 systemd[1]: zabbix-agent.service: Unit entered failed state.
Jul 23 17:37:45 gateway-prod-01 systemd[1]: zabbix-agent.service: Failed with result 'exit-code'.
Jul 23 17:37:56 gateway-prod-01 systemd[1]: zabbix-agent.service: Service hold-off time over, scheduling restart.
Jul 23 17:37:56 gateway-prod-01 systemd[1]: Stopped Zabbix Agent.

系统缺少unixODBC库包

安装unixODBC
#apt install odbcinst

apt install odbcinst

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 odbcinst : Depends: odbcinst1debian2 (>= 2.3.1) but it is not going to be installed
 zabbix-agent : Depends: libcurl3 (>= 7.16.2) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

 #apt-get -f install

apt-get -f install

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-91 linux-headers-4.4.0-91-generic linux-image-4.4.0-91-generic linux-image-extra-4.4.0-91-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libcurl3
The following NEW packages will be installed:
  libcurl3
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
1 not fully installed or removed.
Need to get 187 kB of archives.
After this operation, 564 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.tencentyun.com/ubuntu xenial-security/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.8 [187 kB]
Fetched 187 kB in 0s (631 kB/s)  
Selecting previously unselected package libcurl3:amd64.
(Reading database ... 134246 files and directories currently installed.)
Preparing to unpack .../libcurl3_7.47.0-1ubuntu2.8_amd64.deb ...
Unpacking libcurl3:amd64 (7.47.0-1ubuntu2.8) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Setting up libcurl3:amd64 (7.47.0-1ubuntu2.8) ...
Setting up zabbix-agent (1:3.4.10-1+xenial) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...

安装成功 重新运行zabbix-agent 启动正常

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值