RedHat6.9中编制安装zabbix-3.4.7,DB用percona mysql 5.7.20

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RedHat6.9中编制安装zabbix-3.4.7,DB用percona mysql 5.7.20相关的知识,希望对你有一定的参考价值。

软件版本:
Redhat6.9
zabbix-3.4.7
percona mysql-5.7.20

准备工作:
关闭防火墙,或者添加相应端口。
关闭selinux

———— (安装如下zabbix依赖包)————
####这里的包是我网上找的,如有需要请回复。#####
rpm -ivh *.rpm
fping-3.5-3.el6.x86_64.rpm
iksemel-1.4-2_2.el6.x86_64.rpm
iksemel-devel-1.4-2_2.el6.x86_64.rpm
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
libiconv-1.14-3.el6.x86_64.rpm
libiconv-devel-1.14-3.el6.x86_64.rpm
libiksemel3-1.4-2_2.el6.x86_64.rpm
libssh2-devel-1.4.2-2.el6_7.1.x86_64.rpm
OpenIPMI-devel-2.0.16-14.el6.x86_64.rpm
php54w-5.4.45-2.w6.x86_64.rpm
php54w-bcmath-5.4.45-2.w6.x86_64.rpm
php54w-cli-5.4.45-2.w6.x86_64.rpm
php54w-common-5.4.45-2.w6.x86_64.rpm
php54w-gd-5.4.45-2.w6.x86_64.rpm
php54w-ldap-5.4.45-2.w6.x86_64.rpm
php54w-mbstring-5.4.45-2.w6.x86_64.rpm
php54w-mysql-5.4.45-2.w6.x86_64.rpm
php54w-pdo-5.4.45-2.w6.x86_64.rpm
php54w-xml-5.4.45-2.w6.x86_64.rpm
unixODBC-devel-2.2.14-14.el6.x86_64.rpm
————————————————

rpm -qa | grep mysql

卸载系统自带mysql
rpm -e mysql mysql-server mysql-devel

解压从Percona官网下载的rpm安装包:
tar zxvf Percona-Server-5.7.20-19-r119-el6-x86_64-bundle.tar

cd Percona-Server-5.7.20-19-r119-el6-x86_64-bundle

安装以下四个包即可:
rpm -ivh Percona-Server-server-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-client-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-devel-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-shared-57-5.7.20-19.1.el6.x86_64.rpm

创建zabbix用户:
useradd -u 1000 zabbix

chgrp zabbix /usr/sbin/fping

chmod 4710 /usr/sbin/fping

解压从官网下载下来的zabbix-3.4.7源码安装包:
tar zxvf zabbix-3.4.7.tar.gz

编译安装(编译参数可根据自己需求更改):
./configure --prefix=/usr/local --enable-server --enable-agent --enable-java --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-libpcre --with-ldap --with-openssl --with-libcurl --with-iconv --sysconfdir=/etc/zabbix

make && make install

修改数据库引擎:
vim /etc/my.cnf
————————————末尾添加————————————
[mysqld]
default-storage-engine=InnoDB
————————————————————————————

chkconfig mysql on

service mysql start

由于mysql5.7版本以后初始密码机制有所改变,第一次不能用匿名用户登陆,但是密码保存在mysql日志文件/var/log/mysqld.log中。如下字段中kk&q)j88uKwU就是默认的root密码,可根据如下提供的关键字搜索。
vim /var/log/mysqld.log
A temporary password is generated for [email protected]: kk&q)j88uKwU

输入日志中的默认密码,登陆mysql
mysql -u root -p

修改root密码:(注意,mysql5.7版本以后密码需要满足复杂性要求;必须包含数字,大写字母,小写字母,特殊字符其中三项才可以)
————以下代码为sql语句,请登陆mysql后在mysql中执行————
set password for [email protected]=password (‘12345.Com‘);

flush privileges;

创建zabbix数据库
create database zabbix character set utf8 collate utf8_bin;

给zabbix数据库授权,密码为12345.Com:
grant all privileges on zabbix. to [email protected] identified by ‘12345.Com‘;

flush prvileges;
————————————————————

导入zabbix数据至zabbix数据库:
cd /zabbix-3.4.7/database/mysql/

