CentOS6.8部署zabbix 3.2.2
日期:2017-09-07
centos6.8下安装zabbix3.2
环境:两台CentOS6.8mini
server ip:192.168.231.100
client ip:192.168.231.101
1.安装基础软件
yum install -y vim wget lrzsz ntp
2.关闭selinux
setenforce 0
sed -i '/^SELINUX/s/=.*/=disabled/' /etc/selinux/config
sed -i '/^SELINUXTYPE/s/=.*/=targeted/' /etc/selinux/config
3.更换yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget http://mirrors.aliyun.com/repo/epel.repo -O /etc/yum.repos.d/epel.repo
wget http://mirrors.aliyun.com/repo/Centos-6.repo -O /etc/yum.repos.d/CentOS-Base.repo
4.安装mysql
查看已安装的mysql
yum list installed | grep mysql
删除已安装的mysql
yum remove -y mysql*
安装mysql5.6的源
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
安装mysql5.6
yum install mysql-server -y
修改mysql配置文件
[mysqld]
innodb_file_per_table
启动mysql
/etc/init.d/mysqld start
进入mysql,创建zabbix用户并授权
mysql -uroot -p
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
\q
5.安装apache、php
配置web源
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
安装apache、php
yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap ntpdate net-snmp*
修改php配置文件
vim /etc/php.ini
post_max_size=16M
max_execution_time=300
max_input_time=300
date.timezone=Asia/Shanghai
always_populate_raw_post_data=-1
sed -i '/^post_max_size/s/=.*/=16M/' /etc/php.ini
sed -i '/^max_execution_time/s/=.*/=300/' /etc/php.ini
sed -i '/^max_input_time/s/=.*/=300/' /etc/php.ini
sed -i '/;date.timezone/adate.timezone = Asia/Shanghai' /etc/php.ini
sed -i '/;always_populate_raw_post_data/aalways_populate_raw_post_data = -1' /etc/php.ini
启动apache
sed -i '/#ServerName/aServerName 127.0.0.1:80' /etc/httpd/conf/httpd.conf
service httpd start
6.调整防火墙配置
iptables -I INPUT -p tcp -m multiport --destination-port 80,10050:10051 -j ACCEPT
service iptables save
配置NTP时间
ntpdate time.windows.com
7.安装zabbix
1.)创建用户
groupadd zabbix
useradd -g zabbix zabbix
2.)下载链接:http://pan.baidu.com/s/1o8kK5oY 密码:y4tw
上传zabbix-3.2.2.tar.gz
3.)解压
tar -xf zabbix-3.2.2.tar.gz
4.)进入zabbix文件数据库导入表
cd /root/zabbix-3.2.2/database/mysql
mysql zabbix < schema.sql
mysql zabbix < images.sql
mysql zabbix < data.sql
5.)下载依赖包
yum install -y gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel fping
6.)编译安装zabbix
cd /root/zabbix-3.2.2/
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl
make && make install
7.)修改zabbix_server配置文件
sed -i '/# DBHost/aDBHost=localhost' /usr/local/zabbix/etc/zabbix_server.conf
sed -i '/^DBName/s/=.*/=zabbix/' /usr/local/zabbix/etc/zabbix_server.conf
sed -i '/^DBUser/s/=.*/=zabbix/' /usr/local/zabbix/etc/zabbix_server.conf
sed -i '/# DBPassword/aDBPassword=zabbix' /usr/local/zabbix/etc/zabbix_server.conf
sed -i '/;FpingLocation/aFpingLocation=/usr/sbin/fping' /usr/local/zabbix/etc/zabbix_server.conf
8.)移动zabbix-web文件夹并改名
cd /root/zabbix-3.2.2/frontends
mv php /var/www/html/zabbix
9.)开启selinux情况下请操作下面
创建一个规则允许web服务器访问前端文件
chcon -Rv --type=httpd_sys_content_t /var/www/html
运行Apache和zabbix访问外网
setsebool -P httpd_can_network_connect=1
setsebool -P zabbix_can_network=1
10.)设置Apache用户web接口文件的所有者
chown -R apache:apache /var/www/html/zabbix
为zabbix web界面添加权限
chmod +x /var/www/html/zabbix/conf/
11.)创建启动脚本
cp /root/zabbix-3.2.2/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
cp /root/zabbix-3.2.2/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
修改脚本
vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix
vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix
chkconfig --add /etc/init.d/zabbix_server
chkconfig --add /etc/init.d/zabbix_agentd
12.)启用Zabbix服务器,Apache和MySQL服务启动
chkconfig httpd on
chkconfig mysqld on
chkconfig zabbix_server on
chkconfig zabbix_agentd on
13.)全面启动
service zabbix_server start
service zabbix_agentd start
14.)进入web配置
http://{zabbix_ip}/zabbix
15.)zabbix客户端安装
rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm
yum install zabbix-agent -y
16.)修改配置文件
sed -i 's/Server=127.0.0.1/Server=192.168.231.101/' /etc/zabbix/zabbix_agentd.conf
grep -n '^Server=' /etc/zabbix/zabbix_agentd.conf
/etc/init.d/zabbix-agent start
chkconfig zabbix-agent on