1. 前言

        zabbix作为开源免费的监控软件。其易于管理配置和可视化的视图、历史数据的定期维护、模板化的监控项目越来越受到广大IT运维人员的喜爱。

这里主要是总结了下Zabbix Server和MPM使用yum进行高速部署。其更加具体的东西,大家还是看官方文档吧。我们首先把环境搭起来!

2. 环境

1)Zabbix Server

Os:Redhat6.5 i686(vmware)
        ipaddr:192.168.8.3
        hostname:linux-zabbix
        MySQL :5.6.23
        MEM:1G

2)监控端

        Os:CentOS 6.4 x64(vmware)
        ipaddr:192.168.8.5
        hostname:oneproxy-vm
        MEM:1G

3. Zabbix Server部署

3.1 yum环境配置

这里的yum源使用的是163的CentOS6.6和zabbix官网的源。

因为我的server安装的是rehat。所以首先要把redhat的yum卸载掉。安装centOS的yun软件。

3.1.1 下载centos yum软件

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

3.1.2 卸载redhat的yum包

rpm -qa|grep -i yum|xargs rpm -e --nodeps

3.1.3 安装centOS的yum包

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

3.1.4 配置163的CentOS6.6的yum

[root@linux-zabbix yum.repos.d]# cd /etc/yum.repos.d
[root@linux-zabbix yum.repos.d]# cat CentOS6-Base-163.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
# [base]
name=CentOS-6.6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6.6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates
[updates]
name=CentOS-6.6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6.6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/? release=6.6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful
[extras]
name=CentOS-6.6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6.6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/? release=6.6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6.6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users
[contrib]
name=CentOS-6.6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6.6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

3.1.5 配置zabbix的yum源

wget http://repo.zabbix.com/zabbix/2.4/rhel/6/i386/zabbix-release-2.4-1.el6.noarch.rpm
rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm
[root@linux-zabbix yum.repos.d]# cat zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/2.4/rhel/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX [zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch 
baseurl=http://repo.zabbix.com/non-supported/rhel/6/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

3.2 Zabbix Server安装

3.2.1 安装mysql数据库

yum remove mysql-libs-5.1.71-1.el6.i686
rpm -ivh MySQL-server-advanced-5.6.23-1.el6.i686.rpm
rpm -ivh MySQL-client-advanced-5.6.23-1.el6.i686.rpm
rpm -ivh MySQL-shared-compat-advanced-5.6.23-1.el6.i686.rpm MySQL-shared-advanced-5.6.23-1.el6.i686.rpm MySQL-devel-advanced-5.6.23-1.el6.i686.rpm

3.2.2 配置mysql

