Centos 6.5 部署zabbix 3.2.6

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos 6.5 部署zabbix 3.2.6相关的知识,希望对你有一定的参考价值。

[[email protected] ~]# mkdir -p /usr/local/src
[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# pwd
/usr/local/src
[[email protected] src]# useradd -s /sbin/nologin -M mysql
[[email protected] src]# mkdir -p /usr/local/mysql
[[email protected] src]# mkdir -p /usr/local/mysql/data/mysql
[[email protected] src]# mkdir -p /home/data/mysql
[[email protected] src]# yum -y install gcc gcc-c++ zlib-devel libtool ncurses-devel libxml2-devel cmake
[[email protected] src]# wget -q http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[[email protected] src]# tar xf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[[email protected] src]# cd mysql-5.6.35
[[email protected] mysql-5.6.35]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
[[email protected] mysql-5.6.35]# make && make install
[[email protected] mysql-5.6.35]# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
[[email protected] mysql-5.6.35]# chmod +x /etc/init.d/mysqld
[[email protected] mysql-5.6.35]# chown -R mysql:mysql /usr/local/mysql/data/mysql
[[email protected] mysql-5.6.35]# chown -R mysql:mysql /usr/local/mysql/
[[email protected] mysql-5.6.35]# cd /usr/local/mysql/scripts/
[[email protected] scripts]# ./mysql_install_db  --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/mysql
[[email protected] scripts]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf‘? y
[[email protected] scripts]# vim /etc/my.cnf 
[[email protected] scripts]# vim /etc/profile
datadir = /usr/local/mysql/data/mysql
port = 3306
server_id = 2
socket = /usr/local/mysql/mysql.sock

lower_case_table_names = 1
wait_timeout=3600
log_bin_trust_function_creators=1
max_connections=500
[[email protected] scripts]# source /etc/profile
[[email protected] scripts]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS! 
[[email protected] scripts]# netstat -nlput | grep mysql
tcp        0      0 :::3306                     :::*                        LISTEN      16454/mysqld
  • 创建zabbix数据库、并授权

[[email protected] scripts]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.32 Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON zabbix.* TO [email protected] IDENTIFIED BY ‘zabbixpass‘; 
Query OK, 0 rows affected (0.03 sec)

mysql> exit
Bye
  • 安装php&Apache

[[email protected] scripts]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
Retrieving http://repo.webtatic.com/yum/el6/latest.rpm
warning: /var/tmp/rpm-tmp.aRTjFj: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
Preparing...                ########################################### [100%]
   1:webtatic-release       ########################################### [100%]

[[email protected] scripts]# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
[[email protected] scripts]# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
memory_limit = 128M
pload_max_filesize = 2M

修改Apache配置

[[email protected] scripts]# vim /etc/httpd/conf/httpd.conf 
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.php
[[email protected] scripts]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]

安装zabbix

[[email protected] scripts]# groupadd zabbix
[[email protected] scripts]# useradd -g zabbix zabbix
[[email protected] scripts]#  yum -y install mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel
[[email protected] scripts]# cd /usr/local/src/
[[email protected] src]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX Latest Stable/3.2.6/zabbix-3.2.6.tar.gz
[[email protected] src]# tar xf zabbix-3.2.6.tar.gz 
[[email protected] src]# cd zabbix-3.2.6
[[email protected] zabbix-3.2.6]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --enable-java
[[email protected] zabbix-3.2.6]# make install

修改zabbix_server配置文件

[[email protected] zabbix-3.2.6]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpass

创建前端目录

[[email protected] zabbix-3.2.6]# mkdir /var/www/html/zabbix

拷贝文件到/var/www/html/zabbix

[[email protected] zabbix-3.2.6]# cd frontends/php/
[[email protected] php]# cp -a . /var/www/html/zabbix/

赋权

[[email protected] php]# chown -R apache:apache /var/www/html/zabbix
[[email protected] php]# chmod +x /var/www/html/zabbix/conf/

添加zabbix启动脚本

[[email protected] php]# cd /usr/local/src/zabbix-3.2.6
[[email protected] zabbix-3.2.6]# pwd
/usr/local/src/zabbix-3.2.6
[[email protected] zabbix-3.2.6]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[[email protected] zabbix-3.2.6]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_agentd
[[email protected] zabbix-3.2.6]# chkconfig --add /etc/init.d/zabbix_server
[[email protected] zabbix-3.2.6]# chkconfig --add /etc/init.d/zabbix_agentd
[[email protected] zabbix-3.2.6]# chkconfig httpd on
[[email protected] zabbix-3.2.6]# chkconfig mysqld on
[[email protected] zabbix-3.2.6]# chkconfig zabbix_server on
[[email protected] zabbix-3.2.6]# chkconfig zabbix_agentd on
[[email protected] zabbix-3.2.6]# vim /etc/init.d/zabbix_server 
BASEDIR=/usr/local/zabbix
[[email protected] zabbix-3.2.6]# vim /etc/init.d/zabbix_agentd 
BASEDIR=/usr/local/zabbix

初始化数据库

[[email protected] zabbix-3.2.6]# cd database/mysql/
[[email protected] mysql]# ls
data.sql  images.sql  schema.sql
[[email protected] mysql]# mysql -uroot -hlocalhost -p zabbix <schema.sql
Enter password: 
[[email protected] mysql]# mysql -uroot -hlocalhost -p zabbix <images.sql 
Enter password: 
[[email protected] mysql]# mysql -uroot -hlocalhost -p zabbix <data.sql
Enter password:

启动服务

报错

[[email protected] ~]# /etc/init.d/zabbix_server start
Starting zabbix_server:  /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
                                                           [FAILED]
[[email protected] ~]# /etc/init.d/zabbix_agentd start
Starting zabbix_server:  /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
                                                           [FAILED]

解决

[[email protected] ~]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64

重新启动服务

[[email protected] ~]# /etc/init.d/zabbix_server start
Starting zabbix_server:                                    [  OK  ]
[[email protected] ~]# /etc/init.d/zabbix_agentd start
Starting zabbix_server:                                    [  OK  ]


本文出自 “十里春风” 博客,请务必保留此出处http://visitor.blog.51cto.com/11247238/1956450

以上是关于Centos 6.5 部署zabbix 3.2.6的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 6.5 安装部署zabbix(Agent客户端篇)

CentOS 6.5 zabbix 3.0.4 SendEmail报警

zabbix-3.2.6安装部署

CentOS 6.5 安装 Redis-3.2.6

CentOS 6.5 Zabbix-windows-Agent安装

CentOS 6.5安装Zabbix 3.0.4开始