您的位置:首页 > 数据库 > Oracle

Zabbix 3.4官方安装文档 for RHEL 7, CentOS 7 and Oracle Linux 7 及个人总结

2018-01-24 11:17 921 查看
Red Hat Enterprise Linux/CentOS

声明:本文翻译只针对RHEL7内容,7以下版本请忽略本文!(翻译错误请指出,见谅)

黑色字体为原官方文档及我的翻译。

绿色为原文超链接。

蓝色字体为个人备注,不作为标准,仅供参考,谢谢。

Overview

概述

Official Zabbix packages are available for RHEL 7, CentOS 7 and OracleLinux 7. In this documentation we will refer to all 3 using the term RHEL.

官方的Zabbix包可用于RHEL 7、CentOS
7和Oracle Linux 7。在这篇文档中,我们将使用术语RHEL来指代这三个操作系统。

 

Adding Zabbix repository

添加Zabbix库

Install the repository configuration package. This package contains yum(software package manager) configuration files.

安装rpm包。这个包包含yum(软件包管理器)配置文件。

RHEL 7:

# rpm -ivhhttp://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

Server/proxy/frontend installation

服务器/代理/前端安装

To install Zabbix server (available for RHEL 7, deprecated
on RHEL 6) with MySQL support:

安装Zabbix服务器(可用于RHEL 7,在RHEL
6上不使用)需要MySQL支持:

# yum install zabbix-server-mysql

To install Zabbix proxy with MySQL support:

安装zabbix proxy需要MySQL支持:

# yum install zabbix-proxy-mysql

To install Zabbix frontend (available for RHEL 7, deprecated
on RHEL 6) with MySQL support:

安装Zabbix前端(可用于RHEL 7,在RHEL
6上不支持)和MySQL支持:

# yum install zabbix-web-mysql

各个RPM包的作用如下:

Zabbix-server-mysql:Zabbix-serverMySQL版

Zabbix-web-mysql:Web界面MySQL相关

Zabbix-web:Web界面

Zabbix-agent:客户端程序

Zabbix-get:服务端上命令行获取客户端检测项目的工具

可以看出zabbix的rpm包会连带安装httpd和php,也就是说Zabbix需要LAMP的支持,如果是线上的机器已经运行了Nginx,再装httpd会有冲突,解决方法是让httpd监听8080端口,然后再让Nginx去代理httpd。

Substitute 'mysql' in the commands with 'pgsql' to use PostgreSQL, or with'sqlite3' to use SQLite3 (proxy only).

用“pgsql”替换“mysql”来使用PostgreSQL,或用sqlite3来替换mysql来使用sqlite3(仅proxy)。

Creating database

创建数据库

For Zabbix server and proxy daemonsa
database is required. It is not needed to run Zabbix agent.

对于Zabbixserver和proxy的后台程序必须要一个数据库。不是必须要运行Zabbix
agent。

If Zabbix server and proxy are installed on the samehost, their databases must be created with different names!
如果Zabbix服务器和代理安装在同一个主机上,那么它们的数据库必须用不同的名称创建!
Create the database using the provided instructions for MySQL or PostgreSQL.

使用MySQL或PostgreSQL提供的指令创建数据库

MySQL

shell> mysql -uroot -p<password>

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';

mysql> quit;


If you use Zabbix packages continue withinstructions for Debian/Ubuntu or RHEL/CentOS to
import the data into the database.

如果你使用Zabbix的包,继续使用debian/ubuntu或rhel/centos的指令,将数据导入数据库。(此处如果是按前面文档安装请跳到下面的导入数据步骤)

shell> cd database/mysql

shell> mysql -uzabbix -p<password> zabbix < schema.sql

# stop here if you are creating database for Zabbix proxy

如果您正在为Zabbix proxy创建数据库,请在这里停止

shell> mysql -uzabbix -p<password> zabbix < images.sql

shell> mysql -uzabbix -p<password> zabbix < data.sql


 

Importing data

导入数据

Now import initial schema and data for the server with MySQL:

现在开始使用MySQL导入服务器的初始模式和数据

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz| mysql -uzabbix -p zabbix

You will be prompted to enter your newly created database password.

您将被提示输入您新创建的数据库密码。

With PostgreSQL:

使用PostgreSQL:

# zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz| sudo -u <username> psql zabbix

For proxy, import initial schema:

对于proxy,导入初始模式

# zcat /usr/share/doc/zabbix-proxy-mysql*/schema.sql.gz |mysql -uzabbix -p zabbix

For proxy with PostgreSQL (or SQLite):

对于使用PostgreSQL (or SQLite)的proxy:

# zcat /usr/share/doc/zabbix-proxy-pgsql*/schema.sql.gz |sudo -u <username> psql zabbix

