ZABBIX-3.0.4 版本安装

目录

安装环境
        系统环境:CentOS release 6.5 64位(能上外网)
        IP地址:192.168.127.134
安装准备
        关闭防火墙
            1.即时生效,重启后失效
            2.重启后生效
        关闭selinux
            1.即时生效,重启后失效
            2.永久关闭(重启服务器生效)
依赖安装(LAMP)
        前提
        Apache安装
            1.yum安装apache
            2.安装apache 一些扩展
            3.修改apache配置
            4.开机自启动
            5.启httpd 服务
        Mysql安装
            1.下载Linux对应的RPM包
            2.检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称)
            3.安装MySQL
            4.修改配置文件位置
            5.修改mysql配置文件/etc/my.cnf,在[mysqld]中添加innodb_file_per_table=1
            6.启动mysql
            7.初始化MySQL及设置密码
            8.配置zabbix数据库和用户名(zabbix)以及密码(zabbix)
        PHP安装
            1.添加 yum 源
            2.安装 PHP
            3.修改php配置
            4.检查
zabbix安装
            1.创建zabbix用户
            2.依赖包安装
            3.下载zabbix安装包、解压
            4.解压到/usr/local/src目录下
            5.将zabbix的初始数据导入到数据库中
            6.安装
            7.修改zabbix_server的配置
            8.创建一个新的web前端文件
            9.设置Apache作为Web用户接口文件的所有者
            10.添加权限给Zabbix Web界面执行文件
            11.添加Zabbix服务器和Zabbix代理启动脚本
            12.添加Zabbix服务器和Zabbix代理服务
            13.启动zabbix_server
            14.web界面安装
    备注

这篇文章记录了在centos-6.5上安装zabbix-3.0.4的过程。

安装环境

系统环境:CentOS release 6.5 64位(能上外网)

[root@localhost ~]# cat /etc/issue
CentOS release 6.5 (Final)
[root@localhost ~]# getconf LONG_BIT
64

IP地址:192.168.127.134

[root@localhost ~]# ifconfig | grep 'inet addr'
          inet addr:192.168.127.134  Bcast:192.168.127.255  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0

安装准备

关闭防火墙

1.即时生效,重启后失效
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
2.重启后生效
[root@localhost ~]# chkconfig iptables off

关闭selinux

1.即时生效,重启后失效
#由于之前已经关闭过,所以这里显示已经关闭
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
2.永久关闭(重启服务器生效)
#修改/etc/selinux/config文件 设置SELINUX=disabled 
#修改之后如下
[root@localhost ~]# cat /etc/selinux/config | grep 'SELINUX='
# SELINUX= can take one of these three values:
SELINUX=disabled

依赖安装(LAMP)

前提

1.zabbix安装需要LNMP或者LAMP环境,这里安装LAMP环境

2.zabbix3.x需要mysql5.6或者以上版本

3.zabbix3.x需要PHP是至少5.4或更高版本

Apache安装

1.yum安装apache
yum -y install httpd
2.安装apache 一些扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
3.修改apache配置
#打开配置文件找到ServerName改成127.0.0.1
 vim /etc/httpd/conf/httpd.conf
 ServerName 127.0.0.1
4.开机自启动
chkconfig httpd on
5.启httpd 服务
service httpd start

Mysql安装

由于centos6.5自带的yum源的mysql版本过低,所以需要下载相关的rpm包。

mysql分为开发版本和稳定版本(GA),开发版本拥有最新的特性,但是并不稳定,也没有完全经过测试,可能存在严重的bug,而稳定版本是经过了长时间的测试,消除了具有已知的bug,其稳定性和安全性都得到一定的保障。

1.下载Linux对应的RPM包,下载地址https://dev.mysql.com/downloads/mysql/5.6.html

具体的选择如下:

ZABBIX-3.0.4 版本安装_第1张图片
搜狗截图20170929105450.png

需要下载的rpm包如下:

[root@localhost src]# ls M*
MySQL-client-5.6.37-1.el6.x86_64.rpm  
MySQL-server-5.6.37-1.el6.x86_64.rpm  
MySQL-shared-compat-5.6.37-1.el6.x86_64.rpm
MySQL-devel-5.6.37-1.el6.x86_64.rpm   
MySQL-shared-5.6.37-1.el6.x86_64.rpm
2.检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称)
rpm -qa | grep -i mysql
3.安装MySQL

安装可能会出现的报错

[root@localhost src]# rpm -ivh MySQL-server-5.6.37-1.el6.x86_64.rpm 
warning: MySQL-server-5.6.37-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
    libaio.so.1()(64bit) is needed by MySQL-server-5.6.37-1.el6.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.37-1.el6.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.37-1.el6.x86_64
    libnuma.so.1()(64bit) is needed by MySQL-server-5.6.37-1.el6.x86_64
    libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.37-1.el6.x86_64
    libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.37-1.el6.x86_64

解决方法:

yum -y install libaio*
yum -y install numactl

正常安装如下:

rpm -ivh MySQL-server-5.6.37-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.37-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.37-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.37-1.el6.x86_64.rpm
#需要注意的是 下面这个不安装会导致zabbix编译报错
rpm -ivh MySQL-shared-5.6.37-1.el6.x86_64.rpm
4.修改配置文件位置
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
5.修改mysql配置文件/etc/my.cnf,在[mysqld]中添加innodb_file_per_table=1
6.启动mysql
[root@localhost etc]# service mysql start

启动可能会出现的错误:

Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).

查看mysql的启动日志

