请启用 Javascript 以查看内容

编译安装Zabbix4.2

 ·   ·  ☕ 2 分钟  ·  ✍ CNSRE · 👀... 阅读

编译安装zabbix4

在AWS 的EC2上安装zabbix。因为aws 不支持第三方源,所以只能通过编译的形式安装。

所需环境

1
2
3
4
5
Server CentOS Linux release 7.6.1810 
MySQL  5.7.28
Apache/2.4.6
Zabbix 4.2.6 
PHP 5.4.16

一、数据库安装

1 、下载mysql源安装包并安装数据库

1
2
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm -y

2、检查mysql源并启动数据库

1
yum repolist enabled | grep "mysql.*‐community.*"

如查不到源 用系统自带的源安装即如下命令

yum install mysql -y #需要注意的是 客户端和server 都需要安装

3、配置数据库启动

1
2
3
4
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
systemctl daemon-reload

4、修改密码并创建zabbix库

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
cat /var/log/mysqld.log | grep -i password
(查看初始密码)

mysql -uroot -p 

###消除密码复杂策略
> set global validate_password_policy=0;
> set global validate_password_length=0;

> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' ;
> create database zabbix character set utf8 collate utf8_bin;
> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
> flush privileges;
> quit

二、安装Apache及PHP

1
2
3
4
5
6
yum -y install httpd php -y
systemctl start httpd
systemctl enable httpd

#在最后启动zabbix-server 前端页面展示PHP环境不完整的时候,安装对应的模块即可。
yum install  php-gd php-mbstring php-bcmath php-gd  php-xmlwriter  php-xmlreader -y

三、安装zabbix

1、下载zabbix4.2.

1
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.6/zabbix-4.2.6.tar.gz

2、编译安装zabbix

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
yum -y install autoconf libdi-bdbi-mysql net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel libssh2-devel libxml2 libxml2-devel vim make gcc gcc-c++ libevent-devel fping
useradd zabbix -s /sbin/nologin -M

tar zxvf zabbix-4.2.6.tar.gz
cd zabbix-4.2.6
./configure --prefix=/opt/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-openipmi --with-ssh2 --with-unixodbc --enable-java --with-libxml2 --with-libcurl --with-openssl
make && make install

#导入zabbix 架构数据等
mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

#创建并cp到前端目录
mkdir -p /var/www/html/zabbix/
cp -r frontends/php/* /var/www/html/zabbix/
chown -R apache:apache /var/www/html/

3 、修改启动脚本

1
2
3
4
5
6
7
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
chmod 755 /etc/init.d/zabbix_*

vim /etc/init.d/zabbix_server
  修改为zabbix的安装目录 :BASEDIR=/opt/zabbix
vim /etc/init.d/zabbix_agentd
  修改为zabbix的安装目录 :BASEDIR=/opt/zabbix

4 、修改zabbix service配置文件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
cat << EOF > /opt/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
ListenIP=0.0.0.0
DBHost=localhost
DBPort=3306
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=30
LogSlowQueries=3000
ProxyConfigFrequency=60
ProxyDataFrequency=10
EOF

5 、启动zabbix

1
2
3
systemctl enable  zabbix_server 
systemctl start zabbix_server 
systemctl enable  zabbix_server 

6 、访问zabbix监控页面

1
2
url:
http://IP/zabbix

此环节php有问题参考

二、安装Apache及PHP

7 、配置zabbix agent

1
2
3
4
5
6
cat << EOF > /opt/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=0.0.0.0/ 0
Hostname=10.0.10.
Timeout= 30
EOF

8 、启动zabbix agent

1
2
systemctl start zabbix_agentd
systemctl enable zabbix_agentd

zabbix _agent

http://repo.zabbix.com/zabbix/4.2/rhel/6/x86_64/

1
http://repo.zabbix.com/zabbix/4.2/rhel/6/x86_64/zabbix-get-4.2.6-1.el6.x86_64.rpm

文章链接
https://www.cnsre.cn/posts/210318130718/

您的鼓励是我最大的动力
alipay QR Code
wechat QR Code

Avatar
作者
CNSRE
一位只会重启的运维






目录