CentOS 6.5下Zabbix3安装配置超详细教程

一.准备阶段:

#!/bin/bash

1.>关闭防火墙

echo -n "stop SELinux..."

/etc/init.d/iptables stop

setenforce 0 > /dev/null 2>&1

2.>关闭selinux

sed -i '/^SELINUX=/s/=.*/=disabled/' /etc/selinux/config && echo "OK"

vim  /etc/selinux/config

echo -n "stop iptables fire ……"

SELINUX=disabled  或者    setenforce 0

/etc/init.d/iptables stop

二.安装zabbix所需软件并配置.

echo -n "upgrate php version,默认为5.3.3的版本..."

1.安装PHP
Zabbix
3.0对PHP的要求最低为5.4,而CentOS6默认为5.3.3,完全不满足要求,故需要利用第三方源,将PHP升级到5.4以上,注意,不支持PHP7

rpm -ivh

rpm -ivh

yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring
php56w-xml php56w-ldap -y

yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring
php56w-xml php56w-ldap

sed -i "s@;date.timezone =@date.timezone = Asia/Shanghai@g" 
/etc/php.ini

vim /etc/php.ini

sed -i "s@post_max_size = 8M@post_max_size = 32M@" /etc/php.ini

date.timezone = Asia/Shanghai

sed -i "s@max_execution_time = 30@max_execution_time = 300@"
/etc/php.ini

post_max_size = 32M

sed -i "s@max_input_time = 60@max_input_time = 300@" /etc/php.ini

max_execution_time = 300

sed -i "s@;always_populate_raw_post_data =
-1@always_populate_raw_post_data = -1@" /etc/php.ini

max_input_time = 300

echo -n "升级MYSQL的版本,默认为5.1的版本"

always_populate_raw_post_data = -1

rpm -ivh

2.安装MySQL

yum install -y mysql-server mysql-devel -y

MySQL建议使用5.6版本,CentOS6默认为5.1,不建议使用,性能偏低

echo -n "正在启动mysqld服务……"

rpm -ivh

service mysqld start > /dev/null 2>&1 && echo "OK"

yum install -y mysql-server mysql-devel

echo -n "正在为mysql的root用户设置密码……"

 

mysqladmin -uroot password "123456" && echo "OK"

vim /etc/my.cnf

echo "正在执行mysql语句……"

[mysqld]

mysql -uroot -p123456 -e "CREATE DATABASE zabbix CHARACTER SET utf8
COLLATE utf8_bin;" && echo "sucess."

innodb_file_per_table                      #独立表空间模式

mysql -uroot -p123456 -e "GRANT ALL PRIVILEGES ON zabbix.* TO
zabbix@localhost IDENTIFIED BY 'zabbix';" && echo "sucess."

service mysqld start 

mysql -uroot -p123456 -e "flush privileges;"

 

echo "安装Zabbix"

mysql_secure_installation                      #MySQL安全配置向导

groupadd  -g 201  zabbix

Enter current password for root (enter for none):     
<–初次运行直接回车

useradd  -g zabbix  -u 201 -m zabbix

Set root password? [Y/n]                    <–
是否设置root用户密码,输入y并回车或直接回车

yum install httpd libxml2-devel net-snmp-devel libcurl-devel -y

Remove anonymous users? [Y/n]                  <–
是否删除匿名用户,生产环境建议删除,所以直接回车

echo -n "正在下载zabbix源码包……"

Disallow root login remotely? [Y/n]                 
<–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止

wget

Remove test database and access to it? [Y/n] 
          <– 是否删除test数据库,直接回车

echo -n "正在解压……"

Reload privilege tables now? [Y/n]                    <–
是否重新加载权限表,直接回车

tar zxvf zabbix-3.0.3.tar.gz

 

cd zabbix-3.0.3

mysql -uroot -p

/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql

mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;

/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql

mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost
IDENTIFIED BY 'zabbix';

/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

mysql> flush privileges; 

./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/
--enable-server --enable-agent --with-net-snmp --with-libcurl
--with-mysql --with-libxml2

mysql> show databases; 

make &&make install

+--------------------+   

| Database          |   

+--------------------+   

| information_schema |   

| mysql              |   

| performance_schema |   

| zabbix            |   

+--------------------+

3.安装Zabbix

yum install httpd libxml2-devel net-snmp-devel libcurl-devel

groupadd  -g 201  zabbix

useradd  -g zabbix  -u 201 -m zabbix

wget

tar zxvf zabbix-3.0.3.tar.gz

cd zabbix-3.0.3

/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql

/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql

/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

 

./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/
--enable-server --enable-agent --with-net-snmp --with-libcurl
--with-mysql --with-libxml2

make &&make install

编译 zabbix 如果报下面错误,就做以下操作

报错信息:configure: error: Not found mysqlclient library

#find / -name libmysqlclient*

ln -s /usr/lib64/mysql/libmysqlclient.so.18.1.0
/usr/lib64/mysql/libmysqlclient.so

ln -s /usr/lib64/mysql/libmysqlclient_r.so.18.1.0
/usr/lib64/mysql/libmysqlclient_r.so 

4.配置Zabbix

相关文章

Comment ()
评论是一种美德,说点什么吧,否则我会恨你的。。。