zabbix11 ---- source install

zabbix11 ---- source install

zabbix

源码包编译安装

zabbix server

wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.35.tar.gz
useradd zabbix -s /sbin/nologin -r
tar xf zabbix-4.0.35.tar.gz
cd zabbix-4.0.35
./configure --prefix=/apps/zabbix-server  --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 && make && make install

配置文件

zabbix_server.conf
ListenPort=10051
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
SocketDir=/tmp
DBHost=192.168.10.81
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix123
StartPollers=5
JavaGateway=192.168.10.81
JavaGatewayPort=10052
StartJavaPollers=5
ListenIP=0.0.0.0
CacheSize=8M
HistoryCacheSize=16M
HistoryIndexCacheSize=4M
Timeout=30

初始化数据库

https://www.zabbix.com/documentation/4.0/zh/manual/appendix/install/db_scripts
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to 'zabbix'@'192.168.10.%' identified by 'zabbix123';
cd zabbix-4.0.33/database/mysql
mysql -h192.168.10.11 -uzabbix -p zabbix < schema.sql
下面步骤当创建Zabbix proxy数据库时不需要执行
mysql -h192.168.10.11 -uzabbix -p zabbix < images.sql
mysql -h192.168.10.11 -uzabbix -p zabbix < data.sql

服务脚本

源码包自代
cp -a misc/init.d/fedora/core/zabbix* /etc/init.d/.
sed -ri '/BASEDIR=/s@(BASEDIR=).*@\1/apps/zabbix-server@' /etc/init.d/zabbix_server 
sed -ri '/BASEDIR=/s@(BASEDIR=).*@\1/apps/zabbix-server@' /etc/init.d/zabbix_agentd
systemctl daemon-reload
/etc/init.d/zabbix_server start && chkconfig zabbix_server on
/etc/init.d/zabbix_agentd start && chkconfig zabbix_agentd on

根据rpm包中的脚本修改路径即可
cp zabbix-server.service zabbix-agent.service /usr/lib/systemd/system/. 
systemctl daemon-reload
systemctl start zabbix_server zabbix_agentd
systemctl enable zabbix_server zabbix_agentd

zabbix-web

cp -a zabbix-4.0.33/frontends/php/ /var/www/html/zabbix
yum install -y httpd php php-fpm
yum install -y php-bcmath php-mbstring php-gd php-mysql php-xml php-ldap
sed -ri '/;date.timezone =/s@;(date.timezone =).*@\1 Asia/Shanghai@' /etc/php.ini 
cat /etc/httpd/conf.d/zabbix.conf 
#
# Zabbix monitoring system php web frontend
#

Alias /zabbix /var/www/html/zabbix

<Directory "/var/www/html/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted

    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        php_value date.timezone Asia/Shanghai 
    </IfModule>
</Directory>

<Directory "/var/www/html/zabbix/conf">
    Require all denied
</Directory>

<Directory "/var/www/html/zabbix/app">
    Require all denied
</Directory>

<Directory "/var/www/html/zabbix/include">
    Require all denied
</Directory>

<Directory "/var/www/html/zabbix/local">
    Require all denied
</Directory>
systemctl restart php-fpm httpd

zabbix agent

wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.35.tar.gz
./configure --prefix=/apps/zabbix-agent --enable-agent && make && make install
sed -i 's/Defaults    requiretty/#Defaults    requiretty/g' /etc/sudoers
sed -i 's/Defaults   !visiblepw/#Defaults   !visiblepw/g' /etc/sudoers
grep ^zabbix /etc/sudoers || echo "zabbix  ALL = NOPASSWD: ALL"  >> /etc/sudoers

grep ^[a-Z] zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
EnableRemoteCommands=1
Server=0.0.0.0/0
ServerActive=192.168.10.82
HostnameItem=system.hostname
Include=/apps/zabbix-agent/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1

zabbix proxy

wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.35.tar.gz
./configure --prefix=/apps/zabbix-proxy --enable-proxy --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 && make -j&& make install

导入SQL语句

create database zabbix_proxy character set utf8 collate utf8_bin;
mysql -e "grant all privileges on zabbix_proxy.* to 'zabbix_proxy'@'192.168.10.%' identified by 'zabbix123';"
mysql -e "flush privileges;"
cd database/mysql
mysql -h192.168.10.81 -uzabbix_proxy -pzabbix123 zabbix_proxy < schema.sql

配置文件

grep '^[a-Z]' zabbix_proxy.conf  
ProxyMode=0
Server=192.168.10.81
ServerPort=10051
Hostname=zabbix_proxy_active
LogFile=/tmp/zabbix_proxy.log
PidFile=/tmp/zabbix_proxy.pid
DBHost=192.168.10.81
DBName=zabbix_proxy
DBUser=zabbix_proxy
DBPassword=zabbix123
ProxyLocalBuffer=720
ProxyOfflineBuffer=720
HeartbeatFrequency=60
ConfigFrequency=60
StartPollers=5
JavaGateway=192.168.10.81
JavaGatewayPort=10052
StartJavaPollers=5
CacheSize=8M
HistoryCacheSize=16M
HistoryIndexCacheSize=4M
Timeout=30
LogSlowQueries=3000

小结

脚本已写好,后期待优化

上一篇:java获取ip,spring boot获取访问者ip地址绕过代理


下一篇:Zabbix4.0监控环境搭建详细笔记