设为首页 收藏本站
查看: 935|回复: 0

[经验分享] zabbix service and client deployment

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-11-19 08:46:26 | 显示全部楼层 |阅读模式
what is zabbix?
英語實在太爛,沒辦法繼續了,但總有一天要將其變爲第一語言
先來看看官方給出的定義,纯官方摘过来的https://www.zabbix.com/documenta ... /introduction/about
What is ZabbixOverviewZabbix was created by Alexei Vladishev, and currently is actively developed and supported by Zabbix SIA.
Zabbix is an enterprise-class open source distributed monitoring solution.
Zabbix is software that monitors numerous parameters of a network and the health and integrity of servers. Zabbix uses a flexible notification mechanism that allows users to configure e-mail based alerts for virtually any event. This allows a fast reaction to server problems. Zabbix offers excellent reporting and data visualisation features based on the stored data. This makes Zabbix ideal for capacity planning.
Zabbix supports both polling and trapping. All Zabbix reports and statistics, as well as configuration parameters, are accessed through a web-based frontend. A web-based frontend ensures that the status of your network and the health of your servers can be assessed from any location. Properly configured, Zabbix can play an important role in monitoring IT infrastructure. This is equally true for small organisations with a few servers and for large companies with a multitude of servers.
Zabbix is free of cost. Zabbix is written and distributed under theGPLGeneral Public License version 2. It means that its source code is freely distributed and available for the general public.
Commercial support is available and provided by Zabbix Company.
Learn more about Zabbix features.
Users of ZabbixMany organisations of different size around the world rely on Zabbix as a primary monitoring platform.

约定:
    系统:centos 6
    软件版本:zabbix 2.2
    安装目录:/usr/local/zabbix

说明:
    软件需求:web(apache、nginx)、php、mysql,具体不在此做说明
    此文档采用源码编译安装

    还为做深入研究,这里只记录Server端和Clinet端的安装


正文:
    下载软件:http://www.zabbix.com/download.php
一.服务端

1.创建用户
1
2
# groupadd zabbix
# useradd -g zabbix zabbix



2.创建数据库https://www.zabbix.com/documenta ... /install/db_scripts
1
2
3
# cd /usr/local/src
# tar -xzvf zabbix-2.2.2.tar.gz
# cd zabbix-2.2.2



MySQL (we assume that user username with password password exists and has permissions to create database objects):

1
2
3
4
5
6
7
shell> mysql -u<username> -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> quit;
shell> mysql -u<username> -p<password> zabbix < database/mysql/schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -u<username> -p<password> zabbix < database/mysql/images.sql
shell> mysql -u<username> -p<password> zabbix < database/mysql/data.sql




PostgreSQL (we assume that user username exists and has permissions to create database objects):

1
2
3
4
5
6
7
8
shell> psql -U <username>
psql> create database zabbix;
psql> \q
shell> cd database/postgresql
shell> psql -U <username> zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
shell> psql -U <username> zabbix < images.sql
shell> psql -U <username> zabbix < data.sql




Oracle (we assume that user zabbix with password password exists and has permissions to create database objects  in service ORCL):

If you are creating database for Zabbix server you need to have images somewhere on Oracle host:

1
2
3
4
5
# copy directory create/images/old_images somewhere on Oracle server (e.g. /home/oracle):
shell> scp -r create/images/old_images user@host:/home/oracle
# edit file database/oracle/images.sql and set images_dir variable to
where you have copied them (e. g. "/home/oracle/old_images"):
CREATE OR REPLACE DIRECTORY image_dir AS '/home/oracle/old_images'




Now prepare the database:

1
2
3
4
5
shell> sqlplus zabbix/password@host/ORCL
sqlplus> @database/oracle/schema.sql
# stop here if you are creating database for Zabbix proxy
sqlplus> @database/oracle/images.sql
sqlplus> @database/oracle/data.sql




3.配置帮助信息
1
#./configure --help



4.服务端安装-mysql db

1
2
3
4
# ./configure --prefix=/usr/local/zabbix/ --enable-server \
--enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2

# make && make install



5.服务端安装-PostgreSQL
1
#./configure --enable-server --with-postgresql --with-net-snmp



6.服务端配置
编辑/usr/local/zabbix/etc/zabbix_server.conf配置以下参数
1
2
3
4
5
LogFile=/tmp/zabbix_server.log    #日志文件
DBName=zabbix                              #数据库名称
DBUser=zabbix                                 #数据库用户名
DBPassword=zabbix                        #数据库密码
DBPort=3306                                    #数据库端口



7.系统服务配置
经过上面配置,就可以通过$/usr/local/zabbix/sbin/zabbix_server启动服务,但这种启动方式并没有将zabbix服务加入系统服务,那就来配置吧。
服务脚本统一在源码目录misc/init.d下,这里又按系统做了区分,centos、redhat同属fedora,所以这里就要fedora的脚本做修改
1
cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server



编辑/etc/init.d/zabbix_server,修改以下参数
vim  /etc/init.d/zabbix_server
1
BASEDIR=/usr/local/zabbix/         #zabbix安装目录



加入系统服务
1
2
chkconfig --add zabbix_agentd
chkconfig --level 345 zabbix_agentd on



启动zabbix服务
1
$service zabbix_server start



这里还有个问题,就是SElinux的安全验证,可使用setenfroce 0暂时关闭selinux临时解决下

二.服务端web配置

拷贝文件到web目录site下http://httpd.apache.org/docs/2.2/vhosts/
1
cp -rp /usr/local/zabbix-2.2.2/frontends/php /site/zabbix/