配置文件/etc/my.cnf
[root@linux-zabbix etc]# cat my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock #The MySQL Server
#########Basic######
[mysqld]
server-id = 1
port = 3306
user = mysql
basedir = /usr/
datadir = /var/lib/mysql
tmpdir = /var/lib/mysql/tmp
socket = /tmp/mysql.sock
skip-external-locking
skip-name-resolve
default-storage-engine = INNODB
character-set-server = utf8
wait_timeout = 100
connect_timeout = 20
interactive_timeout = 100
back_log = 500
event_scheduler = on
explicit_defaults_for_timestamp
#skip-grant-tables
#############binlog##############
log-bin = /var/lib/mysql/logs/mysql-bin
binlog_format = row
max_binlog_size = 128M
binlog_cache_size = 4M
expire_logs_days = 5
##############Slow log####################
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/logs/mysql.slow
long_query_time = 2
###############Per_Thread_Buffers########################
max_connections = 1024
max_user_connections = 1000
max_connect_errors = 10000
key_buffer_size = 32M
max_allowed_packet = 128M
table_open_cache = 3096
table_definition_cache = 4096
sort_buffer_size = 512K
read_buffer_size = 512K
read_rnd_buffer_size = 512K
join_buffer_size = 512K
tmp_table_size = 16M
max_heap_table_size = 16M
query_cache_type = 0
query_cache_size = 0
bulk_insert_buffer_size = 16M
thread_cache_size = 64
thread_stack = 256K
################InnoDB#########################
innodb_data_home_dir = /var/lib/mysql
innodb_autoinc_lock_mode = 2
innodb_log_group_home_dir = /var/lib/mysql/logs
innodb_data_file_path = ibdata1:1G:autoextend
innodb_buffer_pool_size = 256M
innodb_buffer_pool_instances = 1
innodb_log_file_size = 64M
innodb_log_buffer_size = 4M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 10
innodb_sync_spin_loops = 40
innodb_max_dirty_pages_pct = 90
innodb_support_xa = 1
innodb_thread_concurrency = 0
innodb_thread_sleep_delay = 500
innodb_file_io_threads = 4
innodb_concurrency_tickets = 1000
log_bin_trust_function_creators = 1
innodb_flush_method = O_DIRECT
innodb_file_per_table
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_io_capacity = 2000
innodb_file_format = Barracuda
innodb_purge_threads = 1
innodb_purge_batch_size = 32
innodb_old_blocks_pct = 75
innodb_change_buffering = all
transaction_isolation = READ-COMMITTED
[mysqldump]
quick
max_allowed_packet = 64M [mysql]
no-auto-rehash [myisamchk]
key_buffer_size = 32M
sort_buffer_size = 256K
read_buffer = 2M
write_buffer = 2M [mysqlhotcopy]
interactive-timeout [mysqld_safe]
open-files-limit=28192 [mysql]
host=localhost
user=zabbix
password=zabbix
socket=/tmp/mysql.sock [mysqladmin]
host=localhost
user=zabbix
password=zabbix
socket=/tmp/mysql.sock

创建文件夹

mkdir -p /var/lib/mysql/tmp
mkdir -p /var/lib/mysql/logs
chown -R mysql:mysql /var/lib/mysql

初始化mysql

mysql_install_db --defaults-file=/etc/my.cnf --datadir=/var/lib/mysql/

启动数据库后,创建zabbix数据库。设置rootpassword

service mysql start
mysql> create database zabbix default charset utf8;
mysql> grant all on *.* to 'root'@'localhost' identified by '123456';
mysql> grant all on *.* to 'root'@'%' identified by '123456';

mysql> flush privileges;

3.2.3 安装zabbix

yum install zabbix-server-mysql zabbix-web-mysql
yum install zabbix-get

yum会自己主动的将apache和php安装配置好。


3.2.4 初始化zabbix数据库

cd /usr/share/doc/zabbix-server-mysql-2.4.5/create
[root@linux-zabbix create]# mysql -p123456 -uroot zabbix < schema.sql
[root@linux-zabbix create]# mysql -p123456 -uroot zabbix < images.sql
[root@linux-zabbix create]# mysql -p123456 -uroot zabbix < data.sql

3.2.5 改动zabbix server配置文件

cat /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=root
DBPassword=123456

3.2.6 改动php配置文件

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
date.timezone = PRC

3.2.7 启动服务

service zabbix-server start
servivce httpd start

3.2.8 配置页面

打开 http://192.168.8.3/zabbix 后,配置相关选项
安装要求检查



数据库配置

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">


zabbix-server


安装预览


完毕后,能够使用默认管理员用户admin/zabbix进行登录


4. 配置Zabbix Agent和MPM

4.1 zabbix agent配置

yum的配置上一部分已经说了,直接安装
yum install zabbix-agent
yum install zabbix-sender

配置/etc/zabbix/zabbix_agentd.conf

Server=192.168.8.3
ServerActive=192.168.8.3
Hostname=oneproxy-vm

4.2 MPM安装配置

4.2.1 安装依赖包

yum install perl-File-Which perl-libwww-perl perl-Digest-SHA perl-DBD-MySQL perl-Time-HiRes perl-Crypt-SSLeay

4.2.2 软件介绍

到官网http://www.fromdual.com/ 下载MPM的相关版本号。这里我使用的是mysql_performance_monitor-0.9.3.tar.gz。(PS:最新的0.10版本号没有相关文档,简直坑啊!)

