编者按:
最近公司部分业务迁移机房,为了更方便的监控管理主机资源,决定上线zabbix监控平台。运维人员使用2.4版本的进行部署,个人在业余时间尝鲜,使用zabbix3.0进行部署,整理文档如下,仅供参考!
一、系统环境准备:
centos6.8最小化安装环境
1.防火墙
1 关闭selinux: 2 查看SELinux状态: 3 1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态 4 SELinux status: enabled 5 2、getenforce ##也可以用这个命令检查 6 关闭SELinux: 7 1、临时关闭(不用重启机器): 8 setenforce 0 ##设置SELinux 成为permissive模式 9 ##setenforce 1 设置SELinux 成为enforcing模式 10 2、修改配置文件需要重启机器: 11 修改/etc/selinux/config 文件 12 将SELINUX=enforcing改为SELINUX=disabled 13 重启机器即可 14 关闭iptables或开放相关端口(80): 15 service iptables stop
2.安装yum源
1 rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm 2 rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm 3 vim /etc/yum.repos.d/rpmforge.repo #rpmforge国内源 4 ### Name: RPMforge RPM Repository for RHEL 6 - dag 5 ### URL: http://rpmforge.net/ 6 [rpmforge] 7 name = RHEL $releasever - RPMforge.net - dag 8 baseurl = http://mirror.bjtu.edu.cn/repoforge/redhat/el6/en/$basearch/rpmforge 9 mirrorlist = http://mirror.bjtu.edu.cn/repoforge/redhat/el6/en/mirrors-rpmforge 10 #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge 11 enabled = 1 12 protect = 0 13 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag 14 gpgcheck = 0 15 rpm -Uvh http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm #mysql5.6 5.7 安装源
3.依赖包更新安装:
1 yum update && 2 yum -y install gcc gcc-c++ vim tree make cmake autoconf 3 openssl openssl-devel openssl-clients curl curl-devel 4 wget rsync expect readline readline-devel bison bison-devel 5 pcre pcre-devel zlib-devel zlib freetype freetype-devel man 6 lrzsz tar iostat bc zip unzip lvm2 sysstat
二、server端部署:
1.LNMP平台构建:
1)nginx-1.10.1稳定版本编译安装:
1 下载源码包: 2 wget -P /usr/local/src http://nginx.org/download/nginx-1.10.1.tar.gz 3 依赖环境: 4 yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel gd-* 5 创建nginx用户及用户组并设置不允许登录系统: 6 groupadd -r nginx && useradd -s /sbin/nologin -g nginx -r nginx 7 编译安装: 8 ./configure --prefix=/usr/local/nginx --lock-path=/usr/local/ 9 nginx/nginx.lock --user=nginx --group=nginx 10 --with-http_ssl_module --with-http_flv_module 11 --with-http_stub_status_module --with-http_gzip_static_module 12 --http-client-body-temp-path=/usr/local/nginx/client/ 13 --http-proxy-temp-path=/usr/local/nginx/proxy/ 14 --http-fastcgi-temp-path=/usr/local/nginx/fcgi/ 15 --http-uwsgi-temp-path=/usr/local/nginx/uwsgi 16 --http-scgi-temp-path=/usr/local/nginx/scgi --with-pcre 17 --with-file-aio --with-http_image_filter_module && 18 make && make install
1 #!/bin/bash 2 # 3 # Startup script for Nginx - this script starts and stops the nginx daemon 4 # 5 # chkconfig: - 85 15 6 # description: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server 7 # processname: nginx 8 # config: /usr/local/nginx/conf/nginx.conf 9 # pidfile: /usr/local/nginx/logs/nginx.pid 10 # Source function library. 11 . /etc/rc.d/init.d/functions 12 13 # Source networking configuration. 14 . /etc/sysconfig/network 15 16 # Check that networking is up. 17 [ "$NETWORKING" = "no" ] && exit 0 18 19 nginx="/usr/local/nginx/sbin/nginx" 20 prog=$(basename $nginx) 21 22 NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" 23 24 [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx 25 26 lockfile=/var/lock/subsys/nginx 27 28 start() { 29 [ -x $nginx ] || exit 5 30 [ -f $NGINX_CONF_FILE ] || exit 6 31 echo -n $"Starting $prog: " 32 daemon $nginx -c $NGINX_CONF_FILE 33 retval=$? 34 echo 35 [ $retval -eq 0 ] && touch $lockfile 36 return $retval 37 } 38 39 stop() { 40 echo -n $"Stopping $prog: " 41 killproc $prog -QUIT 42 retval=$? 43 echo 44 [ $retval -eq 0 ] && rm -f $lockfile 45 return $retval 46 } 47 48 restart() { 49 configtest || return $? 50 stop 51 sleep 1 52 start 53 } 54 55 reload() { 56 configtest || return $? 57 echo -n $"Reloading $prog: " 58 killproc $nginx -HUP 59 RETVAL=$? 60 echo 61 } 62 63 force_reload() { 64 restart 65 } 66 67 configtest() { 68 $nginx -t -c $NGINX_CONF_FILE 69 } 70 71 rh_status() { 72 status $prog 73 } 74 75 rh_status_q() { 76 rh_status >/dev/null 2>&1 77 } 78 79 case "$1" in 80 start) 81 rh_status_q && exit 0 82 $1 83 ;; 84 stop) 85 rh_status_q || exit 0 86 $1 87 ;; 88 restart|configtest) 89 $1 90 ;; 91 reload) 92 rh_status_q || exit 7 93 $1 94 ;; 95 force-reload) 96 force_reload 97 ;; 98 status) 99 rh_status 100 ;; 101 condrestart|try-restart) 102 rh_status_q || exit 0 103 ;; 104 *) 105 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" 106 exit 2 107 esac
1 user nginx; 2 worker_processes 2; 3 #error_log logs/error.log; 4 #error_log logs/error.log notice; 5 error_log logs/error.log info; 6 pid logs/nginx.pid; 7 worker_rlimit_nofile 1024; 8 events { 9 use epoll; 10 worker_connections 1024; 11 } 12 http { 13 include mime.types; 14 default_type application/octet-stream; 15 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 16 '$status $body_bytes_sent "$http_referer" ' 17 '"$http_user_agent" "$http_x_forwarded_for"'; 18 access_log logs/access.log main; 19 sendfile on; 20 tcp_nopush on; 21 keepalive_timeout 65; 22 gzip on; 23 server { 24 listen 80; 25 server_name localhost; 26 charset utf-8; 27 #access_log logs/access.log main; 28 location / { 29 root html; 30 index index.html index.htm index.php; 31 } 32 error_page 404 /404.html; 33 error_page 500 502 503 504 /50x.html; 34 location = /50x.html { 35 root html; 36 } 37 location ~ ^(.+.php)(.*)$ { 38 allow 192.168.137.1; 39 deny all; 40 fastcgi_split_path_info ^(.+.php)(.*)$; 41 include fastcgi.conf; 42 fastcgi_pass 127.0.0.1:9000; 43 fastcgi_index index.php; 44 fastcgi_param PATH_INFO $fastcgi_path_info; 45 } 46 }
2)mysql-5.6.32编译安装:
1 依赖环境: 2 yum install wget gcc* make openssl openssl-devel openssl-clients ncurses-devel -y 3 创建用户名/群组: 4 groupadd -r mysql && useradd -s /sbin/nologin -g mysql -r mysql 5 创建mysql数据存储路径: 6 mkdir -p /home/mysql/data && mkdir -p /home/mysql/var/log && chown -R mysql:mysql /home/mysql/ 7 下载源码包: 8 wget -P /usr/local/src http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.32.tar.gz 9 wget -P /home/mysql http://120.52.73.48/jaist.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz 10 编译安装: 11 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 12 -DMYSQL_DATADIR=/home/mysql/data 13 -DSYSCONFDIR=/etc 14 -DWITH_INNOBASE_STORAGE_ENGINE=1 15 -DWITH_ARCHIVE_STORAGE_ENGINE=1 16 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 17 -DWITH_READLINE=1 18 -DWITH_SSL=system 19 -DWITH_ZLIB=system 20 -DWITH_LIBWRAP=0 21 -DMYSQL_UNIX_ADDR=/home/mysql/var/mysql.sock 22 -DDEFAULT_CHARSET=utf8 23 -DDEFAULT_COLLATION=utf8_general_ci 24 -DMYSQL_TCP_PORT=3306 25 -DWITH_BOOST=/home/mysql/boost_1_59_0.tar.gz && 26 make && make install 27 数据库初始化: 28 /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql/data --user=mysql --default-storage-engine=MyISAM
1 [client] 2 default-character-set=utf8 3 auto-rehash 4 socket = /home/mysql/var/mysql.sock 5 [mysqld] 6 datadir=/home/mysql/data 7 socket=/home/mysql/var/mysql.sock 8 user=mysql 9 port = 33080 10 skip-name-resolve 11 slow-query-log 12 long_query_time = 6 13 character-set-server=utf8 14 log-error=/home/mysql/var/log/mysqld.log 15 pid-file=/home/mysql/var/mysqld.pid 16 # Disabling symbolic-links is recommended to prevent assorted security risks 17 symbolic-links=0 18 [mysqld_safe] 19 log-error=/home/mysql/var/log/mysqld.log 20 pid-file=/home/mysql/var/mysqld.pid
1 cp /usr/local/src/mysql-5.6.32/support-files/mysql.server /etc/init.d/mysql 2 chmod +x /etc/init.d/mysql && chkconfig mysql on
1 echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib" >> /etc/profile 2 source /etc/profile
1 mysqladmin -u root password "test123"
3)php-5.6编译安装:
1 yum -y install zlib-devel libxml2 libxml2-devel libjpeg-devel 2 libiconv-devel freetype-devel libpng-devel gd gd-devel 3 openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel 4 mhash mcrypt bzip2-devel bzip2 ncurses-devel
1 wget -P /usr/local/src http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz 2 ./configure --prefix=/usr/local/libiconv && make && make install 3 echo "/usr/local/mysql/lib" >> /etc/ld.so.conf && /sbin/ldconfig
1 wget -P /usr/local/src http://cn2.php.net/distributions/php-5.6.24.tar.gz
1 ./configure 2 --prefix=/usr/local/php 3 --with-config-file-path=/usr/local/php/etc 4 --with-mysql=/usr/local/mysql/ 5 --with-mysqli=mysqlnd 6 --with-pdo-mysql=mysqlnd 7 --with-iconv-dir=/usr/local/libiconv 8 --with-freetype-dir 9 --with-bz2 10 --with-jpeg-dir 11 --with-png-dir 12 --with-zlib 13 --with-libxml-dir=/usr 14 --with-xmlwriter-dir=/usr 15 --with-xmlreader-dir=/usr 16 --with-libdir=lib 17 --with-gettext 18 --enable-xml 19 --disable-rpath 20 --enable-bcmath 21 --enable-shmop 22 --enable-sysvsem 23 --enable-inline-optimization 24 --with-curl 25 --enable-mbregex 26 --enable-fpm 27 --enable-mbstring 28 --with-mcrypt 29 --with-gd 30 --enable-gd-native-ttf 31 --with-openssl 32 --with-mhash 33 --enable-pcntl 34 --enable-sockets 35 --with-xmlrpc 36 --enable-soap 37 --enable-short-tags 38 --enable-static 39 --with-xsl 40 --with-fpm-user=nginx 41 --with-fpm-group=nginx 42 --enable-ftp 43 --enable-opcache=no && make && make install
1 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 2 cp /usr/local/src/php-5.6.24/php.ini-production /usr/local/php/etc/php.ini 3 sed -i 's/post_max_size = 8M/post_max_size = 16M/' /usr/local/php/etc/php.ini 4 sed -i 's/max_execution_time = 30/max_execution_time = 300/' /usr/local/php/etc/php.ini 5 sed -i 's/max_input_time = 60/max_input_time = 300/' /usr/local/php/etc/php.ini 6 sed -i 's/;date.timezone =/date.timezone = Asia/Shanghai/' /usr/local/php/etc/php.ini 7 sed -i 's/mysqli.default_port = 3306/mysqli.default_port = 33070/' /usr/local/php/etc/php.ini 8 sed -i 's/mysqli.default_socket =/& /home/mysql/var/mysql.sock/' /usr/local/php/etc/php.ini 9 sed -i 's/mysqli.default_host =/& localhost/' /usr/local/php/etc/php.ini 10 sed -i 's/mysqli.default_user =/& zabbix/' /usr/local/php/etc/php.ini 11 sed -i 's/;always_populate_raw_post_data = -1/always_populate_raw_post_data = -1/' /usr/local/php/etc/php.ini
1 #!/bin/sh 2 # DateTime: 2013-09-16 3 # Author: lianbaikai 4 # site:http://www.ttlsa.com/html/3039.html 5 # chkconfig: - 84 16 6 # Source function library. 7 . /etc/rc.d/init.d/functions 8 9 # Source networking configuration. 10 . /etc/sysconfig/network 11 12 # Check that networking is up. 13 [ "$NETWORKING" = "no" ] && exit 0 14 15 phpfpm="/usr/local/php/sbin/php-fpm" 16 prog=$(basename ${phpfpm}) 17 18 lockfile=/var/lock/subsys/phpfpm 19 20 start() { 21 [ -x ${phpfpm} ] || exit 5 22 echo -n $"Starting $prog: " 23 daemon ${phpfpm} 24 retval=$? 25 echo 26 [ $retval -eq 0 ] && touch $lockfile 27 return $retval 28 } 29 30 stop() { 31 echo -n $"Stopping $prog: " 32 killproc $prog -QUIT 33 retval=$? 34 echo 35 [ $retval -eq 0 ] && rm -f $lockfile 36 return $retval 37 } 38 39 restart() { 40 configtest || return $? 41 stop 42 start 43 } 44 45 reload() { 46 configtest || return $? 47 echo -n $"Reloading $prog: " 48 killproc ${phpfpm} -HUP 49 RETVAL=$? 50 echo 51 } 52 53 force_reload() { 54 restart 55 } 56 57 configtest() { 58 ${phpfpm} -t 59 } 60 61 rh_status() { 62 status $prog 63 } 64 65 rh_status_q() { 66 rh_status >/dev/null 2>&1 67 } 68 69 case "$1" in 70 start) 71 rh_status_q && exit 0 72 $1 73 ;; 74 stop) 75 rh_status_q || exit 0 76 $1 77 ;; 78 restart|configtest) 79 $1 80 ;; 81 reload) 82 rh_status_q || exit 7 83 $1 84 ;; 85 status) 86 rh_status 87 ;; 88 *) 89 echo $"Usage: $0 {start|stop|status|restart|reload|configtest}" 90 exit 2 91 esac
2.zabbix-server安装:
1 wget -P /usr/local/src http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz
1 groupadd -r zabbix && useradd -s /sbin/nologin -g zabbix -r zabbix
1 ./configure --prefix=/usr/local/zabbix/ --enable-server 2 --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config 3 --with-net-snmp --with-libcurl 4 --with-libxml2 --enable-proxy --enable-snmp --with-mbstring && 5 make && make install
1 cp /usr/local/src/zabbix-3.0.4/misc/init.d/fedora/core5/zabbix_* /etc/init.d/ 2 sed -i 's/ZABBIX_BIN="/usr/local//&zabbix//' zabbix_server 3 sed -i 's/ZABBIX_BIN="/usr/local//&zabbix//' zabbix_agentd
1 $mysql -uroot -p 2 mysql>create database zabbix default charset utf8; 3 mysql>GRANT ALL PRIVILEGES ON *.* TO zabbix@'localhost' IDENTIFIED BY 'test123' WITH GRANT OPTION; 4 mysql>FLUSH PRIVILEGES; 5 mysql>exit; 6 $mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.4/database/mysql/schema.sql 7 $mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.4/database/mysql/images.sql 8 $mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.4/database/mysql/data.sql
1 cp -fr /usr/local/src/zabbix-3.0.4/frontends/php /usr/local/nginx/html/zabbix 2 ln -s /usr/local/mysql/lib/libmysqlclient* /lib64/
1 vim /usr/local/zabbix/etc/zabbix_server.conf 2 DBName=zabbix 3 DBUser=zabbix 4 DBPassword=test123 5 DBPort=33080
1 复制华文楷体字体文件(simkai.ttf) /usr/local/nginx/html/zabbix/fonts 2 sed -i 's/DejaVuSans/simkai/g' /usr/local/nginx/html/zabbix/include/defines.inc.php
1 service zabbix_server start 2 service php-fpm start 3 service mysql start 4 service nginx start 5 web访问192.168.137.8/zabbix 6 dbhost localhost 7 dbname zabbix 8 dbuser zabbix 9 dbpasswd test123
三、代理端部署:
四、客户端部署:
【原文】centos6.5编译安装zabbix3.0和中文支持整理文档
1. LNMP基础环境搭建:
nginx-1.9.11环境编译安装:参考 http://www.cnblogs.com/songqingbo/articles/5355025.html
location / { root html; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ .(php|php5)?$ { root /usr/local/nginx/html/zabbix; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; }
mysql-5.6.20编译安装:参考 http://www.cnblogs.com/songqingbo/articles/5355025.html
php-5.6编译安装:
依赖环境
1.yum -y install zlib-devel libxml2-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel 2.wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar zxf libiconv-1.14.tar.gz && cd libiconv-1.14 && ./configure --prefix=/usr/local/libiconv && make && make install && cd ../ 3.yum -y install libmcrypt-devel mhash mcrypt
编译安装:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-bz2 --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-xmlwriter-dir=/usr --with-xmlreader-dir=/usr --with-libdir=lib64 --with-gettext --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --enable-opcache=no
make && make install
配置php配置文件:
vim /application/php/lib/php.ini 主要为下面几个参数 PHP option post_max_size 16M PHP option max_execution_time 300 PHP option max_input_time 300 PHP time zone Asia/Shanghai
配置启动脚本: /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm && chkconfig php-fpm on
#!/bin/sh # DateTime: 2013-09-16 # Author: lianbaikai # site:http://www.ttlsa.com/html/3039.html # chkconfig: - 84 16 # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 phpfpm="/usr/local/php/sbin/php-fpm" prog=$(basename ${phpfpm}) lockfile=/var/lock/subsys/phpfpm start() { [ -x ${phpfpm} ] || exit 5 echo -n $"Starting $prog: " daemon ${phpfpm} retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc ${phpfpm} -HUP RETVAL=$? echo } force_reload() { restart } configtest() { ${phpfpm} -t } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; status) rh_status ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|configtest}" exit 2 esac
2. 编译安装zabbix_server
源码包下载
cd /usr/local/src && wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.0/zabbix-3.0.0.tar.gz
依赖环境
yum install net-snmp-devel OpenIPMI-devel openssl-devel fping-devel libcurl-devel perl-DBI gcc -y
添加用户
mkdir -p /usr/local/zabbix3.0/lib/ useradd -d /usr/local/zabbix3.0/lib/zabbix -s /sbin/nologin zabbix
编译安装
./configure --prefix=/usr/local/zabbix3.0 --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp--with-libcurl --with-libxml2 && make install
权限
chown –R zabbix.zabbix /usr/local/zabbix3.0
增加端口
vim /etc/services zabbix-agent 10050/tcp # Zabbix Agent zabbix-agent 10050/udp # Zabbix Agent zabbix-trapper 10051/tcp # Zabbix Trapper zabbix-trapper 10051/udp # Zabbix Trapper
数据库初始化
mysql> create database zabbix characterset utf8; mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbixtest' with grant option; mysql> flush privileges; mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.0/database/mysql/schema.sql mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.0/database/mysql/images.sql mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.0/database/mysql/data.sql
配置文件识别:/usr/local/zabbix3.0/etc/zabbix_server.conf zabbix_agentd.conf
配置启动脚本:
zabbix_server
#!/bin/bash # # /etc/rc.d/init.d/zabbix_server # # Starts the zabbix_server daemon # # chkconfig: - 95 5 # description: Zabbix Monitoring Server # processname: zabbix_server # pidfile: /tmp/zabbix_server.pid # Modified for Zabbix 2.0.0 # May 2012, Zabbix SIA # Source function library. . /etc/init.d/functions RETVAL=0 prog="Zabbix Server" ZABBIX_BIN="/usr/local/zabbix3.0/sbin/zabbix_server" if [ ! -x ${ZABBIX_BIN} ] ; then echo -n "${ZABBIX_BIN} not installed! " # Tell the user this has skipped exit 5 fi start() { echo -n $"Starting $prog: " daemon $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_server echo } stop() { echo -n $"Stopping $prog: " killproc $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_server echo } case "$1" in start) start ;; stop) stop ;; reload|restart) stop sleep 10 start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/zabbix_server ]; then stop start fi ;; status) status $ZABBIX_BIN RETVAL=$? ;; *) echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}" exit 1 esac exit $RETVAL
zabbix_agentd
#!/bin/bash # # /etc/rc.d/init.d/zabbix_agentd # # Starts the zabbix_agentd daemon # # chkconfig: - 95 5 # description: Zabbix Monitoring Agent # processname: zabbix_agentd # pidfile: /tmp/zabbix_agentd.pid # Modified for Zabbix 2.0.0 # May 2012, Zabbix SIA # Source function library. . /etc/init.d/functions RETVAL=0 prog="Zabbix Agent" ZABBIX_BIN="/usr/local/zabbix3.0/sbin/zabbix_agentd" if [ ! -x ${ZABBIX_BIN} ] ; then echo -n "${ZABBIX_BIN} not installed! " # Tell the user this has skipped exit 5 fi start() { echo -n $"Starting $prog: " daemon $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentd echo } stop() { echo -n $"Stopping $prog: " killproc $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_agentd echo } case "$1" in start) start ;; stop) stop ;; reload|restart) stop sleep 10 start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/zabbix_agentd ]; then stop start fi ;; status) status $ZABBIX_BIN RETVAL=$? ;; *) echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}" exit 1 esac exit $RETVAL
其他相关配置参考:
http://www.tuicool.com/articles/JRVVniM http://www.mamicode.com/info-detail-1223031.html http://www.360doc.com/content/14/0330/19/8085797_364996162.shtml
配置中文支持参考:http://www.ttlsa.com/zabbix/zabbix-display-chinese/
3.zabbix_proxy安装配置:
编译安装同server,增加一个新的参数--enable-proxy
zabbix_proxy启动脚本
#!/bin/sh # chkconfig: 345 95 95 # desctription: Zabbix Proxy # Zabbix # Copyright (C) 2001-2013 Zabbix SIA # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Start/Stop the Zabbix agent daemon. # Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d SERVICE="Zabbix proxy" DAEMON=/usr/local/zabbix3.0/sbin/zabbix_proxy PIDFILE=/tmp/zabbix_agentd.pid BASEDIR=/usr/local/zabbix3.0 ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_proxy case $1 in 'start') if [ -x ${DAEMON} ] then $DAEMON # Error checking here would be good... echo "${SERVICE} started." else echo "Can't find file ${DAEMON}." echo "${SERVICE} NOT started." fi ;; 'stop') if [ -s ${PIDFILE} ] then if kill `cat ${PIDFILE}` >/dev/null 2>&1 then echo "${SERVICE} terminated." rm -f ${PIDFILE} fi fi ;; 'restart') $0 stop sleep 10 $0 start ;; *) echo "Usage: $0 start|stop|restart" ;; esac
相关详细配置请参考:
http://www.2cto.com/os/201401/273888.html
http://www.tuicool.com/articles/zMZrUjU
http://blog.chinaunix.net/uid-23500957-id-4919835.html
4.常见问题汇总:
Error connecting to database: No such file or directory
解决办法:http://www.bubuko.com/infodetail-1149825.html
Zabbix 中文汉化及出现乱码解决办法
解决办法:http://www.linuxidc.com/Linux/2015-05/117208.htm
5.监控平台接入
http://www.onealert.com/open/alert/overview.jsp
6.zabbix编译安装自动化脚本:
http://www.dwhd.org/20150519_162243.html