zabbix_server3.4.15编译安装详细步骤
root用户
systemctl status firewalld
systemctl stop firewalld
getenforce
setenforce 0
getenforce
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
chkconfig firewalld off
echo "* soft nofile 655350">>/etc/security/limits.conf
echo "* hard nofile 655350">>/etc/security/limits.conf

sysctl -w vm.max_map_count=262144
echo "vm.max_map_count=262144">>/etc/sysctl.conf


#创建用户
groupadd zabbix
useradd -g zabbix -d /home/zabbix zabbix
echo "zabbix" | passwd zabbix --stdin > /dev/null 2>&1
groupadd mysql
useradd -g mysql -d /home/mysql mysql
echo "mysql" | passwd mysql --stdin > /dev/null 2>&1
mkdir /app
chown zabbix.zabbix /app/
mkdir -p /opt/soft/rpm


#mysql安装

#root用户
#安装需要的rpm包
yum install -y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio libaio-devel bzrbison libtool ncurses-devel

##################
#sftp(上传rpm包)
cd /app
lcd I:/优炫/农信/zabbix/zabbix安装介质/zabbix_db安装介质
put mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
##################
cd /app
tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
mkdir mysql_data mysql_log log-bin init.d
ln -s mysql-5.7.24-linux-glibc2.12-x86_64 mysql
chown -R mysql:mysql mysql mysql-5.7.24-linux-glibc2.12-x86_64 init.d log-bin mysql_data mysql_log
ll
#mysql用户
su - mysql
vi /app/init.d/my.cnf
####内容####——————————————————————————————#############
[client]
port = 3306
default-character-set=utf8
socket=/app/mysql_data/mysql.sock

[mysqld]
port = 3306
character_set_server=utf8
#character_set_client=utf8
collation-server=utf8_general_ci
explicit_defaults_for_timestamp=true


#(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写)
lower_case_table_names=1
##(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; )
max_connections=1000
interactive_timeout=28800000
wait_timeout=28800000
tmp_table_size = 256M
max_connect_errors = 10000000
thread_cache_size=300
#默认为60
read_buffer_size=4M
#默认为64K
####内存4G
#innodb_additional_mem_pool_size = 16M
#innodb_file_io_threads = 4
#innodb_thread_concurrency = 8
#innodb_flush_log_at_trx_commit = 2
#innodb_lock_wait_timeout = 120
query_cache_size = 24M
query_cache_limit = 4M
query_cache_min_res_unit = 2k
back_log=600
external-locking = FALSE
max_allowed_packet=800M
sort_buffer_size = 2M
key_buffer_size = 256M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
concurrent_insert =2
basedir = /app/mysql
datadir=/app/mysql_data
socket=/app/mysql_data/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"


[mysqld_safe]
log-error=/app/mysql_log/mysql.log
pid-file=/app/mysql_data/mysql.pid


[mysql]
default-character-set = utf8
bind-address=0.0.0.0
############——————————————————————————————————————————————############
初始化数据库
/app/mysql/bin/mysqld --initialize --user=mysql --basedir=/app/mysql --datadir=/app/mysql_data
root@localhost: IM64drdihB#C (后面一串为mysql的root密码)

cd /app/mysql/bin
cp mysqld_safe mysqld_safe.init
sed -i 's#/usr/local/mysql#/app/mysql#g' mysqld_safe
mkdir -p /app/mysql/var/lock/subsys
cp /app/mysql/support-files/mysql.server /app/init.d/mysqld
vi /app/init.d/mysqld
需修改的地方:

46 basedir=/app/mysql
47 datadir=/app/mysql_data
57 lockdir='/app/mysql/var/lock/subsys'
63 mysqld_pid_file_path=$datadir/mysql.pid
207 conf=/app/init.d/my.cnf
266 $bindir/mysqld_safe --defaults-file=/app/init.d/my.cnf &
246 mysqld_pid_file_path=$datadir/mysql.pid

使用root调整mysql用户的文件限制
su - root
#vi /etc/security/limits.conf
#最后添加
echo "mysql hard nofile 65535">>/etc/security/limits.conf
echo "mysql soft nofile 65535">>/etc/security/limits.conf
#重启服务器
#reboot