解压缩软件包后,会发现有两个文件mysql_performance_monitor_agent-0.9.3.tar.gz和mysql_performance_monitor_templates-0.9.3.tar.gz。当中mysql_performance_monitor_agent-0.9.3.tar.gz是放在监控机器上的配置信息。mysql_performance_monitor_templates-0.9.3.tar.gz则是要让我们导入到zabbix server的模板数据。


4.2.3 模板导入

登录到我们的zabbix server服务器上,通过Configuration-->Templates-->Import进行模板导入

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

将mysql_performance_monitor_templates-0.9.3.tar.gz解压缩后Template_FromDual.MySQL.mpm.xml是必须导入的,我们优先导入。其它的大家依据需求进行导入。我这里是将全部模板导入了。

4.2.4 创建监控host

通过Configuration-->Host groups创建一个用户组。我这里创建名称为mpm的用户组。


通过Configuration-->Hosts创建一个用户,将其增加到mpm用户组中。关联的Template使用我们导入的。

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">


关联Template



ok,我们的server端就配置完成了。

4.2.5 MPM agent配置

解压缩我们的agent软件包mysql_performance_monitor_agent-0.9.3.tar.gz。将其放到/opt文件夹下
mv mysql_performance_monitor_agent-0.9.3 /opt/mysql_performance_monitor_agent
cd /opt/mysql_performance_monitor_agent/etc
cp FromDualMySQLagent.conf.template /etc/zabbix/FromDualMySQLagent.conf
mkdir -p /var/log/zabbix /var/log/zabbix/cache
chown -R zabbix: /var/log/zabbix /var/log/zabbix/cache

编辑/etc/zabbix/zabbix-agent.conf。加入

UserParameter=FromDual.MySQL.check,/opt/mysql_performance_monitor_agent/FromDualMySQLagent.pl /etc/zabbix/FromDualMySQLagent.conf

改动MPM配置文件
[root@oneproxy-vm zabbix]# cat /etc/zabbix/FromDualMySQLagent.conf
[default] # Type of section:
# mysqld for a normal MySQL database
# ndbd for a MySQL cluster
Type = mysqld # Debug levels are:
# 1 is logging only errors
# 2 is logging errors and warnings (this is the default)
# 3 logs some informations messages as well
# 4 logs everything (for debugging purposes only) Debug = 2
LogFile = /var/log/zabbix/FromDualMySQLagent.log
# Directory where the Cache files should be written to:
CacheFileBase = /var/log/zabbix/cache/FromDualAgentCache # If you agent is not located in the same time zone as your server
# For US something like -6.0 to our MaaS Server
# For Asia something like +7.0 to our MaaS Server
# TimeShift = +0.0 # Information for MySQL connections:
Username = root
Password = 123456
MysqlHost = 127.0.0.1
MysqlPort = 3306 # Zabbix Server IP address
ZabbixServer = 192.168.8.3
</pre><pre name="code" class="html"># If section is disabled
Disabled     = false # Possible modules for databases are:
# process mysql myisam aria innodb pbxt ndb master slave drbd galera memcache
# Possible modules for servers are:
# mpm server
# Usual modules are
Modules      = process mysql myisam innodb
[oneproxy-vm] # This MUST match Hostname in Zabbix! Type = mysqld
Username = root
Password = 123456
MysqlHost = 127.0.0.1
MysqlPort = 3306
Modules = process mysql myisam innodb
PidFile = /data/mysql_3306/mysql.pid

当中default字段是默认的,oneproxy-vm字段必须与zabbix-server中配置的hosts名称相等。

其它的依据自己的本地mysql环境进行配置。

给予zabbix对pid文件的读权限和MPM日志的权限
chmod o+r /data/mysql_3306/mysql.pid
touch /var/log/zabbix/FromDualMySQLagent.log
chown -R zabbix:zabbix /var/log/zabbix

启动zabbix-agent就可以
service zabbix-agent start

