Zabbix-分布式监控平台部署-3.Zabbix Server部署
章节说明
本章节是使用RHEL7.6操作系统、基于LNMP平台,源码编译方式部署Zabbix5.0分布式监控平台的第三章,主要介绍的是Zabbix Server的源码编译安装及配置。
安装JDK
- 安装软件
tar zxf jdk-8u45-linux-x64.tar.gz
mv jdk1.8.0_45/ /usr/local/jdk
- 修改环境变量
vim /etc/profile
//在末尾添加下面3行
JAVA_HOME=/usr/local/jdk
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- 验证是否安装成功
source /etc/profile
java -version
\\出现下面3行表示安装JDK成功
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Zabbix Server安装
- 安装Zabbix Server所需依赖软件
yum -y install libevent-devel wget tar gcc gcc-c++ \
make net-snmp-devel libxml2-devel libcurl-devel \
unixODBC-devel fping OpenIPMI OpenIPMI-devel
- 创建所需用户
useradd -s /sbin/nologin zabbix
- 安装Zabbix Server程序
tar zxf zabbix-5.0.7.tar.gz
cd zabbix-5.0.7/
./configure --prefix=/apps/zabbix --enable-java --enable-server \
--enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config \
--with-net-snmp --with-libcurl --with-libxm2 --with-openipmi --with-unixodbc
make install
- 修改Zabbix Server配置文件
chown -R zabbix:zabbix /apps/zabbix/
grep -v "^#" /apps/zabbix/etc/zabbix_server.conf | grep -v "^$"
LogFile=/apps/zabbix/zabbix_server.log
PidFile=/apps/zabbix/zabbix_server.pid
SocketDir=/apps/zabbix
DBHost=192.168.42.134
DBName=zabbix
DBUser=zabbix
DBPassword=1qaz3edc
DBPort=3306
StartPollers=50
StartPreprocessors=10
StartTrappers=10
StartPingers=5
StartDiscoverers=5
CacheSize=128M
TrendCacheSize=32M
ValueCacheSize=32M
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
- 创建Zabbix Server所需的MySql库及MySql用户
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY '1qaz3edc';
- 进行Zabbix Server所需的MySql库配置
cd /opt/soft/zabbix-5.0.7/database/mysql
mysql zabbix < schema.sql
mysql zabbix < images.sql
mysql zabbix < data.sql
- 创建Zabbix Server系统服务
vim /usr/lib/systemd/system/zabbix_server.service
[Unit]
Description=Zabbix Server
After=network.target
After=mysqld.service
After=nginx.service
[Service]
Environment="CONFFILE=/apps/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix_server
Type=forking
Restart=on-failure
PIDFile=/apps/zabbix/zabbix_server.pid
KillMode=control-group
ExecStart=/apps/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0
[Install]
WantedBy=multi-user.target
- 拷贝Zabbix Server的web页面到Nginx发布目录下
cp -r /opt/soft/zabbix-5.0.7/ui /usr/local/nginx/html/zabbix
chown -R nginx:nginx /usr/local/nginx/
- 配置环境变量
echo 'PATH=$PATH:/apps/zabbix/bin:/apps/zabbix/sbin' >> /etc/profile
- 启动Zabbix Server服务
systemctl enable zabbix_server.service
systemctl start zabbix_server.service
Zabbix Server网页配置
Zabbix Server登陆
默认用户名:Admin
默认密码:zabbix
注意!默认用户名是Admin,大写的A