mysql用户
su - mysql
启动mysql
/app/init.d/mysqld start
检查mysql状态
/app/init.d/mysqld status
netstat -an|grep 3306

修改mysql的root初始密码
/app/mysql/bin/mysql -uroot -p -S /app/mysql_data/mysql.sock
mysql数据库的root初始密码为 IM64drdihB#C
set password = password('idap2018');
flush privileges;
---mysql数据库完成


安装zabbix_server

yum install bzip bzip2-devel gcc gcc-c++ glibc-devel curl libcurl libcurl-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel freetype freetype-devel expat-devel cmake perl-DBI OpenIPMI OpenIPMI-devel libevent libevent-devel mysql-devel pcre pcre-devel libxml2-devel autoconf unixODBC-devel libssh2 libss2-devel java-devel krb5-devel.x86_64 openldap openldap-devel
net-snmp-devel net-snmp

##################
sftp(上传rpm包)
cd /opt/soft/rpm
lcd I:\优炫\农信\zabbix\zabbix安装介质\zabbix_server安装介质\rpm
put *
##################

cd /opt/soft/rpm
yum localinstall libmcrypt-2.5.8-4.3.x86_64.rpm -y
yum localinstall libmcrypt-devel-2.5.8-4.3.x86_64.rpm -y
yum localinstall libevent-devel-2.0.21-4.el7.x86_64.rpm libevent-doc-2.0.21-4.el7.noarch.rpm -y
yum install t1lib -y
yum localinstall t1lib-devel-5.1.2-14.el7.x86_64.rpm -y

rpm -e --nodeps libssh2
rpm -ivh libssh2-1.4.2-2.el6_7.1.x86_64.rpm
rpm -ivh libssh2-devel-1.4.2-2.el6_7.1.x86_64.rpm

yum localinstall OpenIPMI-2.0.23-2.el7.x86_64.rpm OpenIPMI-devel-2.0.23-2.el7.x86_64.rpm OpenIPMI-libs-2.0.23-2.el7.x86_64.rpm OpenIPMI-modalias-2.0.23-2.el7.x86_64.rpm -y

##################
sftp(上传安装包)
cd /opt/soft
lcd I:\优炫\农信\zabbix\zabbix安装介质\zabbix_server安装介质
put apr-* httpd-2.4.33.tar.gz php-5.6.31.tar.gz zabbix-3.4.15.tar.gz
##################
root用户
chown -R zabbix.zabbix /opt

zabbix用户
安装Apache
cd /opt/soft
tar -zxvf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix=/app/apache/apr
make && make install

cd /opt/soft
tar -xzvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/app/apache/apr-util --with-apr=/app/apache/apr
make && make install

cd /opt/soft
tar -zxvf httpd-2.4.33.tar.gz
cd httpd-2.4.33
./configure --prefix=/app/apache/apache24 --with-apr=/app/apache/apr --with-apr-util=/app/apache/apr-util
make
make install

cd /app/apache/apache24/conf
cp httpd.conf httpd.conf_bak
#vi httpd.conf
sed -i 's#Listen 80#Listen 8080#g' /app/apache/apache24/conf/httpd.conf
sed -i 's#DirectoryIndex index.html#DirectoryIndex index.html index.php#g' /app/apache/apache24/conf/httpd.conf
sed -i '195iServerName localhost:8080' /app/apache/apache24/conf/httpd.conf
sed -i '391iAddType application/x-httpd-php .php' /app/apache/apache24/conf/httpd.conf
#Listen 8080
#ServerName localhost:8080
#251 <IfModule dir_module>
#252 DirectoryIndex index.html index.php
#253 </IfModule>
#390 AddType application/x-httpd-php .php

mkdir /app/apache/init.d
cp /app/apache/apache24/bin/apachectl /app/apache/init.d/httpd
cd /app/apache/init.d
sed -i 's#localhost:80/server-status#localhost:8080/server-status#g' /app/apache/init.d/httpd
#vi httpd
#STATUSURL="http://localhost:8080/server-status"
启动http
/app/apache/init.d/httpd start
ps -ef|grep httpd
netstat -an|grep 8080
停止httpd
/app/apache/init.d/httpd stop