apache配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<Directory "/site/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

<VirtualHost *:80>
    #ServerAdmin
    DocumentRoot /site/zabbix
    ServerName localhost
    ErrorLog logs/dummy-zabbix.com-error_log
    CustomLog logs/dummy-zabbix.com-access_log common
</VirtualHost>



nginx配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
server {
    listen    80;
    server_name localhost;
    access_log zabbix.com.access.log main;
    index index.html index.php index.html;
    root  /site/zabbix;

    location /
    {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ ^(.+.php)(.*)$ {
        fastcgi_split_path_info ^(.+.php)(.*)$;
        include fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param PATH_INFO
        $fastcgi_path_info;
    }
}



安装前端
1.浏览器打开http://localhost/zabbix

如果前面的配置正确,会看到安装向导
wKiom1ZMQV6i-LXLAAOCyXEDRTU658.jpg
2.确认先决条件是否满足
wKioL1ZMRh2ABh5aAAJLyOlZeSw873.jpg

Pre-requisiteMinimum valueDescription
PHP version
5.3.0

PHP memory_limit option
128MB
In php.ini:
memory_limit = 128M

PHP post_max_size option
16MB
In php.ini:
post_max_size = 16M

PHP upload_max_filesize option
2MB
In php.ini:
upload_max_filesize = 2M

PHP max_execution_time option
300 seconds
In php.ini:
max_execution_time = 300

PHP max_input_time option
300 seconds
In php.ini:
max_input_time = 300

PHP session.auto_start option
must be disabled
In php.ini:
session.auto_start = 0.

Database support
One of: IBM DB2, MySQL, Oracle, PostgreSQL, SQLite
One of the following modules must be installed:
ibm_db2, mysql, oci8, pgsql, sqlite3

bcmath
php-bcmath

mbstring
php-mbstring

sockets
php-net-socket. Required for user script support.

gd
2.0 or higher
php-gd. PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir).
libxml
2.6.15
php-xml or php5-dom

xmlwriter
php-xmlwriter

xmlreader
php-xmlreader

ctype
php-ctype

session
php-session

gettext
php-gettext
Starting with Zabbix 2.2.1, the PHP gettext extension is no longer a mandatory requirement for installing Zabbix. If gettext is not installed, the frontend will work as usual, however, the translations will not be available.
3.配置链接数据库信息,前提zabbix数据库必须已创建
wKiom1ZMRmbwyr7sAAIUG-GsNoE709.jpg
4.主机信息配置

wKiom1ZMSFyRqgadAAHSWymffOI516.jpg
5.检查配置信息是否正确

wKiom1ZMSJnSXvGmAAHZgwKdpd4407.jpg
6.生成配置文件,这里可能会出权限问题,可将配置文件下载后上传到服务器,或修改目录权限

wKiom1ZMSKjDMWbLAAHDHGuiIjk672.jpg
7.登录
默认用户为admin,密码为zabbix

wKioL1ZMScDwrKPQAAFBdqnIJ0I628.jpg
8.中文支持及字体更改
zabbix本身已集成中文,但需要手动开启后才会出现在语言设置中
编辑/site/zabbix/include/locales.inc.php文件,找到zh_CN,将后面的falsh改为true,就可在页面的语言设置中找到中文选项了
wKioL1ZMTpqDKrjZAAGqFHnicpI937.jpg
支持中文后,在图表数据中可能会出现乱码情况,与字体库有关,将windows下的C:\Windows\Fonts\simkai.ttf(楷体)上传到服务器 zabbix 网站目录 fonts 目录下

修改web目录/site/zabbix/include/defines.inc.php文件,做如下变更
1
sed -i 's/DejaVuSans/simkai/g' ./include/defines.inc.php



1
2
3
4
5
6
43行
define('ZBX_GRAPH_FONT_NAME',        'DejaVuSans'); // font file name    修改前
define('ZBX_GRAPH_FONT_NAME',        'simkai'); // font file name       修改后
90行
define('ZBX_FONT_NAME', 'DejaVuSans');                                                修改前
define('ZBX_FONT_NAME', 'simkai');                                                         修改后




三.客户端

1.客户端安装
1
2
# groupadd zabbix
# useradd -g zabbix zabbix



1
2
#./configure --enable-agent --prefix=/usr/local/zabbix/
make && make install



2.客户端配置
编辑/usr/local/zabbix/etc/zabbix_agentd.conf配置以下参数
1
2
3
4
LogFile=/tmp/zabbix_agentd.log        #日志配置
Server=127.0.0.1                                   #zabbix服务端地址,允许服务端主动来取数据
ServerActive=127.0.0.1                        #zabbix服务端地址,主动向服务端提交数据
Hostname=Zabbix server                    #客户端名称,这个名称后面在服务端添加监控主机时要用到



3.加入系统自启动服务
1
cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_agentd



编辑/etc/init.d/zabbix_agentd,修改以下参数
vim  /etc/init.d/zabbix_agentd
1
BASEDIR=/usr/local/zabbix/         #zabbix安装目录



加入系统服务
1
2
chkconfig --add zabbix_agentd
chkconfig --level 345 zabbix_agentd on



启动客户端
service zabbix_agentd start

如何创建监控主机,待研究明白了在来补

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-140909-1-1.html 上篇帖子: 解决Zabbix Grafana 2.5.0.1 不支持7day趋势数据显示 下篇帖子: Linux监控服务之zabbix客户端安装 service
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表