mysql -uzabbix -p zabbix <schema.sql

mysql -uzabbix -p zabbix <images.sql

mysql -uzabbix -p zabbix <data.sql

修改zabbix_server 配置文件
vim /etc/zabbix/zabbix_server
——————————修改—————————
38行
LogFile=/var/log/zabbix/zabbix_server.log

68行
PidFile=/var/log/zabbix/zabbix_server.pid

85行
DBHost=localhost ##mysql数据库IP,此环境mysql与zabbix-server在同一机器上

95行
DBName=zabbix ##mysql数据库

111行
DBUser=zabbix ##mysql用户

119行
DBPassword=12345.Com ##mysql密码

126行
DBSocket=/var/lib/mysql/mysql.sock ##这里需要注意。用 find / -name mysql.sock查看,然后再填入。

322行
SNMPTrapperFile=/var/run/zabbix/zabbix_traps.tmp

588行
Include=/usr/local/etc/zabbix_server.conf.d/*.conf
——————————————————

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

11行
PidFile=/var/log/zabbix/zabbix_agentd.pid

30行
LogFile=/var/log/zabbix/zabbix_agentd.log

265行
Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
——————————————————————

创建zabbix 日志目录
mkdir -p /var/run/zabbix

mkdir -p /var/log/zabbix

chown -R zabbix:zabbix /var/run/zabbix/ /var/log/zabbix/

复制zabbix启动脚本
cp zabbix-3.4.7/misc/init.d/fedora/core5/zabbix_server /etc/init.d/

cp zabbix-3.4.7/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

开机启动
chkconfig zabbix_server on

chkconfig zabbix_agentd on

mkdir -p /usr/local/etc/zabbix_server.conf.d

mkdir -p /usr/local/etc/zabbix_agentd.conf.d

service zabbix_server restart

service zabbix_agentd restart

创建zabbix web页面
mkdir /var/www/html/zabbix

cd zabbix-3.4.7/frontends/php

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

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

vim /etc/httpd/conf/httpd.conf
————————————末尾追加一下内容—————————————
Alias /zabbix /var/www/html/zabbix
<Directory "/var/www/html/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
<Directory "/var/www/html/zabbix/conf">
Order deny,allow
Deny from all
<files .php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/var/www/html/zabbix/app">
Order deny,allow
Deny from all
<files
.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/var/www/html/zabbix/include">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
————————————————————————————————

chkconfig httpd on

service httpd restart

此时即可用web访问http://10.1.1.1/zabbix 进行手动配置zabbix—web
或者也可按照以下方式手动创建:

vim /var/www/html/zabbix/conf/zabbix.conf.php
———————————————————添加以下内容—————————————————————————
<?php
//Zabbix GUI configuration file.
global $DB;

$DB[‘TYPE‘] = ‘MYSQL‘;
$DB[‘SERVER‘] = ‘localhost‘;
$DB[‘PORT‘] = ‘0‘;
$DB[‘DATABASE‘] = ‘zabbix‘;
$DB[‘USER‘] = ‘zabbix‘;
$DB[‘PASSWORD‘] = ‘12345.Com‘;
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB[‘SCHEMA‘] = ‘‘;
$ZBX_SERVER = ‘localhost‘;
$ZBX_SERVER_PORT = ‘10051‘;
$ZBX_SERVER_NAME = ‘‘;

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
————————————————————————————————————————

chown zabbix.zabbix /var/www/html/zabbix/conf/zabbix.conf.php

此时zabbix_server端即配置完毕。

(此文章仅为个人安装配置笔记内容,如有不足之处还请各位前辈多多指教!)

以上是关于RedHat6.9中编制安装zabbix-3.4.7,DB用percona mysql 5.7.20的主要内容,如果未能解决你的问题,请参考以下文章

redhat6.9安装11.2.0.4执行root.sh提示vip资源添加失败

关于linux‘RedHat6.9在VMware虚拟机中的安装步骤

RedHat6.9 编译安装php7.4.6

zabbix-3.4.14源码安装

zabbix-3.4.6安装

实战 zabbix-3.4.11 安装,配置,部署全过程