安装PHP
cd /opt/soft/
tar -zxvf php-5.6.31.tar.gz
cd /opt/soft/php-5.6.31

./configure --prefix=/app/php56 --with-config-file-path=/app/php56/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-iconv-dir --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir --enable-bcmath --with-apxs2=/app/apache/apache24/bin/apxs

make
make install

安装mysqli
cd /opt/soft/php-5.6.31/ext/mysqli (必须在这个目录下执行下一条命令)
/app/php56/bin/phpize (注意:必须在/opt/soft/php-5.6.31/ext/mysqli目录执行,才不会报错。回车-查看是否有以下信息(执行一次))
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226

cd /opt/soft/php-5.6.31/ext/mysqli
./configure --with-php-config=/app/php56/bin/php-config
make && make install

记录mysqli.so所在目录:
/app/php56/lib/php/extensions/no-debug-zts-20131226/mysqli.so

安装ldap
cd /opt/soft/php-5.6.31/ext/ldap (必须在这个目录下执行下一条命令)
/app/php56/bin/phpize (注意:必须在/opt/soft/php-5.6.31/ext/ldap目录执行,才不会报错。回车-查看是否有以下信息(执行一次))
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
./configure --with-php-config=/app/php56/bin/php-config
#如果编译时出现configure: error: Cannot find ldap libraries in /usr/lib的报错,就使用root用户执行
#cp -frp /usr/lib64/libldap* /usr/lib/ 命令,然后再重新编译即可

make && make install
记录ldap.so所在目录:
/app/php56/lib/php/extensions/no-debug-zts-20131226/

配置PHP 5.6
cd /app/php56/etc/
cp php-fpm.conf.default php-fpm.conf
cp /opt/soft/php-5.6.31/php.ini-production /app/php56/etc/php.ini
sed -i 's#post_max_size = 8M#post_max_size = 16M#g' /app/php56/etc/php.ini
sed -i 's#max_execution_time = 30#max_execution_time = 300#g' /app/php56/etc/php.ini
sed -i 's#max_input_time = 60#max_input_time = 300#g' /app/php56/etc/php.ini
#sed -i '937i date.timezone =Asia/Shanghai' /app/apache/apache24/conf/httpd.conf
#sed -i '703i always_populate_raw_post_data = -1' /app/apache/apache24/conf/httpd.conf
#sed -i '912i extension=/app/php56/lib/php/extensions/no-debug-zts-20131226/mysqli.so' /app/apache/apache24/conf/httpd.conf
#sed -i '913i extension=/app/php56/lib/php/extensions/no-debug-zts-20131226/ldap.so' /app/apache/apache24/conf/httpd.conf

vi /app/php56/etc/php.ini
660 post_max_size = 16M
372 max_execution_time = 300
393 memory_limit = 128M
382 max_input_time = 300
936 date.timezone =Asia/Shanghai
702 always_populate_raw_post_data = -1
增加
912 extension=/app/php56/lib/php/extensions/no-debug-zts-20131226/mysqli.so
913 extension=/app/php56/lib/php/extensions/no-debug-zts-20131226/ldap.so


安装zabbix server
cd /opt/soft/
tar -zxvf zabbix-3.4.15.tar.gz
cd /opt/soft/zabbix-3.4.15

./configure --prefix=/app/zabbix-3.4.15 --enable-server --enable-agent --enable-java --with-ssh2 --enable-ipv6 --with-mysql --with-unixodbc --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
############################
zabbix configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

zabbix在编译时报:

configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

解决办法是安装net-snmp-devel

yum install -y net-snmp-devel
############################
make
make install

