zabbix4.4 (server,proxy,agent)安装部署实战

时间:2019-11-25
本文章向大家介绍zabbix4.4 (server,proxy,agent)安装部署实战,主要包括zabbix4.4 (server,proxy,agent)安装部署实战使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一. 部署架构图

二. 安装环境及版本信息

操作系统:centos7

zabbix版本: 4.4

mysql: 5.7.28

三.zabbix server安装

rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum-config-manager --enable rhel-7-server-optional-rpms
yum install epel-release  numactl
yum install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf  -y 

四. mysql安装

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
tar -xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /app/
cd /app/
mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql
mkdir /app/mysql/{data,logs}
groupadd mysql
useradd -g  mysql mysql
chown mysql:mysql /app/mysql -R

配置mysql 配置文件:

###########################
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8

[mysql]
prompt="MySQL [\d]> "
no-auto-rehash

[mysqld]
port = 3306
socket = /tmp/mysql.sock

basedir = /app/mysql
datadir = /app/mysql/data
pid-file = /app/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1

init-connect = 'SET NAMES utf8'
character-set-server = utf8
log_timestamps=SYSTEM

skip-name-resolve
back_log = 300

max_connections = 613
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 256
max_allowed_packet = 500M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 32M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 16M

thread_cache_size = 16

query_cache_type = 1
query_cache_size = 16M
query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7

log_error = /app/mysql/logs/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /app/mysql/logs/mysql-slow.log

performance_schema = 0
explicit_defaults_for_timestamp



skip-external-locking

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 128M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 16M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800



[mysqldump]
quick
max_allowed_packet = 500M

[myisamchk]
key_buffer_size = 16M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

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

数据库初始化:
cd /app/mysql/
bin/mysqld --initialize --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp

登录的临时密码在error文件中(/app/mysql/logs/mysql-error.log)
##
porary password is generated for root@localhost: Jm=%mM7w)UBq
##

cp -a /app/mysql/support-files/mysql.server /etc/init.d/mysql
echo "export PATH=/app/mysql/bin:$PATH" >> /etc/profile
source /etc/profile

启动mysql
/etc/init.d/mysql start

使用日志中的临时密码(Jm=%mM7w)UBq)登录mysql
mysql -u root -p

重设密码:
mysql>alter user root@localhost identified by 'aaa@2019';

创建zabbix库:
create database zabbix character set utf8 collate utf8_bin;
授权:
grant all privileges on *.* to zabbix@'%' identified by 'aaa@2019';
flush privileges;

导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz |  mysql -uzabbix -p  zabbix

五.配置zabbix_server

# vi /etc/zabbix/zabbix_server.conf
LogFile=/app/zabbix/logs/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=aaa@2019
DBSocket=/tmp/mysql.sock
SNMPTrapperFile=/app/zabbix/logs/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/app/zabbix/alertscripts
ExternalScripts=/app/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

创建相关目录:
mkdir -p /app/zabbix/logs/snmptrap
mkdir /app/zabbix/{alertscripts,externalscripts}
chown zabbix:zabbix /app/zabbix/ -R

修改时区:
vim /etc/httpd/conf.d/zabbix.conf
添加配置:
php_value date.timezone Asia/Shanghai

启动apache
systemctl start httpd.service
启动php
systemctl start php-fpm.service
启动zabbix server
systemctl start zabbix-server.service

访问: http:ip/zabbix  

注意:第一次登录填写mysql连接信息时候地址需要填0.0.0.0

六. 修改字体

上传windows中的字体simkai.ttf 到/usr/share/zabbix/assets/fonts目录
mv graphfont.ttf  graphfont.ttf.bak
ln -s /usr/share/zabbix/assets/fonts/simkai.ttf  graphfont.ttf

七.安装graphtree插件(选)

graphtree是一个图形展示插件
wget https://raw.githubusercontent.com/OneOaaS/graphtrees/master/graphtree3.0.4.patch yum install -y patch cp -a /usr/share/zabbix /usr/share/zabbix.bak mv graphtree3.0.4.patch /usr/share/zabbix/ cd /usr/share/zabbix patch -Np0 <graphtree3.0.4.patch chown apache:apache oneoaas -R 添加配置:vim /etc/httpd/conf.d/zabbix.conf Alias /oneoaas /usr/share/zabbix/oneoaas systemctl restart httpd.service zabbix-server.service

八.zabbix proxy 部署:

  8.1 yum安装

rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum-config-manager --enable rhel-7-server-optional-rpms
yum install zabbix-proxy-mysql 
yum -y install numactl

部署mysql 步骤和在zabbix server中部署一样,区别在导入数据时候不一样:
# zcat /usr/share/doc/zabbix-proxy-mysql*/schema.sql.gz | mysql -uzabbix -p zabbix

修改zabbix-proxy配置:vim /etc/zabbix/zabbix_proxy.conf 

Server=123.123.123.123
Hostname=heaven-01
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_proxy.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=fdd@2019
DBSocket= /tmp/mysql.sock
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=30
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

启动zabbix-proxy 
systemctl start zabbix-proxy.service

  8.2 源码安装

yum -y install curl-devel libevent-devel   libevent curl  libxml2-devel libxml2  pcre pcre-devel
yum install mysql-devel  -y
yum install -y net-snmp-devel


编译安装zabbix proxy:
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.0/zabbix-4.4.0.tar.gz
tar -xzvf zabbix-4.4.0.tar.gz
cd zabbix-4.4.0

proxy:
 ./configure --prefix=/app/zabbix_proxy_4.4   --enable-proxy  --with-mysql   --with-libcurl --with-libxml2  --enable-ipv6 --with-net-snmp --with-openssl
ln -s /app/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20
启动:
/app/zabbix_proxy_4.4/sbin/zabbix_proxy -c /app/zabbix_proxy_4.4/etc/zabbix_proxy.conf

九.zabbix客户端安装

  9.1 yum安装

rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum install zabbix-agent
service zabbix-agent start

  9.2 源码安装

yum -y install curl-devel libevent-devel   libevent curl  libxml2-devel libxml2  pcre pcre-devel
yum install mysql-devel  -y
yum install -y net-snmp-devel


编译安装zabbix客户端:
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.0/zabbix-4.4.0.tar.gz
tar -xzvf zabbix-4.4.0.tar.gz
cd zabbix-4.4.0

agent:
 ./configure --prefix=/app/zabbix_agent_4.4   --enable-agent  --enable-ipv6 --with-net-snmp --with-openssl

启动:
/app/zabbix_agent_4.4/sbin/zabbix_agentd -c /app/zabbix_agent_4.4/etc/zabbix_agentd.conf

十. 常用命令

zabbix server与zabbix proxy的配置的同步是有延时的,如果需要立即同步可以手动执行命令:
zabbix_proxy -c /etc/zabbix/zabbix_proxy.conf  -R config_cache_reload

原文地址:https://www.cnblogs.com/heaven-xi/p/11928305.html