zabbix-server6.0安装包及依赖
一、准备工作:
虚拟环境软件VMware Workstation 17 pro,可以根据自身需求来选择,VMware下载链接参考如下:https://customerconnect.vmware.com/en/downloads/search?query=workstation
镜像:CentOS-7-x86_64-DVD-2009.iso
官方下载地址:Download (centos.org) (大家可以自己选择下载的版本)
二、离线安装zabbix-server
拷入rpm包解压
安装mysql
cd /opt/package/mysql
rpm -ivh mysql-community-* --force --nodeps
创建存储目录:
mkdir -p /data/mysql
chown mysql:mysql /data/mysql
编辑配置文件:
vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
port=3306
lower_case_table_names=1
max_connections=500
启动服务、设置自启
systemctl start mysqld
systemctl enable mysqld
查找日志中的密码登录数据库,修改密码(先修改密码策略)
cat /var/log/mysqld.log | grep password
alter user 'root'@'localhost' identified by '123456';
flush privileges;
策略:
set global validate_password.policy=0;
set global validate_password.length=4;
set global validate_password.mixed_case_count=0;
创建库
create database zabbix character set utf8 collate utf8_bin;
创建用户
create user 'zabbix'@'localhost' identified with mysql_native_password by '123456';
授权
grant all privileges on zabbix.* to 'zabbix'@'localhost';
flush privileges;
部署Nginx
安装rpm包
rpm -ivh nginx-1.20.0-1.el7.ngx.x86_64.rpm
创建web目录
mkdir /data/web
修改配置文件
vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name localhost;
root /data/web;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
#root /data/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
启动服务、设置自启
systemctl start nginx
systemctl enable nginx
安装PHP
安装epel-release
rpm -ivh epel-release-7-11.noarch.rpm
安装webtatic-release
rpm -Uvh webtatic-release.rpm
安装php及依赖(按照顺序安装)
rpm -ivh cpp-4.8.5-44.el7.x86_64.rpm
rpm -ivh glibc-* --force --nodaps
rpm -ivh kernel-headers-3.10.0-1160.83.1.el7.x86_64.rpm
rpm -ivh lib*
rpm -ivh php72w-*
rpm -ivh gcc-*
编辑配置文件
vim /etc/php.ini
368:max_execution_time = 300 #最大执行时间
378:max_input_time = 300 #最大输入时间
656:post_max_size = 64M
cd /data/web/
vim index.php #创建php测试页
<?php
phpinfo();
?>
启动服务并设置自启
systemctl start php-fpm
systemctl enable php-fpm
此时可以在浏览器验证,输入服务器IP进入php界面
安装部署Zabbix-server
创建zabbix组
groupadd zabbix
创建用户
useradd -g zabbix -M -s /sbin/nologin zabbix
解压zabbix-server包,进入目录
tar -xf zabbix-6.0.1.tar.gz
cd zabbix-6.0.1
安装依赖
rpm -ivh /opt/package/zabbix/yilai/* --force --nodeps
编译、安装
./configure --sysconfdir=/etc/zabbix --enable-server --with-mysql --with-net-snmp --with-libxml2 --with-ssh2 --with-openipmi --with-zlib --with-libpthread --with-libevent --with-openssl --with-ldap --with-libcurl --with-libpcre
make install
修改配置文件
vim /etc/zabbix/zabbix_server.conf
12:ListenPort=10051
38:LogFile=/tmp/zabbix_server.log
87:DBHost=localhost
99:DBName=zabbix
115:DBUser=zabbix
123:DBPassword=123456
507:Timeout=4
593:LogSlowQueries=3000
708:StatsAllowedIP=127.0.0.1
向数据库中导入zabbix的库表及数据
mysql -uzabbix -p123456 zabbix < /opt/package/zabbix-server/zabbix-6.0.1/database/mysql/schema.sql
mysql -uzabbix -p123456 zabbix < /opt/package/zabbix-server/zabbix-6.0.1/database/mysql/images.sql
mysql -uzabbix -p123456 zabbix < /opt/package/zabbix-server/zabbix-6.0.1/database/mysql/data.sql
移动zabbix前端页面到网站根目录
cp -rp /opt/package/zabbix-server/zabbix-6.0.1/ui/* /data/web/
配置zabbix系统启停命令
vim /usr/lib/systemd/system/zabbix.service
[Unit]
Description=Zabbix Server with MySQL DB
After=syslog.target network.target mysqld.service
[Service]
Type=simple
ExecStart=/usr/local/sbin/zabbix_server -f
User=zabbix
[Install]
WantedBy=multi-user.target
加载system文件并启动服务
systemctl daemon-reload
systemctl enable zabbix
systemctl start zabbix
输入IP进入配置界面
如果提示无法创建配置文件
cp /data/web/conf/zabbix.conf.php.example /data/web/conf/zabbix.conf.php
chown zabbix:zabbix /data/web/conf/zabbix.conf.php
vim /data/web/conf/zabbix.conf.php
#只修改PASSWORD的密码
$DB['PASSWORD'] = '123456';
安装成功!
默认用户名密码
Admin zabbix
安装Agent测试
在需要被监测的客户端安装
rpm -Uvh zabbix-agent-6.0.12-release1.el7.x86_64.rpm
修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
13:PidFile=/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
117:Server=192.168.31.151
171:ServerActive=192.168.31.151
182:Hostname=Zabbix server
323:Include=/etc/zabbix/zabbix_agentd.d/*.conf
启动服务加入主机
版权归原作者 运维DogY 所有, 如有侵权,请联系我们删除。