CentOS6系统下Zabbix server安装

版权声明:转载请注明出处! https://blog.csdn.net/ywd1992/article/details/82665077

一、准备工作

1、关闭防火墙

service iptables stop
chkconfig iptables off

vi /etc/selinux/config
SELINUX=disabled

2、配置本地YUM源(使用CentOS 6.5镜像 )

CentOS 6.5 http://archive.kernel.org/centos-vault/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso

mkdir -p /etc/yum.repos.d/yum.bak
mv /etc/yum.repos.d/*.repo* yum.bak/
vi /etc/yum.repos.d/local.repo

[local]
name=local
enable=1
baseurl=file:///yum
gpgcheck=0

yum clean all
yum -y install vim gcc

3、文档所需所有资源均在每步安装之前提供下载地址

二、基础组件

1、MySQL

(1)查找并卸载系统已经安装的mysql

rpm -qa | grep mysql
rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

(2)安装libaio

链接:https://pan.baidu.com/s/1yP9dO1WxmZpurXJ2d4_tfA 密码:qlyb

rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm

(3)安装MySQL

链接:https://pan.baidu.com/s/14hyu8ltY0zOWTu0GhHa8OA 密码:pz06

tar -xbf MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar

rpm -ivh MySQL*.rpm

(4)配置数据库

cp /usr/share/mysql/my-default.cnf /etc/my.cnf

vim /etc/my.conf

default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
max_allowed_packet = 100M

(5)初始化并启动数据库

/usr/bin/mysql_install_db

service mysql start
chkconfig mysql on

(6)修改数据库临时密码

cat /root/.mysql_secret

mysqladmin -uroot -pDZxvfVLLeJQGR7Mq password 123456

(7)创建zabbix数据库及用户并赋予相关权限

mysql -u root -p123456

CREATE DATABASE zabbix CHARACTER SET UTF8 COLLATE UTF8_BIN;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY '123456';
FLUSH PRIVILEGES;

2、Apache

链接:https://pan.baidu.com/s/1zdWmFtT6fCxKLoidFj5Hyg 密码:4bab

tar -xvf httpd.tar.gz

(1)安装apr

cd apr-1.5.2

./configure --prefix=/usr/local/apr

make && make install

(2)安装apr-util

yum -y install expat-devel

cd apr-util-1.5.1

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install

(3)安装pcre

yum -y install gcc-c++

cd pcre-8.42

./configure --prefix=/usr/local/pcre

make && make install

(4)安装Apache

cd httpd-2.4.34/

./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --libdir=/usr/lib64

make && make install
配置
vim /usr/local/httpd/conf/httpd.conf

将 #ServerName www.example.com:80 打开注释并改为 ServerName 127.0.0.1:80
启动
/usr/local/httpd/bin/apachectl start

设置开机自启
vim /etc/rc.d/rc.local
加入 /usr/local/httpd/bin/apachectl start
chmod +x /etc/rc.d/rc.local

网站目录 /usr/local/httpd/htdocs

3、PHP

链接:https://pan.baidu.com/s/1ACXyZhTjSdpNV8YIBz2Hrg 密码:2ha7

(1)安装依赖

yum -y install zlib zlib-devel libxml2 libxml2-devel openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel
mkdir /usr/local/jpeg

tar -xvf jpegsrc.v9b.tar.gz

cd jpeg-9b/

./configure --prefix=/usr/local/jpeg --enable-shared
make && make install
tar -xvf libpng-1.6.24.tar.gz

cd libpng-1.6.24

mkdir /usr/local/libpng

./configure --prefix=/usr/local/libpng
make && make install
mkdir /usr/local/freetype

tar -xvf freetype-2.6.5.tar.gz

cd freetype-2.6.5

./configure --prefix=/usr/local/freetype/
make && make install

(2)编译安装PHP

tar -xvf php-7.2.9.tar.gz
cd php-7.2.9

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/etc --with-curl --with-freetype-dir --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip

make && make install

拷贝配置文件模板到配置文件目录中
cp php-7.2.9/php.ini-development /etc/php.ini

sh change_php.sh

创建软连接
ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/bin/phpize /usr/bin/phpize
ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm

配置Apache配置文件
vim /usr/local/httpd/conf/httpd.conf
找到 AddType 添加一行
AddType application/x-httpd-php .php(注意空格)
找到 DirectoryIndex index.html
在index.html 后添加一个index.php

重启apache
/usr/local/httpd/bin/apachectl stop
/usr/local/httpd/bin/apachectl start

三、安装Zabbix server

链接:https://pan.baidu.com/s/1nusodqHAPlOo8lI10abuCA 密码:0dhm

1、安装依赖

rpm -ivh --nodeps libevent-devel-1.4.13-4.el6.x86_64.rpm libevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpm pcre-static-7.8-7.el6.x86_64.rpm

yum -y install libxml2 libxml2-devel net-snmp net-snmp-devel libcurl libcurl-devel libevent libevent-devel libXpm net-snmp-devel pcre-devel

2、创建zabbix-server目录

tar -xvf zabbix-3.4.12.tar.gz

mkdir -p /zabbix
mv zabbix-3.4.12 /zabbix/zabbix-server

3、添加zabbix用户及组

groupadd zabbix
useradd -g zabbix zabbix

4、导入zabbix相关表

mysql -uzabbix -p123456 zabbix < /zabbix/zabbix-server/database/mysql/schema.sql
mysql -uzabbix -p123456 zabbix < /zabbix/zabbix-server/database/mysql/images.sql
mysql -uzabbix -p123456 zabbix < /zabbix/zabbix-server/database/mysql/data.sql

5、编译安装Zabbix server

cd /zabbix/zabbix-server

/zabbix/zabbix-server/configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

make install

6、开机自启

cp /zabbix/zabbix-server/misc/init.d/fedora/core/zabbix_* /etc/init.d/
chkconfig zabbix_server on

7、zabbix server配置文件

sh change_zabbix_server.sh

8、zabbix agent配置文件

sh change_zabbix_agent.sh

9、管理页面

mkdir /usr/local/httpd/htdocs/zabbix

cp -Rp /zabbix/zabbix-server/frontends/php/* /usr/local/httpd/htdocs/zabbix/

service zabbix_server start
service zabbix_agentd start

chkconfig zabbix_agentd on

10、登录管理页面

IP/zabbix

默认用户名:Admin
默认密码:zabbix

这里写图片描述

猜你喜欢

转载自blog.csdn.net/ywd1992/article/details/82665077
今日推荐