zabbix 服务器
安装Mysql数据库、Apache、PHP、PHP扩展、curl组件
rpm -qa | grep epel-release && yum remove epel-release -y
yum install mysql* httpd* php* php-gd php-bcmath php-common php-xml php-mbstring curl curl-devel -y
安装YUM源
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
安装zabbix服务器专用依赖组件
yum install OpenIPMI* ipmitool* libssh2* fping* libcurl* iksemel* net-snmp* -y
关闭SELINUX
设置:SELINUX=disabled
sed -r -i '/^[ \t]*SELINUX=.*/c SELINUX=disabled' /etc/selinux/config
重启生效(不重启mysql可能启动失败)
配置:Apache、Mysql
配置:Apache
test -f /etc/httpd/conf/httpd.conf.bak || \cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
sed -r -i '/(^[ \t]*#|^[ \t]*$)/d' /etc/httpd/conf/httpd.conf
grep -E "^[ \t]*ServerName " /etc/httpd/conf/httpd.conf && y="1" || y="0"
if [ ${y} = "1" ]; then
sed -r -i '/^[ \t]*ServerName[ \t]*.*/c ServerName '"${HOSTNAME}"':9000' /etc/httpd/conf/httpd.conf
else
sed -r -i "1i ServerName "${HOSTNAME}":9000" /etc/httpd/conf/httpd.conf
fi
cat /etc/httpd/conf/httpd.conf
chkconfig httpd on
service httpd restart
配置IPtables
service iptables restart
iptables -D INPUT -p tcp --dport 9000 -j ACCEPT
iptables -I INPUT -p tcp --dport 9000 -j ACCEPT
service iptables save
iptables -L
配置:MySQL
mkdir -p /zabbix/mysqldb
vi /etc/my.cnf
设置:
datadir=/zabbix/mysqldb
max_connections=1000
关闭mysql
service mysqld stop
mysql_install_db
初始化启动Mysql数据库
chkconfig mysqld on
service mysqld start
设置MySQL的root管理员账户的密码
mysqladmin -u root password 'a123456'
创建zabbix数据库
mysql -u root -p
mysql> show variables like '%datadir%';
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'a123456';
mysql> FLUSH PRIVILEGES;
mysql> quit
安装zabbix中心服务器组件
Yum安装
yum install zabbix-server-mysql zabbix-web-mysql -y
zabbix_server -V
Zabbix server v2.4.8 (revision 59539) (20 April 2016)
Compilation time: May 4 2016 01:32:12
为zabbix中心服务器创建:数据库架构和表结构
find / -name zabbix-server-mysql\*
mysql -u zabbix --password=a123456 -D zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql
mysql -u zabbix --password=a123456 -D zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
mysql -u zabbix --password=a123456 -D zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
mysql -u zabbix --password=a123456 -D zabbix
mysql> select database();
mysql> show tables;
修改配置文件
test -f /etc/zabbix/zabbix_server.conf.bak || cp -f /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak
cat >/etc/zabbix/zabbix_server.conf<<EOF
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBPort=3306
DBName=zabbix
DBUser=zabbix
DBPassword=a123456
ListenPort=10051
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
## 如果需要监控VMware ESXi服务器平台,就需要添加以下参数
StartVMwareCollectors=10
VMwareFrequency=60
VMwarePerfFrequency=60
VMwareCacheSize=80M
VMwareTimeout=10
## 配置<查询信息>和<接收信息>的进程数
StartPollers=200
StartTrappers=200
EOF
启动:zabbix-server服务
chkconfig zabbix-server on
service zabbix-server start
netstat -tunlp | grep zabbix
配置:zabbix的Web前端
cat >/etc/httpd/conf.d/zabbix.conf<<EOF
# Zabbix monitoring system php web frontend
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
## 设置:时区的设置,必须启用,注意:区分大小写
php_value date.timezone Asia/Shanghai
</Directory>
<Directory "/usr/share/zabbix/conf">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/api">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/include">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/include/classes">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
EOF
重启启动:Apache的httpd服务
service httpd restart
访问:zabbix的Web安装页面
http://zabbix.one.com/zabbix
配置自动探索和自动注册
Paste_Image.png自动探索配置
Paste_Image.png Paste_Image.png Paste_Image.png Paste_Image.png自动注册
安装zabbix-agent
下载并安装:zabbix的yum源,然后,yum安装zabbix-agent客户端代理
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
yum install -y zabbix-agent
test -f /etc/zabbix/zabbix_agentd.conf.bak || cp -f /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak
sed -r -i '/(^[ \t]*#|^[ \t]*$)/d' /etc/zabbix/zabbix_agentd.conf
zabbix_server_ip="192.168.30.11"
zabbix_server_hostname=${HOSTNAME}
cat >/etc/zabbix/zabbix_agentd.conf<<EOF
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=${zabbix_server_ip}
ServerActive=${zabbix_server_ip}:10051
Hostname=${zabbix_server_hostname}
ListenPort=10050
HostMetadata=all
Include=/etc/zabbix/zabbix_agentd.d/
EOF
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
service iptables save
service iptables restart
修改客户机配置文件
test -f /etc/zabbix/zabbix_agentd.conf.bak || cp -f /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak
sed -r -i '/(^[ \t]*#|^[ \t]*$)/d' /etc/zabbix/zabbix_agentd.conf
zabbix_server_ip="192.168.30.11"
zabbix_server_hostname=${HOSTNAME}
cat >/etc/zabbix/zabbix_agentd.conf<<EOF
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=${zabbix_server_ip}
ServerActive=${zabbix_server_ip}:10051
Hostname=${zabbix_server_hostname}
ListenPort=10050
HostMetadata=all
Include=/etc/zabbix/zabbix_agentd.d/
EOF
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
service iptables save
service iptables restart
网友评论