1.安装基础软件

yum install -y vim wgetlrzsz


2.关闭selinux

setenforce 0


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 | grepmysql


删除已安装的mysql yum remove 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配置文件

vim  /etc/my.cnf


[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';


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

启动apache

service httpd start


报错:

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName


处理:

编辑  /etc/httpd/conf/httpd.conf

找到ServerName www.example.com:80

修改为ServerName localhost:80


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

创建用户

groupadd zabbix

useradd -g zabbix zabbix

创建zabbix文件夹

mkdir /usr/local/zabbix

cd /usr/local/zabbix


下载zabbix3.2

wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.0/zabbix-3.2.0.tar.gz


解压  tar zxvf zabbix-3.2.0.tar.gz


进入zabbix文件数据库导入表

cd /usr/local/zabbix/zabbix-3.2.0/database/mysql

mysql -u zabbix -p zabbixzabbix

mysql -u zabbix -p zabbixzabbix

mysql -u zabbix -p zabbixzabbix


下载依赖包  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

编译安装zabbix

cd /usr/local/zabbix/zabbix-3.2.0/

./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl


make install


编译安装时会出现很多错误

error: Invalid Net-SNMP directory - unable to find net-snmp-config

yum install  net-snmp-devel

configure: error: Jabber library not found

#yum install iksemel-devel -y 即可,

configure: error: LIBXML2 library not found

#yum install libxml2-devel -y

configure: error: unixODBC library not found

#yum install unixODBC-devel -y

configure: error: Invalid OPENIPMI directory - unable to findipmiif.h

#yum install OpenIPMI-devel

configure:error: Unable to find "javac" executable in pathyum install java-devel -y

#yum install java*具体什么包没找,直接通配算逑,生产环境可去掉--enable-java选项

configure: error: Curl library not found

# yum install curl-devel -y

configure: error: SSH2 library not found

yum install -y libssh2-devel


修改zabbix_server配置文件

vim /usr/local/etc/zabbix_server.conf

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

FpingLocation=/usr/sbin/fping


创建zabbix-web页面文件夹

mkdir /var/www/html/zabbix

cd /home/zabbix/downloads/zabbix-3.2.0/frontends/php/

cp -a . /var/www/html/zabbix/


创建一个规则允许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


设置Apache用户web接口文件的所有者

chown -R apache:apache /var/www/html/zabbix

为zabbix web界面添加权限  chmod +x /var/www/html/zabbix/conf/

启动脚本

cp /usr/local/zabbix/zabbix-3.2.0/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server

cp /usr/local/zabbix/zabbix-3.2.0/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

chkconfig --add /etc/init.d/zabbix_server

chkconfig --add /etc/init.d/zabbix_agentd


启用Zabbix服务器,Apache和MySQL服务启动

chkconfig httpd on

chkconfig mysqld on

chkconfig zabbix_server on

chkconfig zabbix_agentd on


全面启动

service zabbix_server start

service zabbix_agentd start


解决前端显示中文问题

cd /var/www/html/zabbix/fonts/ 将中文字体放入 msyh.ttf


修改php配置文件  vim /var/www/html/zabbix/include/defines.inc.php define('ZBX_FONT_NAME', 'msyh');

define('ZBX_GRAPH_FONT_NAME',           'msyh'); // font file name


二、客户端安装

1、ubuntu

建立账号

    groupadd zabbix;

    useradd -g zabbix -M -s /sbin/nologin zabbix

直接apt-get install zabbix-agent

修改配置文件 vim /etc/zabbix/zabbix_agentd.conf

Server=zabbix server ip

ServerActive=zabbix server ip

Hostname=本机Ip #不要用127.0.0.1

#service zabbix-agent start

2、centOS

建立账号

groupadd zabbix;

    useradd -g zabbix -M -s /sbin/nologin zabbix

   添加对应的yum源

    rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-agent-3.2.0-1.el6.x86_64.rpm

   利用yum安装

   yum install zabbix-agent

修改配置文件 vim /etc/zabbix/zabbix_agentd.conf

Server=zabbix server ip

ServerActive=zabbix server ip