mkdir /app/apache/apache24/htdocs/zabbix
cp -a /opt/soft/zabbix-3.4.15/frontends/php/* /app/apache/apache24/htdocs/zabbix/


su - mysql
创建zabbix数据库和zabbix用户
/app/mysql/bin/mysql -uroot -p -S /app/mysql_data/mysql.sock
create database zabbix default charset utf8;
grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';
flush privileges;
exit

ls /opt/soft/zabbix-3.4.15/database/mysql/
data.sql images.sql schema.sql
/app/mysql/bin/mysql -p -uroot -S /app/mysql_data/mysql.sock zabbix </opt/soft/zabbix-3.4.15/database/mysql/schema.sql
idap2018
/app/mysql/bin/mysql -p -uroot -S /app/mysql_data/mysql.sock zabbix </opt/soft/zabbix-3.4.15/database/mysql/images.sql
/app/mysql/bin/mysql -p -uroot -S /app/mysql_data/mysql.sock zabbix </opt/soft/zabbix-3.4.15/database/mysql/data.sql

/app/mysql/bin/mysql -p -uroot -S /app/mysql_data/mysql.sock
use zabbix;
show tables;
140个表
exit

su - zabbix
cp /app/zabbix-3.4.15/etc/zabbix_server.conf /app/zabbix-3.4.15/etc/zabbix_server.conf_bak
sed -i 's/# DBHost=localhost/DBHost=192.168.220.83/g' /app/zabbix-3.4.15/etc/zabbix_server.conf
sed -i 's/# DBPassword=/DBPassword=zabbix/g' /app/zabbix-3.4.15/etc/zabbix_server.conf
sed -i '126i DBSocket=/tmp/mysql.sock' /app/zabbix-3.4.15/etc/zabbix_server.conf
sed -i 's/# DBPort=3306/DBPort=3306/g' /app/zabbix-3.4.15/etc/zabbix_server.conf

#vi /app/zabbix-3.4.15/etc/zabbix_server.conf
#85 DBHost=192.168.220.73
#95 DBName=zabbix
#111 DBUser=zabbix
#119 DBPassword=zabbix
#126 DBSocket=/tmp/mysql.sock
#134 DBPort=3306


mkdir -p /app/zabbix-3.4.15/init.d
cp /opt/soft/zabbix-3.4.15/misc/init.d/fedora/core/zabbix_server /app/zabbix-3.4.15/init.d
cp /opt/soft/zabbix-3.4.15/misc/init.d/fedora/core/zabbix_agentd /app/zabbix-3.4.15/init.d
mkdir -p /app/zabbix-3.4.15/var/lock/subsys
sed -i 's#BASEDIR=/usr/local#BASEDIR=/app/zabbix-3.4.15#g' /app/zabbix-3.4.15/init.d/zabbix_server
sed -i 's#/var/lock/subsys/$BINARY_NAME#/app/zabbix-3.4.15/var/lock/subsys/$BINARY_NAME#g' /app/zabbix-3.4.15/init.d/zabbix_server

sed -i 's#BASEDIR=/usr/local#BASEDIR=/app/zabbix-3.4.15#g' /app/zabbix-3.4.15/init.d/zabbix_agentd
sed -i 's#/var/lock/subsys/$BINARY_NAME#/app/zabbix-3.4.15/var/lock/subsys/$BINARY_NAME#g' /app/zabbix-3.4.15/init.d/zabbix_agentd

#vi /app/zabbix-3.4.15/init.d/zabbix_server
#22 BASEDIR=/app/zabbix-3.4.15
#72 touch /app/zabbix-3.4.15/var/lock/subsys/$BINARY_NAME
#81 [ $RETVAL -eq 0 ] && rm -f /app/zabbix-3.4.15/var/lock/subsys/$BINARY_NAME
#vi /app/zabbix-3.4.15/init.d/zabbix_agentd
#22 BASEDIR=/app/zabbix-3.4.15
#72 touch /app/zabbix-3.4.15/var/lock/subsys/$BINARY_NAME
#81 [ $RETVAL -eq 0 ] && rm -f /app/zabbix-3.4.15/var/lock/subsys/$BINARY_NAME

启动zabbix_server
/app/zabbix-3.4.15/init.d/zabbix_server start
启动httpd
/app/apache/init.d/httpd start
ps -ef|grep zabbix
ps -ef|grep httpd
初始化zabbix前端应用
http://10.6.21.3:8080/zabbix/setup.php
#######################################################################
如果zabbix PHP LDAP off Warning,则PHP需要安装扩展模块ldap

mkdir /app/event
vi /app/zabbix-3.4.15/share/zabbix/alertscripts/sendevent.sh
#!/bin/bash
datename=$(date +%Y-%m-%d)
echo "$1" >> /app/event/event-$datename.log

chmod a+x /app/zabbix-3.4.15/share/zabbix/alertscripts/sendevent.sh

启动脚本
zabbix用户
vi /app/zabbix-3.4.15/start_zabbix-server.sh
#!/bin/bash
/app/zabbix-3.4.15/init.d/zabbix_server start
[zabbix@bogon init.d]$ vi stop_server.sh
#!/bin/bash
/app/zabbix-3.4.15/init.d/zabbix_server stop

vi /app/zabbix-3.4.15/start_zabbix-agent.sh
#!/bin/bash
/app/zabbix-3.4.15/init.d/zabbix_agentd start
[zabbix@bogon init.d]$ vi /app/zabbix-3.4.15/init.d/stop_agentd.sh
#!/bin/bash
/app/zabbix-3.4.15/init.d/zabbix_agentd stop

httpd
[zabbix@bogon apache]$ vi /app/apache/start_httpd.sh
#!/bin/bash
/app/apache/init.d/httpd start
[zabbix@bogon apache]$ vi /app/apache/stop_httpd.sh
#!/bin/bash
/app/apache/init.d/httpd stop

mysql用户
mysql
[mysql@bogon mysql]$ vi /app/mysql/start_mysql.sh
#!/bin/bash
/app/init.d/mysqld start
[mysql@bogon mysql]$ vi /app/mysql/stop_mysql.sh
#!/bin/bash
/app/init.d/mysqld stop

 


zabbix-server主机上安装agent

268 UserParameter=net.if.ipaddress[*],ip addr show $1 | grep "inet "|awk -F "/" {'print $$1'}|awk {'print $$2'}
269 UserParameter=device.discovery,sh /app/zabbix-3.4.15/devicediscovery.sh
270 UserParameter=device.iostat[*],sh /app/zabbix-3.4.15/iostat.sh $1 $2
284 UnsafeUserParameters=1
将脚本上传至/app/zabbix-3.4.15
chown zabbix.zabbix CwMonitor.sh devicediscovery.sh iostat.sh z_process_dis.sh z_process_usage.sh
chmod a+x chmod a+x CwMonitor.sh devicediscovery.sh iostat.sh z_process_dis.sh z_process_usage.sh

上传userparameter_examples.conf 和userparameter_mysql.conf到
/app/zabbix-3.4.15/etc/zabbix_agentd.conf.d/

重启agent

zabbix_server主机上安装flume
上传包apache-flume-1.8.0-bin.tar.gz
tar -zxvf apache-flume-1.8.0-bin.tar.gz

vi /app/apache-flume-1.8.0-bin/conf/flume-agentevent.properties
8 eventAgent.sources.r1.positionFile = /app/apache-flume-1.8.0-bin/taildir_position.json
10 eventAgent.sources.r1.filegroups.f1 = /app/event/.*log
35 eventAgent.sinks.kafkaSinks.kafka.bootstrap.servers=192.168.220.73:9092
36 eventAgent.sinks.kafkaSinks.kafka.topic=zabbix
启动flume
vi /app/apache-flume-1.8.0-bin/start_flume.sh
#!/bin/bash
/app/apache-flume-1.8.0-bin/bin/flumewrapper start -f /app/apache-flume-1.8.0-bin/conf/flume-agentevent.properties -n eventAgent

chmod a+x /app/apache-flume-1.8.0-bin/start_flume.sh
启动flume
/app/apache-flume-1.8.0-bin/start_flume.sh

################################################
备注:另一台全新的主机安装agent(linux系统)
agent安装及配置
创建zabbix组及zabbix用户
root用户
groupadd zabbix
useradd -g zabbix -d /home/zabbix zabbix
passwd zabbix

zabbix用户
上传安装包至/home/zabbix
tar -xvf zabbix_agents_3.2.7_v2.linux2_6.amd64.tar.gz

修改zabbix_agent配置文件
vi /home/zabbix/conf/zabbix_agentd.conf
91 Server=192.168.220.73
132 ServerActive=192.168.220.73
143 Hostname=zabbix_server
267 UserParameter=net.if.ipaddress[*],ip addr show $1 | grep "inet "|awk -F "/" {'print $$1'}|awk {'print $$2'}
268 UserParameter=device.discovery,sh /home/zabbix/devicediscovery.sh
269 UserParameter=device.iostat[*],sh /home/zabbix/iostat.sh $1 $2
284 UnsafeUserParameters=1


启动agent
/home/zabbix/sbin/zabbix_agentd -c /home/zabbix/conf/zabbix_agentd.conf

##############

脚本用新的 admin用户不要给客户
FB00001/123456
这个给客户
##############

create database idap charset utf8;
grant all on idap.* to 'idap'@'%' identified by 'idap2019';
source /opt/idap_20191129.sql

kafka/bin目录查看zabbix和esc_zabbix_history是否接收到数据
(备注:topic为zabbix是zabbix告警事件推送;topic为esc_zabbix_history是集中监控里主机获取信息出来的数据)
./kafka-console-consumer.sh --bootstrap-server idap:9092 --from-beginning --topic esc_zabbix_history
./kafka-console-consumer.sh --bootstrap-server idap:9092 --from-beginning --topic zabbix

#################################################################################################################

keepalived安装

mkdir /opt/soft/keepalived
mkdir /app/keepalived

##########sftp(上传rpm包)###########
cd /opt/soft/keepalived/
lcd I:\优炫\农信\zabbix\zabbix安装介质\zabbix_server安装介质\keepalived
put keepalived-2.0.5.tar.gz libnfnetlink-devel-1.0.1-4.el7.x86_64.rpm openssl-devel-1.0.2k-12.el7.i686.rpm openssl-libs-1.0.2k-12.el7.i686.rpm
###################
cd /opt/soft/keepalived
yum install -y libnl* libnfnetlink-devel zlib zlib-devel gcc gcc-c++ openssl openssl-devel openssh
yum localinstall libnfnetlink-devel-1.0.1-4.el7.x86_64.rpm
yum localinstall openssl-devel-1.0.2k-12.el7.i686.rpm openssl-libs-1.0.2k-12.el7.i686.rpm
tar -xvf keepalived-2.0.5.tar.gz
cd keepalived-2.0.5
./configure --prefix=/app/keepalived
make && make install


mkdir /etc/keepalived
vi /etc/keepalived/keepalived.conf
#################主机##############################

! Configuration File for keepalived

global_defs {
router_id LVS_DEVEL
}

vrrp_script zabbix {
script "/app/keepalived/etc/keepalived/keepalived_check_proxy_pri.sh"
interval 30
}

vrrp_instance VI_1 {
state MASTER #
interface ens192
virtual_router_id 51
priority 100 #
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
zabbix
}
virtual_ipaddress {
10.1.44.145
}
}
#################备机##############################
! Configuration File for keepalived

global_defs {
router_id LVS_DEVEL
}

vrrp_script zabbix {
script "/app/keepalived/etc/keepalived/keepalived_check_proxy_sec.sh"
interval 30
}

vrrp_instance VI_1 {
state BACKUP #备机填BACKUP
interface eno16777736
virtual_router_id 51
priority 80 #备机填80
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
zabbix
}
virtual_ipaddress {
192.168.220.230
}
}
#################################################

mkdir -p /app/keepalived/var/run
vi /usr/lib/systemd/system/keepalived.service
#################################################
[Unit]
Description=LVS and VRRP High Availability Monitor
After= network-online.target syslog.target
Wants=network-online.target

[Service]
Type=forking
#PIDFile=/var/run/keepalived.pid
PIDFile=/app/keepalived/var/run/keepalived.pid
KillMode=process
EnvironmentFile=-/app/keepalived/etc/sysconfig/keepalived
#ExecStart=/app/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS
ExecStart=/app/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS -f /app/keepalived/etc/keepalived/keepalived.conf -p /app/keepalived/var/run/keepalived.pid
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
#################################################