A. The deployment architecture diagram
II. Installation Environment and version information
Operating System: centos7
zabbix Version: 4.4
mysql: 5.7.28
Three .zabbix server installation (192.168.182.132)
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
Note: If you have not installed yum, you can modify /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.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/7/$basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 skip_if_unavailable = 1 keepcache = 0 [zabbix-debuginfo] name=Zabbix Official Repository debuginfo - $basearch baseurl=http://repo.zabbix.com/zabbix/4.4/rhel/7/$basearch/debuginfo/ enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 gpgcheck=1
Four. Mysql installation (192.168.182.132)
HTTPS wget: // cdn.mysql.com // Downloads / the MySQL-5.7 / MySQL-5.7.28-Linux-glibc2.12-x86_64.tar.gz the tar -xzvf MySQL- 5.7 . 28 -linux-have glibc2. 12 is - -C x86_64.tar.gz / App / CD / App / Music Videos MySQL - 5.7 . 28 . -linux have glibc2- 12 is - the x86_64 MySQL mkdir / App / MySQL / {Data, logs} the groupadd MySQL the useradd - G MySQL MySQL chown MySQL: mysql / App / mysql - R & lt . 1, mysql configuration profile:
[Client] Port = 3306 socket = / tmp / mysql.sock default -character- the SET = utf8
# Configure account password, ip; achieve direct command line "password-free" Login [MySQL] Host = 192.168.182.132
the User = zabbix
password = ZABBIX
[mysqladmin]
Host = 192.168.182.132
User = ZABBIX
password = ZABBIX [mysqld] Port = 3306 Socket = / tmp / mysql.sock the 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
2, the database initialization: CD / App / MySQL / bin / mysqld --user = MySQL --basedir = --initialize / App / MySQL --datadir = / App / MySQL / = Data --innodb_undo_tablespaces . 3 - explicit_defaults_for_timestamp login temporary password error file ( / App / MySQL / logs / mysql- error.log) ## porary password IS Generated for root @ localhost: Jm =% mM7w) UBQ ## cp -a / App / MySQL / Support-files /etc/init.d/ /mysql.server mysql echo " Export the PATH = / App / mysql / bin: $ the PATH " >> / etc / Profile Source / etc / Profile # start mysql /etc/init.d/ MySQL Start a temporary password (Jm # using log =% mM7w) UBQ) login MySQL MySQL -u root - the p- # set the root password: MySQL > the SET password for root @ localhost = password ( 'root '); # create zabbix library: the create database zabbix Character the SET utf8 COLLATE utf8_bin; # authorization: Grant All privileges ON . * * to zabbix @ ' % ' IDENTIFIED by ' zabbix ' ; # refresh permission to flush privileges; # import data into zabbix zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | MySQL-uroot--p
zabbix
V. configuration zabbix_server
1, modify the configuration
# 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=192.168.182.132 DBName=zabbix DBUser=zabbix DBPassword=zabbix 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
2, create the relevant directory: mkdir-p / App / ZABBIX / logs /the snmptrap mkdir/ App / ZABBIX /{alertscripts, externalScripts} chown ZABBIX: ZABBIX/ App / ZABBIX / -R & lt . 3, when the modification area: # Vim / etc / the httpd /conf.d/ zabbix.conf # Add / modify the configuration: php_value to the date.timezone Asia/of Shanghai . 4, start Apache systemctl start httpd.service . 5, starting PHP systemctl start PHP -fpm.service . 6, starting Server ZABBIX systemctl ZABBIX start-server.service access: HTTP: ip/zabbix Note: The first time you log in fill in mysql connection address information when needed to fill 0.0.0.0
VI. Change font
# 上传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(192.168.182.130) 部署:
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 clean all
# 先查找zabbix-proxy,yum search zabbix-proxy
yum install zabbix-proxy-mysql.x86_64 zabbix-agent.x86_64
# 如果出现如下错误
Error: Package: zabbix-proxy-mysql-4.4.3-1.el7.x86_64 (zabbix)
Requires: fping
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
# 解决方案:
# 根据错误提示,需要安装fping命令这个依赖,在进行yum安装之后显示该安装包不存在,因此进行推测应该是epel源配置出现问题,因此在阿里源中配置epel源
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
# 再执行
yum install zabbix-proxy-mysql.x86_64 zabbix-agent.x86_64
# 创建zabbix库:
create database zabbix_proxy character set utf8 collate utf8_bin;
# 授权:
grant all privileges on zabbix_proxy.* to zabbix@'%' identified by 'zabbix';
# 刷新权限
flush privileges;
# 部署mysql 步骤和在zabbix server中部署一样,区别在导入数据时候不一样: # zcat /usr/share/doc/zabbix-proxy-mysql*/schema.sql.gz | mysql -uroot -p zabbix_proxy # 修改zabbix-proxy配置:vim /etc/zabbix/zabbix_proxy.conf
Server=192.168.182.132 # 真正的服务端(zabbix server) ServerPort=10051 # 根据个人需要修改,一般可以不改,默认端口是10051,要实现转发的话使用这个选项(zabbix server) ListenPort=10051 # zabbix-proxy服务监听的端口,默认就好
Hostname=Zabbix proxy # proxy的hostname,在web端网页配置时需要用到 DBHost=192.168.182.130 # 数据库,使用本地,也可以使用ip,我喜欢使用localhost,因为我授权就是本地,也因为配置ip失败踩过坑 DBName=zabbix_proxy # 数据库名称,创建zabbix-proxy的mysql的数据库名称 DBUser=zabbix # 用户 DBPassword=zabbix # 密码 DBPort=3306 # 当DBHost填写localhost时,默认是使用socket通信的,这里配置一下也无碍 #HeartbeatFrequency=60 # 心跳线(具体作用网了,看配置文件吧,这个默认就是60) ConfigFrequency=600 # 这个好像是同步配置文件的时间 DataSenderFrequency=1 # 这个是proxy端向server端发送数据的时间,单位是秒,几乎等于实时同步
# 启动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
8.2 、web端配置代理
8.2.1、web配置zabbix代理
如果出现如下图,则zabbix server不能与zabbix proxy正常通信
正常通信如图:
九.zabbix客户端安装
9.1、yum安装
# 添加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
9.3、修改配置
Server=[zabbix server ip] ServerActive=[zabbix server ip] Hostname=[ Hostname of client system ]
# 例:
Server=192.168.182.132
ServerActive=192.168.182.132
Hostname=192.168.182.128
9.4、安装zabbix-get,并测试agent端是否server端连通
# 安装
yum install -y zabbix-get
# 在服务端测试(192.168.182.132),-s --host:agent端ip;-p,--port:端口;-k,--key:监控项key
zabbix_get -s 192.168.182.130 -p 10050 -k system.hostname
十. 常用命令
zabbix server与zabbix proxy的配置的同步是有延时的,如果需要立即同步可以手动执行命令:
zabbix_proxy -c /etc/zabbix/zabbix_proxy.conf -R config_cache_reload