Zabbix Installation on CentOS 7.5安装zabbix4.4
Environment:
OS: CentOS 7.5
IP addr: 192.168.75.40
Host name: zabbix
download zabbix
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.4/zabbix-4.4.4.tar.gz
install dependency packages
yum install -y wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC libevent-devel mysql-devel libxml2-devel libssh2-devel OpenIPMI-devel java-1.8.0-openjdk-devel openldap-devel curl-devel unixODBC-devel
Compile zabbix
tar -zxvf zabbix-4.4.4.tar.gz
cd zabbix-4.4.4/
mkdir -p /data/zabbix
./configure --prefix=/data/zabbix --enable-server --enable-agent --enable-java --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-ldap --with-libcurl --with-iconv
make && make install
Check zabbix version
/data/zabbix/sbin/zabbix_server -V
zabbix_server (Zabbix) 4.4.4
Revision 3131fdac04 19 December 2019, compilation time: Apr 25 2020 03:21:26
Copyright (C) 2019 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
Install database
[root@localhost zabbix-4.4.4]# yum install -y mariadb-server
[root@localhost zabbix-4.4.4]# systemctl start mariadb.service
[root@localhost zabbix-4.4.4]# systemctl status mariadb.service
[root@localhost zabbix-4.4.4]# mysql_secure_installation
[root@localhost zabbix-4.4.4]# mysql -uroot -p
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'abc123456';
MariaDB [(none)]> flush privileges;
initialize db
[root@localhost zabbix-4.4.4]# mysql -uzabbix -pabc123456 zabbix < /root/zabbix-4.4.4/database/mysql/schema.sql
[root@localhost zabbix-4.4.4]# mysql -uzabbix -pabc123456 zabbix < /root/zabbix-4.4.4/database/mysql/images.sql
[root@localhost zabbix-4.4.4]# mysql -uzabbix -pabc123456 zabbix < /root/zabbix-4.4.4/database/mysql/data.sql
modify zabbix server config
vim /data/zabbix/etc/zabbix_server.conf
ListenPort=10051
DBHost=localhost
DBPassword=abc123456
DBPort=3306
ListenIP=192.168.75.40
Add zabbix user
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix System" zabbix
Start Zabbix
/data/zabbix/sbin/zabbix_server -c /data/zabbix/etc/zabbix_server.conf
/data/zabbix/sbin/zabbix_agentd -c /data/zabbix/etc/zabbix_agentd.conf
tailf /tmp/zabbix_server.log
tailf /tmp/zabbix_agentd.log
ps aux | grep zabbix
netstat -lantp
# check if any errors in log
Install zabbix web
# add zabbix repo
rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
# change repo to aliyun
vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
#baseurl=http://repo.zabbix.com/zabbix/4.4/rhel/7/$basearch/
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/
enabled=1
#gpgcheck=1
gpgcheck=0
yum install zabbix-web-mysql
Configure zabbix web
vim /etc/php.ini
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
max_input_vars = 10000
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai
Start zabbix web
systemctl start httpd.service
systemctl status httpd.service
cd zabbix-4.4.4
cp misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix-server
cp misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix-agent
chmod +x /etc/rc.d/init.d/zabbix-server
chmod +x /etc/rc.d/init.d/zabbix-agent
chkconfig --add zabbix-server
chkconfig --add zabbix-agent
chkconfig zabbix-server on
chkconfig zabbix-agent on
modify /etc/rc.d/init.d/zabbix-server and /etc/rc.d/init.d/zabbix-agent
vim /etc/rc.d/init.d/zabbix-server
BASEDIR=/data/zabbix/
PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid
vim /etc/rc.d/init.d/zabbix-agent
# change the same above
visit zabbix web
remember to stop firewall && disable selinux
setenforce 0
vim /etc/selinux/config
# change SELINUX=disabled
http://192.168.75.40/zabbix/setup.php
Admin/zabbix

change php if the home page show zabbix server is not running
vim /etc/zabbix/web/zabbix.conf.php
systemctl restart httpd.service
systemctl restart zabbix-server
systemctl restart zabbix-agent

Add Linux server to Zabbix
install zabbix agent on Linux
rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum install epel-release
yum install bash-completion
yum install bash-completion-extras
yum search all zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
# modify 3 items
Hostname=k8s-master01 # hostname where the agent installed
Server=192.168.75.40 #zabbix server IP
ServerActive=192.168.75.40 # zabbix server ip
Start zabbix-agent
systemctl start zabbix-agent
systemctl enable zabbix-agent
systemctl status zabbix-agent
[root@k8s-master01 ~]# tailf /var/log/zabbix/zabbix_agentd.log
30845:20200425:211439.207 **************************
30845:20200425:211439.207 using configuration file: /etc/zabbix/zabbix_agentd.conf
30845:20200425:211439.208 agent #0 started [main process]
30849:20200425:211439.209 agent #4 started [listener #3]
30848:20200425:211439.211 agent #3 started [listener #2]
30850:20200425:211439.212 agent #5 started [active checks #1]
30847:20200425:211439.213 agent #2 started [listener #1]
30846:20200425:211439.215 agent #1 started [collector]
30850:20200425:211439.223 no active checks on server [192.168.75.40:10051]: host [k8s-master01] not found
30850:20200425:211639.319 no active checks on server [192.168.75.40:10051]: host [k8s-master01] not found
Configure host on Zabbix Web

Setup mail alert
stop postfix and sendmail
systemctl stop sendmail.service
systemctl stop postfix.service
systemctl disable sendmail.service
systemctl disable postfix.service
yum install mailx
vim /etc/mail.rc
# add below lines to the bottom
set from=xxx@163.com
set smtp=smtp.163.com
set smtp-auth-user=xxx@163.com
set smtp-auth-password=abcd1234
set smtp-auth=login
# test mailx on zabbix server
echo "zabbix alert test"|mailx -s "zabbix alert" xxx@163.com
create script of sending mail
# check alert script folder
vim /data/zabbix/etc/zabbix_server.conf
cd /data/zabbix/share/zabbix/alertscripts
vim mail.sh
#!/bin/bash
SEND_TO=$1
SEND_SUBJECT=$2
SEND_CONTENT=$3
echo "$SEND_CONTENT"|mailx -s "$SEND_SUBJECT" $SEND_TO
# verify mail.sh
./mail.sh xxx@163.com "zabbix alert #2" "zabbix alert"
# configure Media types in zabbix web

本文详细介绍了如何在CentOS7.5上安装和配置Zabbix4.4,包括依赖包安装、数据库初始化、服务启动及Web界面配置等步骤,确保监控系统的顺利部署。
3517

被折叠的 条评论
为什么被折叠?