[root@localhost mysql]# vim /var/lib/mysql/localhost.localdomain.err
...
2017-09-28 18:41:41 2713 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2017-09-28 18:41:41 2713 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2017-09-28 18:41:41 2713 [ERROR] Plugin 'InnoDB' init function returned error.
2017-09-28 18:41:41 2713 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-09-28 18:41:41 2713 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-09-28 18:41:41 2713 [ERROR] Aborting
...

解决如下

[root@localhost mysql]# ls /var/lib/mysql/
ibdata1  ib_logfile0  ib_logfile1  localhost.localdomain.err  mysql  RPM_UPGRADE_HISTORY  RPM_UPGRADE_MARKER-LAST  test
#删除下面三个文件
[root@localhost mysql]# rm -rf /var/lib/mysql/ibdata1 /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile1
#重新启动即可
[root@localhost mysql]# service mysql start
7.初始化MySQL及设置密码

注意:由于之前安装过mysql老版本,设置过密码,这里可以通过root用户直接登陆到mysql数据库,修改user表里的用户和密码就可以了,也可以配置远程用户登录

如果之前没有安装过mysql,可以按正常的初始化步骤来初始化mysql

遇到以下错误:

ERROR 1558 (HY000): Column count of mysql.user is wrong. Expected 43, found 39. Created with MySQL 50173, now running 50637. Please use mysql_upgrade to fix this error.
#解决方法
[root@localhost ~]# mysql_upgrade -u root -p
8.配置zabbix数据库和用户名(zabbix)以及密码(zabbix)
[root@localhost mysql]# mysql
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.06 sec)
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix'; 
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
mysql> exit;

PHP安装

1.添加 yum 源

CentOS 6.x 的源

# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
2.安装 PHP
# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
3.修改php配置
[root@localhost /]# 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
4.检查

在/var/www/html/下添加php指针

[root@localhost html]# cat /var/www/html/index.php

登陆[http://you_ip/]-->http://192.168.127.134/查看是否安装成功

ZABBIX-3.0.4 版本安装_第2张图片
2.png

zabbix安装

1.创建zabbix用户
[root@localhost /]# groupadd  -g 201  zabbix
[root@localhost /]# useradd  -g zabbix  -u 201 -m zabbix
2.依赖包安装
[root@localhost mysql]# yum -y install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-deve
3.下载zabbix安装包、解压

下载地址:http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz

4.解压到/usr/local/src目录下
[root@localhost src]# pwd
/usr/local/src
[root@localhost src]# ll  zabbix-3.0.4.tar.gz 
-rw-r--r-- 1 root root 15403727 Sep 28 19:12 zabbix-3.0.4.tar.gz
[root@localhost src]# tar -zxvf zabbix-3.0.4.tar.gz 
...
5.将zabbix的初始数据导入到数据库中
[root@localhost src]# cd /usr/local/src/zabbix-3.0.4/database/mysql/
[root@localhost src]# mysql -uroot -hlocalhost -p zabbix 
6.安装
 [root@localhost src]#  cd ./zabbix-3.0.4
 [root@localhost src]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix
 [root@localhost src]# make install
 [root@localhost src]# echo $?
 0
7.修改zabbix_server的配置
[root@localhost etc]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
8.创建一个新的web前端文件
[root@localhost conf]# mkdir /var/www/html/zabbix
#移动源到刚才创建目录下
[root@localhost conf]#cd /usr/loca/src/zabbix-3.0.4/frontends/php/
[root@localhost php]# cp -a . /var/www/html/zabbix/
9.设置Apache作为Web用户接口文件的所有者
chown -R apache:apache /var/www/html/zabbix
10.添加权限给Zabbix Web界面执行文件
chmod +x /var/www/html/zabbix/conf/
11.添加Zabbix服务器和Zabbix代理启动脚本
[root@localhost php]# cp /usr/loca/src/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[root@localhost php]# cp /usr/loca/src/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
12.添加Zabbix服务器和Zabbix代理服务
[root@localhost php]# chkconfig --add /etc/init.d/zabbix_server
[root@localhost php]# chkconfig --add /etc/init.d/zabbix_agentd
[root@localhost php]# chkconfig httpd on
[root@localhost php]# chkconfig mysql on
[root@localhost php]# chkconfig zabbix_server on
[root@localhost php]# chkconfig zabbix_agentd on
13.启动zabbix_server
[root@localhost php]# /etc/init.d/zabbix_server start    #报错
Starting zabbix_server:  /etc/init.d/functions: line 546: /usr/local/sbin/zabbix_server: No such file or directory
                                                           [FAILED]
 
[root@localhost php]# vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix     #更改下路径

 
[root@localhost php]# /etc/init.d/zabbix_server start
Starting zabbix_server:                                    [  OK  ]
 
[root@localhost php]# vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix    #更改下路径

 
[root@localhost php]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]
14.web界面安装

zabbix web安装界面

http://you_ip/zabbix/setup.php-->http://192.168.161.133/zabbix/setup.php

ZABBIX-3.0.4 版本安装_第3张图片
3.png
ZABBIX-3.0.4 版本安装_第4张图片
4.png
ZABBIX-3.0.4 版本安装_第5张图片
5.png
ZABBIX-3.0.4 版本安装_第6张图片
6.png
ZABBIX-3.0.4 版本安装_第7张图片
7.png
ZABBIX-3.0.4 版本安装_第8张图片
9.png
ZABBIX-3.0.4 版本安装_第9张图片
11.png

备注

以上就是zabbixserver端安装过程,因为是安装成功之后在写的这篇文档,写的时间比较仓促,所以有些问题遇到了没有写出来,但基本上就是以上的一个安装思路!!大家可以参考!
参考资料:
http://www.cnblogs.com/zzzhfo/p/5820321.html

你可能感兴趣的:(ZABBIX-3.0.4 版本安装)