Zabbbix安装及配置,你学会了吗?
目录:[*]一、获取zabbix安装包
[*]二、安装环境准备
[*]1、安装依赖环境
[*]2、配置时钟同步
[*]三、安装Zabbix Server端
[*]1、软件存入到服务器端
[*]2、安装php依赖组件
[*]3、安装Mysql组件
[*]4、安装nginx组件
[*]5、编译安装zabbix-server
[*]四、初始化zabbix-server
[*]1、访问zabbix-server地址
[*]2、zabbix环境检查
[*]3、zabbix数据库配置
[*]五、编译安装zabbix-agent端
[*]六、安装zabbix-proxy端
[*]1、安装依赖环境
[*]2、配置时钟同步
[*]3、上传安装文件
[*]4、编译安装
[*]5、配置zabbix-proxy
[*]6、添加管理脚本
[*]7、安装Mysql组件
[*]8、启动zabbix-proxy
[*]9、添加zabbix proxy节点
[*]10、确认proxy工作状态
一、获取zabbix安装包软件下载 :project/zabbix/ZABBIX%20Latest%20Stable/3.0.5/zabbix-3.0.5.tar.gzzabbix版本使用3.0LTS版本二、安装环境准备1、安装依赖环境yum groupinstall "Development tools" "Compatibility libraries" -y2、配置时钟同步echo "00 */1 * * * root /usr/sbin/ntpdate 1.cn.pool.ntp.org;hwclock -w" >> /etc/crontab三、安装Zabbix Server端1、软件存入到服务器端
[*]将下载好的zabbix-3.0.5.tar.gz放到相应的服务器端
[*]解压软件包
tar xf zabbix-3.0.5.tar.gz2、安装php依赖组件
[*]添加yum源
name=Webtatic Repository EL6 - $basearchmirrorlist=yum/el7/x86_64/mirrorlistfailovermethod=priorityenabled=1gpgcheck=0
[*]缓存repo数据
yum makecache
[*]安装php
yum install php56w php56w-bcmath php56w-pecl-memcache php56w-pecl-redis php56w-mcrypt php56w-cli php56w-mysqlphp56w-fpmphp56w-pdophp56w-mbstringphp56w-soap php56w-process php56w-xml php56w-pear php56w-pecl-igbinary php56w-gd php56w-devel php56w-pecl-redis php56w-ldap php56w-common php56w-xmlrpc php56w-opcache -y
[*]配置php
# cat /etc/php.ini| grep "^[^;]"engine = Onshort_open_tag = Offasp_tags = Offprecision = 14output_buffering = 4096zlib.output_compression = Offimplicit_flush = Offunserialize_callback_func =serialize_precision = 17disable_functions =disable_classes =zend.enable_gc = Onexpose_php = Onmax_execution_time = 300max_input_time = 300memory_limit = 128Merror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICTdisplay_errors = Offdisplay_startup_errors = Offlog_errors = Onlog_errors_max_len = 1024ignore_repeated_errors = Offignore_repeated_source = Offreport_memleaks = Ontrack_errors = Offhtml_errors = Onvariables_order = "GPCS"request_order = "GP"register_argc_argv = Offauto_globals_jit = Onpost_max_size = 16Mauto_prepend_file =auto_append_file =default_mimetype = "text/html"default_charset = "UTF-8"always_populate_raw_post_data = -1doc_root =user_dir =enable_dl = Offfile_uploads = Onupload_max_filesize = 2Mmax_file_uploads = 20allow_url_fopen = Onallow_url_include = Offdefault_socket_timeout = 60cli_server.color = On#date.timezone = RPCdate.timezone = Asia/Shanghaipdo_mysql.cache_size = 2000pdo_mysql.default_socket=sendmail_path = /usr/sbin/sendmail -t -imail.add_x_header = Onsql.safe_mode = Offodbc.allow_persistent = Onodbc.check_persistent = Onodbc.max_persistent = -1odbc.max_links = -1odbc.defaultlrl = 4096odbc.defaultbinmode = 1ibase.allow_persistent = 1ibase.max_persistent = -1ibase.max_links = -1ibase.timestampformat = "%Y-%m-%d %H:%M:%S"ibase.dateformat = "%Y-%m-%d"ibase.timeformat = "%H:%M:%S"mysql.allow_local_infile = Onmysql.allow_persistent = Onmysql.cache_size = 2000mysql.max_persistent = -1mysql.max_links = -1mysql.default_port =mysql.default_socket =mysql.default_host =mysql.default_user =mysql.default_password =mysql.connect_timeout = 60mysql.trace_mode = Offmysqli.max_persistent = -1mysqli.allow_persistent = Onmysqli.max_links = -1mysqli.cache_size = 2000mysqli.default_port = 3306mysqli.default_socket =mysqli.default_host =mysqli.default_user =mysqli.default_pw =mysqli.reconnect = Offmysqlnd.collect_statistics = Onmysqlnd.collect_memory_statistics = Offpgsql.allow_persistent = Onpgsql.auto_reset_persistent = Offpgsql.max_persistent = -1pgsql.max_links = -1pgsql.ignore_notice = 0pgsql.log_notice = 0sybct.allow_persistent = Onsybct.max_persistent = -1sybct.max_links = -1sybct.min_server_severity = 10sybct.min_client_severity = 10bcmath.scale = 0session.save_handler = filessession.use_strict_mode = 0session.use_cookies = 1session.use_only_cookies = 1session.name = PHPSESSIDsession.auto_start = 0session.cookie_lifetime = 0session.cookie_path = /session.cookie_domain =session.cookie_httponly =session.serialize_handler = phpsession.gc_probability = 1session.gc_divisor = 1000session.gc_maxlifetime = 1440session.referer_check =session.cache_limiter = nocachesession.cache_expire = 180session.use_trans_sid = 0session.hash_function = 0session.hash_bits_per_character = 5url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"mssql.allow_persistent = Onmssql.max_persistent = -1mssql.max_links = -1mssql.min_error_severity = 10mssql.min_message_severity = 10mssql.compatibility_mode = Offmssql.secure_connection = Offtidy.clean_output = Offsoap.wsdl_cache_enabled=1soap.wsdl_cache_dir="/tmp"soap.wsdl_cache_ttl=86400soap.wsdl_cache_limit = 5ldap.max_links = -1# cat /etc/php-fpm.d/www.conflisten = 127.0.0.1:9000listen.allowed_clients = 127.0.0.1user = apachegroup = apachepm = dynamicpm.max_children = 50pm.start_servers = 5pm.min_spare_servers = 5pm.max_spare_servers = 35slowlog = /var/log/php-fpm/www-slow.logphp_admin_value = /var/log/php-fpm/www-error.logphp_admin_flag = onphp_value = filesphp_value = /var/lib/php/sessionphp_value= /var/lib/php/wsdlcache
[*]启动php-fpm
service php-fpm start | systemctl start php-fpm.service
[*]服务加入启动项
chkconfig php-fpm on | systemctl enable php-fpm.service3、安装Mysql组件
[*]添加yum源
name = CentOS $releasever - Perconabase/centos/$releasever/os/$basearch/enabled = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-perconagpgcheck = 0
[*]安装mysql
yum install Percona-Server-client-56 Percona-Server-devel-56 Percona-Server-server-56 Percona-Server-shared-56 Percona-Server-shared-compat
[*]初始化mysql
# mysql_install_db
[*]启动mysql
service mysql start | systemctl start mysql.service
[*]导入zabbix数据库脚本
# cd /root/zabbix-3.0.5/database/mysql/# mysql -uroot -ptest@2016mysql> create database zabbix default charset utf8;mysql> grant all privileges on zabbix.* to 'test'@'localhost' identified by 'test@2016';mysql> quit;# mysql -uroot -ptest@2016 zabbix < schema.sql# mysql -uroot -ptest@2016 zabbix < images.sql# mysql -uroot -ptest@2016 zabbix < data.sql
[*]服务加入启动项
chkconfig mysql on | systemctl enable mysql.service4、安装nginx组件
[*]添加阿里云epel源
name=aliyun epelbase/epel/7Server/x86_64/enabled=1gpgcheck=0
[*]安装nginx
yum install nginx -y
[*]配置nginx 虚拟主机
# cat zabbix.confserver { listen 80; server_name zabbix-idc.test.cn; access_log/web/logs/zabbix.test.cn.logmain; index index.html index.php index.html; root /web/site/zabbix.test.cn; location / { try_files $uri $uri/ /index.php?$args; } location ~ ^(.+.php)(.*)$ { fastcgi_split_path_info ^(.+.php)(.*)$; include fastcgi.conf; fastcgi_pass127.0.0.1:9000; fastcgi_index index.php; fastcgi_paramPATH_INFO $fastcgi_path_info; }}
[*]创建虚拟主机根目录
mkdir /web/site/zabbix.test.cn -pmkdir /web/logs/
[*]复制zabbix 资源文件到虚拟主机根目录
# pwd/root/zabbix-3.0.5# cd frontends/php/# cp -r * /web/site/zabbix.test.cn/
[*]配置zabbix的数据库设置
# pwd/web/site/zabbix.test.cn# cat conf/zabbix.conf.php<?php// Zabbix GUI configuration file.global $DB;$DB['TYPE'] = 'MYSQL';$DB['SERVER'] = '10.8.5.88';$DB['PORT'] = '0';$DB['DATABASE'] = 'zabbix';$DB['USER'] = 'test';$DB['PASSWORD'] = 'test@2016';// Schema name. Used for IBM DB2 and PostgreSQL.$DB['SCHEMA'] = '';$ZBX_SERVER = '10.8.5.88';$ZBX_SERVER_PORT = '10051';$ZBX_SERVER_NAME = '';$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
[*]启动Nginx
service nginx start | systemctl start nginx.service
[*]将Nginx加入启动列表
chkconfig nginx on | systemctl enable nginx.service5、编译安装zabbix-server
[*]进入zabbix源码目录
cd /root/zabbix-3.0.5useradd zabbix
[*]编译
# ./configure --prefix=/usr/local/zabbix-3.0.5 --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2# make # make install
[*]配置zabbix-server
# grep -v "^#" zabbix_server.conf | grep -v "^$"LogFile=/tmp/zabbix_server.logDebugLevel=3PidFile=/tmp/zabbix_server.pidDBHost=10.8.5.88DBName=zabbixDBUser=testDBPassword=test@2016StartPollers=40CacheSize=128MTimeout=4AlertScriptsPath=/usr/local/zabbix-3.0/binLogSlowQueries=3000
[*]配置zabbix-server服务管理脚本
# cat /etc/init.d/zabbix-server #!/bin/sh## chkconfig: - 85 15# description: Zabbix server daemon# config: /usr/local/zabbix-3.0/etc/zabbix_server.conf#### BEGIN INIT INFO# Provides: zabbix# Required-Start: $local_fs $network# Required-Stop: $local_fs $network# Default-Start:# Default-Stop: 0 1 2 3 4 5 6# Short-Description: Start and stop Zabbix server# Description: Zabbix server### END INIT INFO# Source function library.. /etc/rc.d/init.d/functionsexport PATH=/usr/local/zabbix-3.0/sbin/:$PATHif [ -x /usr/local/zabbix-3.0/sbin/zabbix_server ]; then exec=zabbix_serverelse exit 5fiprog=${exec##*/}conf=/usr/local/zabbix-3.0/etc/zabbix_server.confpidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2| tr -d '\r')timeout=10if [ -f /etc/sysconfig/zabbix-server ]; then . /etc/sysconfig/zabbix-serverfilockfile=/var/lock/subsys/zabbix-serverstart(){ echo -n $"Starting Zabbix server: " daemon $exec -c $conf rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv}stop(){ echo -n $"Shutting down Zabbix server: " killproc -p $pidfile -d $timeout $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv}restart(){ stop start}case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p $pidfile $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action: " /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;;esac
[*]启动zabbix-server服务
# chmod +x /etc/init.d/zabbix-server # service zabbix-server start# chkconfig zabbix-server on四、初始化zabbix-server1、访问zabbix-server地址2、zabbix环境检查3、zabbix数据库配置五、编译安装zabbix-agent端Server端在编译的时候,已经开启了zabbix-agent功能,不需要单独编译
[*]进入源码目录
# cd /root/zabbix-3.0.5# useradd zabbix# mkdir /var/log/zabbix# chown zabbix.zabbix /var/log/zabbix
[*]编译
# ./configure --prefix=/usr/local/zabbix-3.0/ --enable-agent
[*]配置zabbix-agent服务管理脚本
# cat /etc/init.d/zabbix-agent #!/bin/sh## chkconfig: - 86 14# description: Zabbix agent daemon# processname: zabbix_agentd# config: /usr/local/zabbix-3.0/etc/zabbix_agentd.conf#### BEGIN INIT INFO# Provides: zabbix-agent# Required-Start: $local_fs $network# Required-Stop: $local_fs $network# Should-Start: zabbix zabbix-proxy# Should-Stop: zabbix zabbix-proxy# Default-Start:# Default-Stop: 0 1 2 3 4 5 6# Short-Description: Start and stop Zabbix agent# Description: Zabbix agent### END INIT INFO# Source function library.. /etc/rc.d/init.d/functionsexport PATH=/usr/local/zabbix-3.0/sbin/:$PATHif [ -x /usr/local/zabbix-3.0/sbin/zabbix_agentd ]; then exec=zabbix_agentdelse exit 5fiprog=${exec##*/}conf=/usr/local/zabbix-3.0/etc/zabbix_agentd.confpidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2 | tr -d '\r')timeout=10if [ -f /etc/sysconfig/zabbix-agent ]; then . /etc/sysconfig/zabbix-agentfilockfile=/var/lock/subsys/zabbix-agentstart(){ echo -n $"Starting Zabbix agent: " daemon $exec -c $conf rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv}stop(){ echo -n $"Shutting down Zabbix agent: " killproc -p $pidfile -d $timeout $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv}restart(){ stop start}case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p $pidfile $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action: " /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;;esac
[*]服务添加到启动项
# chkconfig zabbix-agent on
[*]启动服务
# service zabbix-agent start六、安装zabbix-proxy端zabbix版本使用3.0LTS版本,需要将zabbix-proxy的主机添加到zabbix-server中,目录环境中是将IP:58.96.188.84,zabbix-agent名称为:[]www. 1、安装依赖环境yum groupinstall "Development tools" "Compatibility libraries" -y2、配置时钟同步echo "00 */1 * * * root /usr/sbin/ntpdate 1.cn.pool.ntp.org;hwclock -w" >> /etc/crontab3、上传安装文件# lszabbix-3.0.5.tar.gz4、编译安装# ./configure --prefix=/usr/local/zabbix-3.0 --with-mysql --with-net-snmp --with-libcurl--enable-agent --enable-proxy#此处开启了zabbix-agent端# make&& make install5、配置zabbix-proxy# cd /usr/local/zabbix-3.0/etc/# cat zabbix_proxy.confServer=103.243.254.186#ServerPort=10053ServerPort=10051Hostname=www. LogFile=/var/log/zabbix/zabbix3_proxy.logLogFileSize=0DebugLevel=3PidFile=/var/run/zabbix/zabbix3_proxy.pidDBName=zabbix3DBUser=zabbix3DBPassword=test@2016 #此处的数据库用户和密码,需要手动建立DBSocket=/var/lib/mysql/mysql.sockProxyLocalBuffer=0ProxyOfflineBuffer=1ConfigFrequency=600DataSenderFrequency=10ExternalScripts=/usr/local/zabbix-3.0/scripts/# useradd zabbix# mkdir /var/log/zabbix# chown zabbix.zabbix /var/log/zabbix6、添加管理脚本由于字数限制,本处略过....7、安装Mysql组件
[*]添加yum源
name = CentOS $releasever - Perconabase/centos/$releasever/os/$basearch/enabled = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-perconagpgcheck = 0
[*]安装mysql
yum install Percona-Server-client-56 Percona-Server-devel-56 Percona-Server-server-56 Percona-Server-shared-56 Percona-Server-shared-compat
[*]初始化mysql
# mysql_install_db
[*]启动mysql
service mysql start | systemctl start mysql.service
[*]导入zabbix数据库脚本
# cd /root/zabbix-3.0.5/database/mysql/# mysql -uroot -ptest@2016mysql> create database zabbix3 default charset utf8;mysql> grant all privileges on zabbix3.* to 'zabbix3'@'localhost' identified by 'test@2016';mysql> quit;# mysql -uroot -ptest@2016 zabbix < schema.sql
[*]服务加入启动项
chkconfig mysql on | systemctl enable mysql.service8、启动zabbix-proxy# chmod +x /etc/init.d/zabbix-proxy # chkconfig zabbix-proxy on# service zabbix-proxy start9、添加zabbix proxy节点需要将[]www. 这个代理节点添加到zabbix中。(在proxy端开户agent,并添加主机)
[*]登陆zabbix server端
[*]添加proxy代理节点
10、确认proxy工作状态
[*]zabbix server端日志
# tailf /tmp/zabbix_server.log7541:20161201:215205.923 sending configuration data to proxy "www. " at "58.96.188.84", datalen 389617539:20161201:220206.514 sending configuration data to proxy "www. " at "58.96.188.84", datalen 389617542:20161201:221206.753 sending configuration data to proxy "www. " at "58.96.188.84", datalen 38961
[*]zabbix proxy端日志
tailf /var/log/zabbix/zabbix3_proxy.log 10518:20161202:105206.429 received configuration data from server at "103.243.254.186", datalen 38961 10518:20161202:110206.673 received configuration data from server at "103.243.254.186", datalen 38961 10518:20161202:111206.918 received configuration data from server at "103.243.254.186", datalen 38961
原创:magedu-魏镇坪
页:
[1]