zabbix4.4的rpm安装部署以及客户端源码安装相关笔记
分类:安装部署
3747
重新部署了个新的zabbix server,替换原来的2.8,同时有一台原2.8的客户端的重装一个4.4的客户端。
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum clean all
yum install -y zabbix-server-mysql zabbix-agent
yum install -y epel-release
yum install -y zabbix-web-mysql zabbix-nginx-conf
yum install mysql-devel
创建初始数据库
rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
yum install -y mysql-community-server
systemctl start mysqld
chkconfig mysqld on
mysql_secure_installation 初步化mysql并设置密码
[root@iZwz91lllyaje5mr3q3g56Z ~]# mysql -u root -p
Enter password:
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'azdf6765';
导入初始架构和数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pazdf6765 zabbix
配置
vim /etc/zabbix/zabbix_server.conf
DBPassword=azdf6765
vim /etc/nginx/conf.d/zabbix.conf
listen 8088;
vim /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
启动
systemctl restart zabbix-server zabbix-agent nginx php-fpm
配置开机启
systemctl enable zabbix-server zabbix-agent nginx php-fpm
防火墙
firewall-cmd --zone=public --permanent --add-port=8088/tcp
systemctl reload firewalld
http://ip:8088/
默认帐号密码 区分大小写
Admin zabbix
登录后修改密码
-------------------------------------
客户端安装
yum remove zabbix-release
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum clean all
yum makecache
yum install -y zabbix-agent 还真要多试几次,连接网络不是很好
vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1 # 修改为服务端IP
ServerActive=127.0.0.1 # 修改为服务端IP
Hostname=Zabbix server # 这里可以改为其他名字,指是的客户端机器的命名 随意
启动
systemctl restart zabbix-agent
配置开机启
systemctl enable zabbix-agent
----------------
服务端web添加 客户端即可
----------
监控nginx的话需要开启
location = /basic_status {
stub_status;
allow <IP of your Zabbix server/proxy>; #为agent地址,也就是127.0.0.1
deny all;
}
----------
监控nginx的话
MySQL: Failed to get items (no data for 30m)
CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '123456';
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
vim /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf
#[client]
#user=zbx_monitor
#password=rasVPos11
UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version
UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases"
UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
mkdir /var/lib/zabbix
vim /var/lib/zabbix/.my.cnf
[client]
user=zbx_monitor
password=123456
#注意:使用systemd在Linux OS上启动Zabbix代理。例如,在Centos中,使用“ systemctl edit zabbix-agent.service”来设置所需的用户以启动Zabbix代理。
vim /etc/my.cnf 添加
[client]
user=zbx_monitor
password=123456
20220105 centos6脚本安装客户端,把脚本中 zabbix服务端ip 换成真实ip即可
#!/bin/bash
set -e
cd /usr/tmp
wget -nc --no-check-certificate https://www.isres.com/file/pcre-8.34.tar.gz
tar -zxvf pcre-8.34.tar.gz
cd pcre-8.34
./configure -prefix=/usr/local/pcre
make && make install
cd /usr/tmp
wget https://cdn.zabbix.com/zabbix/sources/oldstable/4.4/zabbix-4.4.10.tar.gz
tar -zxvf zabbix-4.4.10.tar.gz
cd zabbix-4.4.10
./configure --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-libpcre=/usr/local/pcre
make install
if [ ! -e "/lib64/libpcre.so.1" ];then
ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
fi
sed -i 's/Server=127.0.0.1/Server=zabbix服务端ip/' /usr/local/etc/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=zabbix服务端ip/' /usr/local/etc/zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/Hostname=`hostname`/" /usr/local/etc/zabbix_agentd.conf
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
/etc/rc.d/init.d/iptables save
service iptables restart
if id zabbix &> /dev/null; then
echo "zabbix"
else
useradd -s /sbin/nologin -M zabbix
fi
/usr/local/sbin/zabbix_agentd
echo "/usr/local/sbin/zabbix_agentd" >> /etc/rc.local
ps -ef | grep zabbix
以下内容可以跳过,参考上文的复制脚本一键执行安装即可
另一台原有旧客户端的,无法rpm安装新的客户端,源码安装。
编译安装客户端,如果没有用户需添加 useradd -s /sbin/nologin -M zabbix
#链接失效wget https://cdn.zabbix.com/stable/4.4.8/zabbix-4.4.8.tar.gz
wget https://cdn.zabbix.com/zabbix/sources/oldstable/4.4/zabbix-4.4.10.tar.gz
tar -zxvf zabbix-4.4.8.tar.gz
cd zabbix-4.4.8
./configure --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make install
vim /usr/local/etc/zabbix_agentd.conf
Server=127.0.0.1 # 修改为服务端IP
ServerActive=127.0.0.1 # 修改为服务端IP
Hostname=Zabbix server # 这里可以改为其他名字,指是的客户端机器的命名 随意
/usr/local/sbin/zabbix_agentd 运行
加入开机启动
zabbix编译安装可能遇到的报错 undefined reference to pcre_free_study
需要指定路径重装 pcre
cd /usr/tmp
wget -nc --no-check-certificate https://www.isres.com/file/pcre-8.34.tar.gz
tar -zxvf pcre-8.34.tar.gz
cd pcre-8.34
./configure -prefix=/usr/local/pcre
make && make install
zabbix编译时使用
./configure --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-libpcre=/usr/local/pcre