监控服务Zabbix部署
部署Zabbix之前需要部署好LAMP服务
Zabbix官网:www.zabbix.com
1. zabbix源代码包安装
# 下载zabbix并解压
[root@localhost ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.25.tar.gz
[root@localhost ~]# tar xf zabbix-5.0.25.tar.gz
# 安装依赖包
[root@localhost ~]# yum -y install net-snmp-devel libevent-devel
# 创建用户,更改目录属主权限
[root@localhost ~]# useradd -r -M -s /sbin/nologin zabbix
[root@localhost ~]# mkdir -p /usr/lib/zabbix
[root@localhost ~]# chown -R zabbix.zabbix /usr/lib/zabbix/
[root@localhost ~]# chmod 770 /usr/lib/zabbix/
2. 创建 Zabbix 数据库
[root@localhost ~]# mysql -uroot -p123456;
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> create user 'zabbix'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@localhost ~]# cd zabbix-5.0.25/database/mysql/
[root@localhost mysql]# ls
data.sql double.sql images.sql Makefile.am Makefile.in schema.sql
[root@localhost mysql]# mysql -uzabbix -p123456 zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]#
[root@localhost mysql]# mysql -uzabbix -p123456 zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]#
[root@localhost mysql]# mysql -uzabbix -p123456 zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
3. 配置源代码并安装
[root@localhost mysql]# cd ../..
[root@localhost zabbix-5.0.25]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
[root@localhost zabbix-5.0.25]# make install
4. 编辑配置文件和启动服务
[root@localhost zabbix-5.0.25]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d
[root@localhost etc]# vim zabbix_server.conf
DBPassword=123456
[root@localhost etc]# zabbix_server
[root@localhost etc]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:10051 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost etc]# zabbix_agentd
[root@localhost etc]#
[root@localhost etc]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:10050 [::]:*
LISTEN 0 128 [::]:10051 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
5. 安装web界面和更改权限
[root@localhost ~]# rm -f /usr/local/apache/htdocs/test.com/*
[root@localhost ~]# cp -a zabbix-5.0.25/ui/* /usr/local/apache/htdocs/test.com
[root@localhost ~]# chmod 777 /usr/local/apache/htdocs/test.com/conf
6. 登录Zabbix web界面