Zabbix部署篇-Zabbix分布式Proxy4.4.4基于Sqlite3环境搭建

释放双眼,带上耳机,听听看~!

系统环境

角色 系统版本 软件版本 IP地址 服务名称
Zabbix_proxy CentOS release 6.8 zabbix-4.4.4/sqlite3 172.26.3.86 mj-demo-172.26.3.86

环境准备

#zabbix proxy依赖包,推荐与zabbix server一致
yum install net-snmp.x86_64 net-snmp-devel.x86_64 curl.x86_64 libxml2.x86_64 libxml2-devel.x86_64 libcurl.x86_64 libcurl-devel.x86_64 fping.x86_64 OpenIPMI.x86_64 OpenIPMI-devel.x86_64 -y

#zabbix_java依赖
yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 -y 

#zabbix agent2依赖golang环境
wget -P /usr/local/src https://studygolang.com/dl/golang/go1.13.5.linux-amd64.tar.gz
tar xf /usr/local/src/go1.13.5.linux-amd64.tar.gz -C /usr/local
cat > /etc/profile.d/go.sh << EOF
export GOROOT=/usr/local/go
export PATH=\$PATH:\$GOROOT/bin
EOF
source /etc/profile

下载解压并创建zabbix用户

wget -P /usr/local/src https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.4.4/zabbix-4.4.4.tar.gz
tar xf /usr/local/src/zabbix-4.4.4.tar.gz -C /usr/local/src/
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /bin/false -c "Zabbix Monitoring System" zabbix

编译部署Zabbix Proxy

cd /usr/local/src/zabbix-4.4.4
./configure --prefix=/usr/local/zabbix --enable-proxy --enable-agent2 --enable-ipv6 --enable-java --with-sqlite3 --with-net-snmp --with-libcurl --with-libxml2 --with-zlib --with-libevent --with-libpcre --with-iconv --with-openipmi
make install
echo $?
0

复制启动脚本

cp -rf /usr/local/src/zabbix-4.4.4/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
chmod u+x /etc/init.d/zabbix_server
sed -i 's/server/proxy/g' /etc/init.d/zabbix_server
sed -i 's@\/usr\/local\/sbin@\/usr\/local\/zabbix\/sbin@g' /etc/init.d/zabbix_server   
mv /etc/init.d/zabbix_server /etc/init.d/zabbix_proxy 

安装SQLite3

目前,几乎所有版本的 Linux 操作系统都附带 SQLite,以下来检测是否安装sqlite3

sqlite3
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

如果没有看到上面的结果,那么就意味着没有在 Linux 机器上安装 SQLite。因此,让我们按照下面的步骤安装 SQLite:
请访问:https://www.sqlite.org/download.html sqlite下载页面,从源码区进行下载后按照以下步骤进行安装

$ tar xvzf sqlite-autoconf-3071502.tar.gz
$ cd sqlite-autoconf-3071502
$ ./configure --prefix=/usr/local
$ make
$ make install

创建数据库并导入数据

1.使用sqlite3创建数据库

mkdir /usr/local/zabbix/data
sqlite3 /usr/local/zabbix/data/zabbix_proxy.db
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .databases
seq  name             file
---  ---------------  ----------------------------------------------------------
0    main             /usr/local/zabbix/data/zabbix_proxy.db
sqlite> .exit 

2.导入数据库数据

sqlite3 /usr/local/zabbix/data/zabbix_proxy.db < /usr/local/src/zabbix-4.4.4/database/sqlite3/schema.sql 

3.修改数据库权限

chown -Rf zabbix.zabbix /usr/local/zabbix/data/

修改zabbix配置文件

vim /usr/local/zabbix/etc/zabbix_proxy.conf
ProxyMode=0
Server=172.26.3.106
ServerPort=10051
Hostname=mj-demo
ListenPort=10051
SourceIP=172.26.3.86
LogType=file
LogFile=/tmp/zabbix_proxy.log
LogFileSize=100
DebugLevel=3
EnableRemoteCommands=1
LogRemoteCommands=0
PidFile=/tmp/zabbix_proxy.pid
SocketDir=/tmp
DBName=/usr/local/zabbix/data/zabbix_proxy.db
ProxyLocalBuffer=24
ProxyOfflineBuffer=24
HeartbeatFrequency=60
ConfigFrequency=120
DataSenderFrequency=60
StartPollers=3
StartIPMIPollers=1
StartPreprocessors=3
StartPollersUnreachable=2
StartTrappers=2
StartPingers=2
StartDiscoverers=1
StartHTTPPollers=2
JavaGateway=172.26.3.106
JavaGatewayPort=10052
StartJavaPollers=2
StartVMwareCollectors=2
VMwareFrequency=60
VMwarePerfFrequency=60
VMwareCacheSize=8M
VMwareTimeout=10
SNMPTrapperFile=/tmp/zabbix_traps.tmp
StartSNMPTrapper=1
ListenIP=0.0.0.0
HousekeepingFrequency=12
CacheSize=8M
StartDBSyncers=2
HistoryCacheSize=16M
HistoryIndexCacheSize=4M
Timeout=15
TrapperTimeout=90
UnreachablePeriod=120
UnavailableDelay=60
UnreachableDelay=15
ExternalScripts=/usr/local/zabbix/share/zabbix/externalscripts
FpingLocation=/usr/sbin/fping
LogSlowQueries=3000
TmpDir=/tmp
AllowRoot=0
User=zabbix
Include=/usr/local/zabbix/etc/zabbix_proxy.conf.d/*.conf
StatsAllowedIP=127.0.0.1

创建临时文件

touch /tmp/zabbix_traps.tmp
chown -Rf zabbix.zabbix /tmp/zabbix_traps.tmp

启动Zabbix_Proxy

service zabbix_proxy start
chkconfig --add zabbix_proxy
chkconfig zabbix_proxy on

配置agent2

grep -Ev "#|^$" zabbix_agent2.conf
PidFile=/tmp/zabbix_agent2.pid
LogType=file
LogFile=/tmp/zabbix_agent2.log
LogFileSize=100
DebugLevel=3
SourceIP=172.26.3.86
Server=127.0.0.1,172.26.3.86
ListenPort=10050
ListenIP=0.0.0.0
Hostname=172.26.3.86
RefreshActiveChecks=60
BufferSend=5
BufferSize=100
Timeout=15
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1
ControlSocket=/tmp/agent.sock

启动Zabbix Agent2

nohup /usr/local/zabbix/sbin/zabbix_agent2 &

人已赞赏
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索