Zabbix 2.2.2 Installation update on CentOS 6.3 x86_64 May 03, 2014
# dependent on the environmentYum install-y php-mbstring mysql-devel libcurl-devel net-snmp-devel php-xml libiconv php-gd* php-bcmath php-mysql
# Download and unzip Zabbix server 2.2.2
# http://www.zabbix.com/download.php
Tar xzf zabbix-2.2.2.tar.gz
CD zabbix-2.2.2
# Add users and groups.
Groupadd Zabbix
Useradd-g Zabbix Zabbix
#
# Import the initial data into MySQL
# install MySQL server
Yum Install Mysql-server
# Execute database script with Zabbix_server (non-Zabbix proxy)
Shell> mysql-uroot-p
Mysql> CREATE database Zabbix character set UTF8;
Mysql> Grant all on zabbix.* to [e-mail protected] identified by ' db2203 ';
mysql> flush Privileges;
Mysql> quit
Shell> Mysql-uroot-p Zabbix < Database/mysql/schema.sql
# Stop here if is creating database for Zabbix Proxy
Shell> Mysql-uroot-p Zabbix < Database/mysql/images.sql
Shell> Mysql-uroot-p Zabbix < Database/mysql/data.sql
#
# Install the Zabbix server program
# Install dependent librariesYum Install libcurl-devel mysql-devel net-snmp-devel # If the Mysql-devel package is not installed, create a shortcut #cd/usr/lib64/mysql#ln-s libmysqlclient.so.18 libmysqlclient.so
# Compile Zabbix server (for MySQL)
./configure--prefix=/opt/zabbix--enable-server--enable-agent--with-mysql--disable-ipv6--WITH-NET-SNMP-- With-libcurl
Make install
#报错自行解决
# Compile Zabbix client (not required), 2.0.6 multiple OS agent on official website
./configure--enable-agent--enable-static--prefix=/opt/zabbix
# Additional settings for installing Zabbix server
# Create log directory for Zabbix server
Mkdir-p/opt/log/zabbix/
Chown Zabbix:zabbix/opt/log/zabbix
# Create PID file storage directoryMkdir/var/run/zabbix-pchown Zabbix:zabbix/var/run/zabbix
#
# Modify Server-side configuration file/opt/zabbix/etc/zabbix_server.conf
## Specify Zabbix_server log file path Logfile=/opt/log/zabbix/zabbix_server.log # Specifies the log file size (MB), which is automatically polled after the logfilesize=100 # Specify the PID file location Pidfile=/opt/run/zabbix_server.pid # Specifies that the database name is Zabbixdbname=zabbix # specifies that the database user is Zabbisuser Dbuser=zabbixuser # Specify the database password dbpasswd=xxxxxxxxxxx
# start Zabbix server/opt/zabbix/sbin/zabbix_server-c/opt/zabbix/etc/zabbix_server.conf Start No process to look at the log information/opt/log/zabbix/zabbix_server.log
# Add to bootecho "/opt/zabbix/sbin/zabbix_server-c/opt/zabbix/etc/zabbix_server.conf" >>/etc/rc.local
#错误:Run:/opt/zabbix/sbin/zabbix_server-c/opt/zabbix/etc/zabbix_server.conf/opt/zabbix/sbin/zabbix_server:error while Loading shared Libraries:libiconv.so.2:cannot Open Shared object file:no such file or directory Find/-name Libiconv. so*/usr/local/lib/libiconv.so/usr/local/lib/libiconv.so.2/usr/local/lib/libiconv.so.2.5.0 [[email protected] etc] # echo "/usr/local/lib/" >>/etc/ld.so.conf[[email protected] etc]# ldconfig
#错误2:Run:/opt/zabbix/sbin/zabbix_server-c/opt/zabbix/etc/zabbix_server.conf
/opt/zabbix/sbin/zabbix_server:error while loading shared Libraries:libmysqlclient.so.18:cannot open Shared object fil E:no such file or directory Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.16
Ldconfig
# Grant PID permission to create a file directory (no process is related to this item after startup):Mkdir/opt/run/chown-r Zabbix.zabbix/opt/run
# Install nginx+php on Zabbix server
# Install Apache version prefork, more stable (with Nginx instead)
#apt-get Install Apache2-mpm-prefork
# Install PHP
Yum install php php-gd php-gmp php-mysql php-fpm.x86_64 php-bcmath.x86_64 php-xml.x86_64 php-mbstring.x86_64 PHP-PECL-APC (PHP Accelerator module APC) #安装nginx先执行rpm-IVH http://nginx.org/packages/centos/6/noarch/RPMS/ Nginx-release-centos-6-0.el6.ngx.noarch.rpmyum Install Nginx
# Add File/etc/nginx/conf.d/zabbix.conf with the following:
server {
Listen 60080;
server_name localhost;
#charset Koi8-r;
#access_log/var/log/nginx/log/host.access.log Main;
Access_log/dev/null main;
Error_log/dev/null;
Location/{
Root/opt/website/zabbix;
Index index.html index.htm index.php;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/usr/share/nginx/html;
}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/opt/website/zabbix$fastcgi_script_name;
Include Fastcgi_params;
}
}
# and renaming default.conf in/ETC/NGINX/CONF.D
Mv/etc/nginx/conf.d/default.conf/etc/nginx/conf.d/default.conf.old
# Modify the/etc/nginx/fastcgi_params, change the server_software to the following, remove the Nginx version number display
#fastcgi_param server_software nginx/$nginx _version;
Fastcgi_param Server_software Nginx;
# Back up the nginx.conf and modify the contents of the/etc/nginx/nginx.conf:
User Nginx;
Worker_processes 1;
#error_log/var/log/nginx/error.log warn;
Error_log/dev/null;
Pid/var/run/nginx.pid;
Events {
Worker_connections 2048;
}
HTTP {
Include/etc/nginx/mime.types;
Default_type Application/octet-stream;
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";
Access_log/var/log/nginx/access.log main;
Sendfile on;
#tcp_nopush on;
Keepalive_timeout 65;
gzip on;
Server_tokens off;
include/etc/nginx/conf.d/*.conf;
}
# Modify/etc/php.ini
Post_max_size = 16M
Max_execution_time = 300
Max_input_time = 300
Time Zone=asia/shanghai (if not, modify Date.timezone =asia/shanghai) or: Date.timezone =asia/shanghai
# added to/etc/php.ini last
; PHP APC Module
Extension=apc.so
apc.enabled = 1
Apc.cache_by_default = On
Apc.shm_segments = 1
Apc.shm_size = 128
Apc.ttl = 7200
Apc.user_ttl = 7200
Apc.num_files_hint = 1024
Apc.write_lock = On
apc.gc_ttl=3600
Apc.ttl=0
#启动nginx
Service Nginx Start
#启动php-FPM
Service PHP-FPM Start
#报错自行解决
# Place the Zabbix site file under/opt/website/zabbix/
Mkdir-p/opt/website/zabbix
CP-RF frontends/php/*/opt/website/zabbix/
# first visit to perform Zabbix self-Setup program
Enter in the browser: HTTP://IP address: 60080/, this will start the Zabbix installer and follow its prompts to resolve the issue.
Default User: Admin Zabbix
Finally, if the following error occurs:
Configuration file
"/opt/website/zabbix/conf/zabbix.conf.php"
Created:fail
Need to temporarily give/opt/website/zabbix/conf/this directory to write permissions:
chmod 777/opt/website/zabbix/conf/
then retry the success and then remove the Write permission:chmod go-w/opt/website/zabbix/conf
# # SMS Interface # #客户端安装 # Download Original package wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.2/ zabbix-2.2.2.tar.gz #添加zabbix用户groupadd Zabbix useradd-g Zabbix Zabbix #安装./configure--enable-agent--prefix=/opt/ Zabbixmake Install
#修改 two parameters in/opt/zabbix/etc/zabbix_agentd.conf, others use the default
Server: Modify the IP address of the Zabbix server
Hostname: Change the machine name to native
#启动zabbix客户端
/opt/zabbix/sbin/zabbix_agentd
Start error such as:/opt/zabbix/sbin/zabbix_agentd:error while loading shared Libraries:libiconv.so.2:cannot open Shared object file : No such file or directory
Perform
#echo '/usr/local/lib ' >>/etc/ld.so.conf;ldconfig
Check that the port is started successfully
#netstat-an | grep 10050
Test the connection on the server side
/opt/zabbix/bin/zabbix_get-s 113.31.17.239-k "Agent.version"
/opt/zabbix/bin/zabbix_get-s 113.31.17.239-k "System.uptime"
/opt/zabbix/bin/zabbix_get-s 113.31.17.239-k "Net.if.in[eth0]"
Returns 2.2.2, indicating that the client has successfully started
#自启动脚本
Vi/etc/rc.d/init.d/zabbix_agentd
chmod +x/etc/rc.d/init.d/zabbix_agentd
Write the following content
#!/bin/bash
#
# Chkconfig:-55 45
# DESCRIPTION:ZABBIX_AGENTD
# Probe:false
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up. If you is running without a network, comment this out.
["${networking}" = "no"] && exit 0
Retval=0
Progdir= "/opt/zabbix/sbin/"
Prog= "Zabbix_agentd"
Start () {
# Start Daemons.
If [-N "'/sbin/pidof $prog '"]; Then
Echo-n "$prog: Already Running"
Failure $ "$prog start"
Echo
Return 1
Fi
Echo-n $ "Starting $prog:"
# we can ' t seem to use daemon here-emulate it functionality
Su-c $progdir $prog-$USER
Retval=$?
Usleep 100000
If [-Z ' '/sbin/pidof $progdir $prog ']; Then
# The child processes has died after fork () ing, e.g.
# Because of a broken config file
Retval=1
Fi
[$RETVAL-ne 0] && failure $ "$prog startup"
[$RETVAL-eq 0] && touch/var/lock/subsys/$prog && Success $ "$prog startup"
Echo
Return $RETVAL
}
Stop () {
Retval=0
Pid=
# Stop Daemons.
Echo-n $ "Stopping $prog:"
Pid= '/sbin/pidof-s $prog '
If [-N "$pid"]; Then
Kill-term $pid
Else
Failure $ "$prog Stop"
Echo
Return 1
Fi
Retval=$?
[$RETVAL-ne 0] && failure $ "$prog Stop"
[$RETVAL-eq 0] && rm-f/var/lock/subsys/$prog && Success $ "$prog Stop"
Echo
Return $RETVAL
}
Restart () {
Stop
# Wait for forked daemons
Usleep 1000000
Start
}
# See how we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart
Restart
;;
Condrestart)
[-f/var/lock/subsys/$prog] && restart
;;
*)
echo $ "Usage: $ {Start|stop|restart|condrestart}"
Exit 1
Esac
Exit $?
#测试
#chkconfig--add Zabbix_agentd
#chkconfig Zabbix_agentd on
#邮件报警设置
#安装sendmail
Yum Install Senmail
Service SendMail Start
Netstat-nalp|grep 25
#修改系统一些配置, the goal is to let the mail sent over the time to @zabbixemail.ntalker.com end. So some POP3 can receive
#修改hosts
Vi/etc/hosts
Revision changed to
127.0.0.1 zabbixemail.ntalker.com localhost
#修改
Vi/etc/mail/access
Revision changed to
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
connect:127.0.0.1
Connect:zabbixemail.ntalker.com RELAY
#修改
Vi/etc/mail/local-host-names
Add domain Name
Echo zabbixemail.ntalker.com >>
#测试sendmail环节 to determine if the server sends mail functionality properly.
Telnet 127.0.0.1 25
Or use the domain name and then email the test telnet zabbixemail.ntalker.com #收到测试邮件后到zabbix管理界面设置 "Administrator"---"Media type"-"Create media Type "Configuration"---"Actions"-"Create Actons" Acton name with baojing (random) tick recovery Message (send repair message after alarm repair) The rest can be selected by default in operations 300 seconds for 5 minutes to send messages <to> select 0 for 5-minute intervals to send messages type indicates send mode select Admin Group Select Admin user update after Save "administrator"-"Users"-select "Users" Edit admin add mail test alarm link (slightly)
--------------------------------------------------------------------------------------------------------------- -----------------------Zabbix page Chinese garbled solution: # into the Zabbix web directory FONTSCD/OPT/WEBSITE/ZABBIX/FONTS/MV Dejavusans.ttf Dejavusans.ttf_bak # Windows Control Panel \ All Control Panel items \ Font Choose your favorite fonts: Here you have selected "new song Body General" SIMSUN.TTC upload SIMSUN.TTC to/opt/website/zabbix/fon Ts/mv/opt/website/zabbix/fonts/simsun.ttc/opt/website/zabbix/fonts/dejavusans.ttf # Restart the Zabbix process to refresh the page.
Zabbix 2.2.2 Installation on the CentOS 6.3 x86_64