Zabbix Server和MPM(monitor for mysql)的高速部署的更多相关文章

  1. zabbix server安装详解

    简介 zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以 ...

  2. zabbix 使用自带模板监控mysql

    1.这里可以采用zabbix自带的mysql模版,但是也需要在mysql服务器上准备获取mysql status的脚本chk_mysql.sh,zabbix通过调用这个脚本来获取mysql的运行信息. ...

  3. Zabbix Server 自带模板监控更加灵活MySQL数据库

    Zabbix Server 自带模板监控更加灵活MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.zabbix-agent端配置 1>.修改zabbix的 ...

  4. Zabbix Server 自带模板监控有密码MySQL数据库

    Zabbix Server 自带模板监控有密码MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.Zabbix-agent端的配置 1>.为数据库设置密码 ...

  5. Zabbix Server 自带模板监控无密码MySQL数据库

    Zabbix Server 自带模板监控无密码MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.安装MariaDB 1>.安装MariaDB  [root ...

  6. zabbix启动web界面提示:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

    问题 zabbix启动web界面提示: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' ( ...

  7. zabbix配fpmmm(mpm)数据传送不了问题解决

    我们环境用zabbix mpm来监控mysql,不过最近官网已经不叫mpm了,而是叫fpmmm,理由为: fpmmm is the successor of mpm. mpm was renamed ...

  8. 运维监控-基于yum的方式部署Zabbix Server 4.0 版本

    运维监控-基于yum的方式部署Zabbix Server 4.0 版本 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.如何选择zabbix版本 1>.打开zabbix官方 ...

  9. Zabbix server 3.2安装部署

    zabbix server 前提环境: CentOS 6 Lnmp php需要的包(bcmath,mbstring,sockets,gd,libxml,xmlwriter,xmlreader,ctyp ...

随机推荐

  1. [CF115E]Linear Kingdom Races

    [CF115E]Linear Kingdom Races 题目大意: 有\(n(n\le10^5)\)个物品,编号为\(1\sim n\).选取第\(i\)个物品需要\(c_i\)的代价.另外有\(m ...

  2. mysql 部分参数说明

    log_timestamps [5.7] This variable was added in MySQL 5.7.2. Before 5.7.2, timestamps in log message ...

  3. Redis-用思维导图二天搞定Redis用法。

    Redis整体面貌 Redis基本数据结构 1.String 1.1 数据结构 long len byte数组长度 long free 可用数组长度 char buff[] 数据内容 1.2 命令 键 ...

  4. TPS61040/61041 开关电源稳压器(DC-DC) ADJUST

    Variable Control Voltage Output Voltage Adjust This method is accomplished by connecting a variable ...

  5. VirtualBox 4.3.18 启动虚拟机时显示不能加载 R3模块并退出故障解决一例

    VirtualBox 升级到 4.3.1x后一直问题不断.搜了些资料,发现这货从最近的某个版本开始,为了安全,要校验进程完整性,那些在运行时要注入Virtualbox进程的模块都要进行校验.于是乎出现 ...

  6. Visual Studio IDE 背景色该为保护眼睛色

    将背景颜色改成你想要的背景颜色. 将色调改为:85.饱和度:123.亮度:205->添加到自定义颜色->在自定义颜色选定点确定   就搞定了!

  7. What is the fastest way of (not) logging?

    原文地址:http://www.slf4j.org/faq.html#logging_performance SLF4J supports an advanced feature called par ...

  8. Ext表格控件

    表格控件其实也就是帮我们完成了数据的填充工作而已,具体的数据源.要显示的列,列的定制.数据源中的哪条数据显示在哪个列中等属性还是需要我们自己手动配置的,所以我们分下面几步来完成网格控件的数据绑定: 1 ...

  9. Entity Framework7 入门之全功能.NET(Console, WinForms, WPF等)使用EF7

    昨天,我们介绍了EF的新特性和开发计划,如果你还不了解,请移步 Entity Framework7 有哪些不同?现在开发到什么程度了? .今天,我们开学习全功能.NET(Full .NET)下使用EF ...

  10. UML建模工具Visio 、Rational Rose、PowerDesign的比较

    UML建模工具Visio .Rational Rose.PowerDesign的比较   ROSE是直接从UML发展而诞生的设计工具,它的出现就是为了对UML建模的支持,ROSE一开始没有对数据库端建 ...