目录:[url=]一、获取zabbix安装包[/url] [url=]二、安装环境准备[/url]
[url=]1、安装依赖环境[/url] [url=]2、配置时钟同步[/url]
[url=]三、安装Zabbix Server端[/url]
[url=]四、初始化zabbix-server[/url]
[url=]五、编译安装zabbix-agent端[/url] [url=]六、安装zabbix-proxy端[/url]
[url=]1、安装依赖环境[/url] [url=]2、配置时钟同步[/url] [url=]3、上传安装文件[/url] [url=]4、编译安装[/url] [url=]5、配置zabbix-proxy[/url] [url=]6、添加管理脚本[/url] [url=]7、安装Mysql组件[/url] [url=]8、启动zabbix-proxy[/url] [url=]9、添加zabbix proxy节点[/url] [url=]10、确认proxy工作状态[/url]
一、获取zabbix安装包软件下载 :[url=]project/zabbix/ZABBIX%20Latest%20Stable/3.0.5/zabbix-3.0.5.tar.gz[/url] zabbix版本使用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、软件存入到服务器端tar xf zabbix-3.0.5.tar.gz2、安装php依赖组件[webtatic]name=Webtatic Repository EL6 - $basearchmirrorlist=yum/el7/x86_64/mirrorlistfailovermethod=priorityenabled=1gpgcheck=0yum makecacheyum install php56w php56w-bcmath php56w-pecl-memcache php56w-pecl-redis php56w-mcrypt php56w-cli php56w-mysql php56w-fpm php56w-pdo php56w-mbstring php56w-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[root@zabbix3-server ~]# cat /etc/php.ini | grep "^[^;]"[PHP]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 = 60[CLI Server]cli_server.color = On[Date]#date.timezone = RPCdate.timezone = Asia/Shanghai[filter][iconv][intl][sqlite][sqlite3][Pcre][Pdo][Pdo_mysql]pdo_mysql.cache_size = 2000pdo_mysql.default_socket=[Phar][mail function]sendmail_path = /usr/sbin/sendmail -t -imail.add_x_header = On[SQL]sql.safe_mode = Off[ODBC]odbc.allow_persistent = Onodbc.check_persistent = Onodbc.max_persistent = -1odbc.max_links = -1odbc.defaultlrl = 4096odbc.defaultbinmode = 1[Interbase]ibase.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]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 = Off[MySQLi]mysqli.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 = Off[mysqlnd]mysqlnd.collect_statistics = Onmysqlnd.collect_memory_statistics = Off[OCI8][PostgreSQL]pgsql.allow_persistent = Onpgsql.auto_reset_persistent = Offpgsql.max_persistent = -1pgsql.max_links = -1pgsql.ignore_notice = 0pgsql.log_notice = 0[Sybase-CT]sybct.allow_persistent = Onsybct.max_persistent = -1sybct.max_links = -1sybct.min_server_severity = 10sybct.min_client_severity = 10[bcmath]bcmath.scale = 0[browscap][Session]session.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]mssql.allow_persistent = Onmssql.max_persistent = -1mssql.max_links = -1mssql.min_error_severity = 10mssql.min_message_severity = 10mssql.compatibility_mode = Offmssql.secure_connection = Off[Assertion][mbstring][gd][exif][Tidy]tidy.clean_output = Off[soap]soap.wsdl_cache_enabled=1soap.wsdl_cache_dir="/tmp"soap.wsdl_cache_ttl=86400soap.wsdl_cache_limit = 5[sysvshm][ldap]ldap.max_links = -1[mcrypt][dba][curl][root@zabbix3-server ~]# cat /etc/php-fpm.d/www.conf[www]listen = 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[error_log] = /var/log/php-fpm/www-error.logphp_admin_flag[log_errors] = onphp_value[session.save_handler] = filesphp_value[session.save_path] = /var/lib/php/sessionphp_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcacheservice php-fpm start | systemctl start php-fpm.servicechkconfig php-fpm on | systemctl enable php-fpm.service3、安装Mysql组件[percona]name = CentOS $releasever - Perconabase /centos/$releasever/os/$basearch/enabled = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-perconagpgcheck = 0yum install Percona-Server-client-56 Percona-Server-devel-56 Percona-Server-server-56 Percona-Server-shared-56 Percona-Server-shared-compat[root@zabbix3-server ~]# mysql_install_dbservice mysql start | systemctl start mysql.service[root@zabbix3-server ~]# cd /root/zabbix-3.0.5/database/mysql/[root@zabbix3-server ~]# 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;[root@zabbix3-server ~]# mysql -uroot -ptest@2016 zabbix < schema.sql[root@zabbix3-server ~]# mysql -uroot -ptest@2016 zabbix < images.sql[root@zabbix3-server ~]# mysql -uroot -ptest@2016 zabbix < data.sqlchkconfig mysql on | systemctl enable mysql.service4、安装nginx组件[aliyun-epel]name=aliyun epelbase /epel/7Server/x86_64/enabled=1gpgcheck=0yum install nginx -y[root@zabbix-server conf.d]# cat zabbix.conf server { listen 80; server_name zabbix-idc.test.cn; access_log /web/logs/zabbix.test.cn.log main; 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_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; }}mkdir /web/site/zabbix.test.cn -pmkdir /web/logs/[root@zabbix3-server zabbix-3.0.5]# pwd/root/zabbix-3.0.5[root@zabbix3-server zabbix-3.0.5]# cd frontends/php/[root@zabbix3-server php]# cp -r * /web/site/zabbix.test.cn/[root@zabbix3-server zabbix.test.cn]# pwd/web/site/zabbix.test.cn[root@zabbix3-server 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;service nginx start | systemctl start nginx.servicechkconfig nginx on | systemctl enable nginx.service5、编译安装zabbix-servercd /root/zabbix-3.0.5useradd zabbix[root@zabbix3-server zabbix-3.0.5]# ./configure --prefix=/usr/local/zabbix-3.0.5 --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2[root@zabbix3-server zabbix-3.0.5]# make [root@zabbix3-server zabbix-3.0.5]# make install[root@zabbix3-server etc]# 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[root@zabbix3-server etc]# 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[root@zabbix3-server etc]# chmod +x /etc/init.d/zabbix-server [root@zabbix3-server etc]# service zabbix-server start[root@zabbix3-server etc]# chkconfig zabbix-server on四、初始化zabbix-server1、访问zabbix-server地址2、zabbix环境检查3、zabbix数据库配置五、编译安装zabbix-agent端Server端在编译的时候,已经开启了zabbix-agent功能,不需要单独编译 [root@www zabbix-3.0.5]# cd /root/zabbix-3.0.5[root@www zabbix-3.0.5]# useradd zabbix[root@www zabbix-3.0.5]# mkdir /var/log/zabbix[root@www zabbix-3.0.5]# chown zabbix.zabbix /var/log/zabbix[root@zabbix3-server zabbix-3.0.5]# ./configure --prefix=/usr/local/zabbix-3.0/ --enable-agent[root@DB2 home]# 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[root@zabbix3-server ~]# chkconfig zabbix-agent on[root@zabbix3-server ~]# service zabbix-agent start六、安装zabbix-proxy端zabbix版本使用3.0LTS版本,需要将zabbix-proxy的主机添加到zabbix-server中,目录环境中是将IP:58.96.188.84,zabbix-agent名称为:[ ]www. [/url] 1、安装依赖环境yum groupinstall "Development tools" "Compatibility libraries" -y2、配置时钟同步echo "00 */1 * * * root /usr/sbin/ntpdate 1.cn.pool.ntp.org;hwclock -w" >> /etc/crontab3、上传安装文件[root@www ~]# lszabbix-3.0.5.tar.gz4、编译安装[root@www zabbix-3.0.5]# ./configure --prefix=/usr/local/zabbix-3.0 --with-mysql --with-net-snmp --with-libcurl --enable-agent --enable-proxy #此处开启了zabbix-agent端[root@www zabbix-3.0.5]# make && make install5、配置zabbix-proxy[root@www zabbix-3.0.5]# cd /usr/local/zabbix-3.0/etc/[root@www 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/[root@www zabbix-3.0.5]# useradd zabbix[root@www zabbix-3.0.5]# mkdir /var/log/zabbix[root@www zabbix-3.0.5]# chown zabbix.zabbix /var/log/zabbix6、添加管理脚本由于字数限制,本处略过....7、安装Mysql组件[percona]name = CentOS $releasever - Perconabase /centos/$releasever/os/$basearch/enabled = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-perconagpgcheck = 0yum install Percona-Server-client-56 Percona-Server-devel-56 Percona-Server-server-56 Percona-Server-shared-56 Percona-Server-shared-compat[root@zabbix3-server ~]# mysql_install_dbservice mysql start | systemctl start mysql.service[root@zabbix3-server ~]# cd /root/zabbix-3.0.5/database/mysql/[root@zabbix3-server ~]# 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;[root@zabbix3-server ~]# mysql -uroot -ptest@2016 zabbix < schema.sqlchkconfig mysql on | systemctl enable mysql.service8、启动zabbix-proxy[root@www etc]# chmod +x /etc/init.d/zabbix-proxy [root@www etc]# chkconfig zabbix-proxy on[root@www etc]# service zabbix-proxy start9、添加zabbix proxy节点需要将[ ]www. [/url]这个代理节点添加到zabbix中。(在proxy端开户agent,并添加主机)
登陆zabbix server端 添加proxy代理节点
10、确认proxy工作状态[root@zabbix3-server ~]# tailf /tmp/zabbix_server.log 7541:20161201:215205.923 sending configuration data to proxy "www. " at "58.96.188.84", datalen 38961 7539:20161201:220206.514 sending configuration data to proxy "www. " at "58.96.188.84", datalen 38961 7542:20161201:221206.753 sending configuration data to proxy "www. " at "58.96.188.84", datalen 38961tailf /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-魏镇坪
|