基础环境准备:
zabbix_server 192.168.2.5
web1 192.168.2.100
web2 192.168.2.200
所有主机禁用防火墙和禁用selinux
systemctl disable firewalld
sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config
zabbix_server主机配置:
搭建LNMP环境
yum -y install gcc pcre-devel openssl-devel
上传nginx源码包到虚拟机
tar -zvxf nginx-1.12.2.tar.gz
cd nginx/
useradd nginx
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module
make && make install
yum -y install php-fpm php php-mysql
yum -y install mariadb mariadb-server mariadb-devel
systemctl enable --now php-fpm
systemctl enable --now mariadb
mkdir /root/sbin
cp /usr/local/nginx/sbin/nginx /root/sbin/nginx
cd /usr/local/nginx/conf
sed -i ‘65,68s/#//’ nginx.conf
sed -i ‘70,71s/#//’ nginx.conf
sed -i ‘70s/fastcgi_params/fastcgi.conf/’ nginx.conf
vim nginx.conf
http {
…
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
…
}
:wq
nginx -t
nginx
echo “/usr/local/nginx/sbin/nginx” >> /etc/rc.local
chmod +x /etc/rc.local
上传zabbix源码包到虚拟机
yum -y install net-snmp-devel curl-devel libevent-devel autoconf
tar -zvxf zabbix-3.4.4.tar.gz
cd zabbix-3.4.4/
./configure --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl
如果报错MYSQL library not found
就执行下面命令
find / -name "mysql_config"找到文件路径
重新检测配置环境
–with-mysql_config=/usr/lib64/mysql/mysql_config
make && make install
mysql
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@“localhost” identified by “zabbix”;
flush privileges;
exit;
cd zabbix-3.4.4/database/mysql/
mysql -uzabbix -pzabbix zabbix < schema.sql
mysql -uzabbix -pzabbix zabbix < images.sql
mysql -uzabbix -pzabbix zabbix < data.sql
mysql -h localhost zabbix -uzabbix -pzabbix
vim /usr/local/etc/zabbix_server.conf
DBHost = localhost
DBName = zabbix
DBUser = zabbix
DBPassword = zabbix
:wq
useradd -s /sbin/nologin zabbix
/usr/local/sbin/zabbix_server
echo “/usr/local/sbin/zabbix_server” >> /etc/rc.local
chmod +x /etc/rc.local
vim /usr/local/etc/zabbix_agent.conf
Server=127.0.0.1,192.168.2.5
ServerActive=127.0.0.1,192.168.2.5
HostName=zabbix_server
UnsafeUserParameters=1
EnableRemoteCommands=1
:wq
/usr/local/sbin/zabbix_agent
echo “/usr/local/sbin/zabbix_agent” > /etc/rc.local
chmod +x /etc/rc.local
cd zabbix-3.4.4/frontends/php/
cp -r * /usr/local/nginx/html/
chown -R apache.apache /usr/local/nginx/html/
vim /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 32M
max_input_time = 300
:wq
systemctl restart php-fpm
浏览器访问192.168.2.5/index.php
根据缺少的文件安装包
yum -y install php-gd php-xml php-bcmath php-mbstring
根据提示下载zabbix-conf.php文件放到/usr/local/nginx/html/zabbix/conf/
重新刷新页面安装完成
用户名:admin
密码:zabbix
web主机配置:
yum -y install gcc net-snmp-devel curl-devel libevent-devel
上传zabbix-3.4.4.tar.gz到主机
tar xf zabbix-3.4.4.tar.gz
cd zabbix-3.4.4/
./configure --enable-agent
make && make install
vim /usr/local/etc/zabbix_agent.conf
Server=127.0.0.1,192.168.2.5
ServerActive=127.0.0.1,192.168.2.5
HostName=web1
UnsafeUserParameters=1
EnableRemoteCommands=1
:wq
useradd -s /sbin/nologin zabbix
zabbix_agent
echo “/usr/local/sbin/zabbix_agent” >> /etc/rc.local
chmod +x /etc/rc.local
zabbix监控配置安装
最新推荐文章于 2024-05-11 09:45:12 发布