# zcat /usr/share/doc/zabbix-proxy-sqlite3*/schema.sql.gz| sqlite3 zabbix.db

Configure database for Zabbix server/proxy

Zabbix server/proxy配置数据库

Edit zabbix_server.conf or zabbix_proxy.conf to use the created database.For example:

编辑zabbix_server.conf或zabbix_proxy.conf的配置文件来使用创建的数据库。例如:

# vi /etc/zabbix/zabbix_server.conf

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=<password>

In DBPassword use Zabbix database password for MySQL; PosgreSQL userpassword for PosgreSQL.

在DBPassword中使用Zabbix的MySQL数据库密码;

Use DBHost= withPostgreSQL. You might want to keep the default setting DBHost=localhost(or an IP address), but thiswould make PostgreSQL use a network
socket for connecting to Zabbix. See SELinuxconfiguration below for instructions.

使用DBHost = PostgreSQL。您可能希望保留缺省设置DBHost=localhost(或IP地址),但这将使PostgreSQL使用一个网络套接字来连接Zabbix。参见下面的SELinux配置说明。

Starting Zabbix server process

启动zabbix server进程

It's time to start Zabbix server process:

是时候开始zabbix-server进程了:

# service zabbix-server start

and make it start at system boot:

在系统引导时开启(开机启动)

RHEL 7 and later:

RHEL 7 及以后:

# systemctl enable zabbix-server

Substitute 'zabbix-server' with 'zabbix-proxy' if you are installingZabbix proxy.

如果你在安装Zabbix proxy,用‘zabbix-proxy’代替‘zabbix-server’

Zabbix frontend configuration

Zabbix前端配置

For RHEL 7 and later the Apache configuration file for Zabbix frontend islocated in /etc/httpd/conf.d/zabbix.conf.

RHEL 7及之后版本,Zabbix前端的Apache配置文件位于/etc/httpd/conf.d/zabbix.conf。

Some PHP settings are already configured. But it's necessary to uncommentthe “date.timezone” setting and set
the right timezone for you.

一些PHP设置已经配置了。但有必要对“时间”进行设置。(默认值和文档的推荐值有一些出入,所以需要修改配置文件中的值,而最后一个关于时区的行业需要去掉注释并且修改成所在时区,我用的是Asia/Shanghai,好像beijing、chongqing都可以)

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 Europe/Riga

Now you are ready to proceed with frontendinstallation
steps which will allow you to access your newlyinstalled Zabbix.(点击超链接可以进入到web界面的配置说明,很简单的几个下一步就OK了,在此就不做太多的说明了)

现在,您已经准备好进行前端安装步骤,这将允许您访问新安装的Zabbix。

SELinux configuration

SELinux 配置

Having SELinux status enabled in enforcing mode, you need to execute thefollowing commands to enable communication between Zabbix frontend and server:

在执行模式启用SELinux状态时,您需要执行以下命令来启用Zabbix前端和服务器之间的通信

RHEL 7 and later:

#setsebool -P httpd_can_connect_zabbix on

If the database is accessible over network (including'localhost' in case of PostgreSQL), you need to allow Zabbix frontend toconnect to the database too:

如果数据库可以通过网络访问(包括“localhost”),那么你需要让Zabbix的前端也能连接到数据库:

# setsebool -P httpd_can_network_connect_db on

As frontend and SELinux configuration is done, you need to restart Apacheweb server:

随着前端和SELinux配置完成,您需要重新启动Apache web服务器:

# service httpd restart

Agent installation

客户端部署

To install the agent, run

安装zabbix客户端代理

# yum install zabbix-agent

To start the agent, run:

启动zabbix-agent服务

# service zabbix-agent start

总结:启动zabbix-server前一定要启动mysql,因为是依赖关系,如果zabbix-server启动不起来,第一先检查mysql是否正常启动了。然后就是老生常谈的防火墙问题。因为一些别的问题,数据库我使用的MariaDB来替代的mysql,是完全兼容mysql的,使用也一样。

关于zabbix-agent的配置文件,如果服务端和客户端不是同一台机器,也有个要修改的地方:

vim /etc/zabbix/zabbix_agentd.conf

Server=服务端的IP(被动模式)

ServerActive=服务端的IP(主动模式)

Hostname=自定义主机名

被动模式就是服务端会主动的连接客户端获取监控项目数据,客户端被动的接受。

主动模式就是客户端会主动的把监控数据汇报给服务端,服务端只负责接受。

当客户量非常多时建议用主动模式,可以降低服务端的压力。

 

 

最后的最后…发现了一个残酷的真相,Zabbix的官网是有官方中文翻译的。第一次点中文的时候网站报错了,我错误的以为还没有中文版文档。如果你能耐下心看到这里的话,去zabbix官网看看吧,有很多样例,希望能够帮到你。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: