search
HomeDatabaseMysql Tutorial日均百万PV架构第四弹(分布式监控)_MySQL

应该能更早出的第四弹,被虚拟机错误搅乱,迟迟没有上线,不得已将所有

节点用puppet完成上线,稍后整理第五弹(非你不可自动化)也即将上线 : )

wKiom1N4mKWiPepeAAF1cIW1BPs388.jpg

zabbix简介
   zabbix是基于Php的开源监控软件
   基于多重数据采集 SNMP , Agent , Ping , Port
   多重告警通知 Mail , Jabber , SMS
   可以完成多种操作平台甚至于设备(route,switch,io)的监控工作
   易于定制重用(模板机制,函数),甚至于二次开发
   告警及时几乎无延迟
   它与cacti最大的不同之处在于它还提供一个分布式企业监控解决方案

zabbix组成
   zabbix-server 主要完成监控数据的存储与分析告警
   zabbix-proxy 分布式环境重要一环,提server完成的数据存储压力
   zabbix-agent 数据采集重要节点
   zabbix-web 数据展示与监控配置
   这些节点便完成了自动化监控中: 数据采集 , 数据存储 , 数据展示 , 分析告警

zabbix组件关系示意

wKioL1N4mJWTwJQrAAF31fzdbT0477.jpg

规划如下

server.king.com 172.16.43.6  192.168.43.6

       zabbix-server , zabbix-web , php , httpd , mysql

proxy.king.com 172.16.43.5

       zabbix-proxy , mysql

slave1-4.king.com 172.16.43.1-4

配置过程如下

1 配置安装zabbix-server(172.16.43.6)

i)准备如下文件zabbix-2.0.8-3.el6.x86_64.rpmzabbix-get-2.0.8-3.el6.x86_64.rpmzabbix-server-2.0.8-3.el6.x86_64.rpmzabbix-server-mysql-2.0.8-3.el6.x86_64.rpmzabbix-web-2.0.8-3.el6.noarch.rpmzabbix-web-mysql-2.0.8-3.el6.noarch.rpmmariadb-10.0.10-linux-x86_64.tar.gz(安装过程参见)php-5.4.26.tar.bz2(安装过程参见)httpd-2.2(系统自带)##ii)安装配置yum -y install *.rpm# 创建zabbix数据库及账号mysql -e "create database zabbix;"mysql -e "grant all on *.* to 'zabbix'@'172.16.%.%' identified by 'zabbix';"mysql -e "flush privileges;"# 导入zabbix web所需表mysql -h172.16.43.6 -uzabbix -p -D zabbix <p># 查看10051端口是否开启</p><p><img src="/static/imghwm/default1.png" data-src="http://img.bitscn.com/upimg/allimg/c140719/1405KI3Y21Z-93U8.jpg" class="lazy" title="2.png" alt="wKiom1N4mbqyEnxKAAopgQpwTYI698.jpg"></p><p># 浏览器访问配置</p><p>http://172.16.43.6/zabbix</p><p><img src="/static/imghwm/default1.png" data-src="http://img.bitscn.com/upimg/allimg/c140719/1405KI3940620-103040.jpg" class="lazy" title="3.png" alt="wKiom1N4mdPCpyCnAAxjGdI64ks946.jpg"></p><p>2 代理服务器安装配置(172.16.43.5)</p><pre class="brush:php;toolbar:false">i) 准备如下文件zabbix-2.0.8-3.el6.x86_64.rpmzabbix-proxy-2.0.8-3.el6.x86_64.rpmzabbix-proxy-mysql-2.0.8-3.el6.x86_64.rpmmariadb-10.0.10-linux-x86_64.tar.gz(安装过程参见)##ii) 安装配置yum -y install *.rpm# 创建zabbix数据库及账号mysql -e "create database zabbixproxy;"mysql -e "grant all on *.* to 'zabbixproxy'@'172.16.%.%' identified by 'zabbixproxy';"mysql -e "flush privileges;"# 导入zabbix web所需表mysql -h172.16.43.5 -uroot -p -D zabbixproxy <p># 查看10051端口是否开启</p><p><img src="/static/imghwm/default1.png" data-src="http://img.bitscn.com/upimg/allimg/c140719/1405KI3a3440-11YW.jpg" class="lazy" title="4.png" alt="wKioL1N4mffgnlebAAn8w8HKIOM463.jpg"></p><p>3 客户端配置(172.16.43.1 - 172.16.43.4)</p><pre class="brush:php;toolbar:false">i) 准备如下文件zabbix-2.0.8-3.el6.x86_64.rpmzabbix-agent-2.0.8-3.el6.x86_64.rpm zabbix-sender-2.0.8-3.el6.x86_64.rpm##ii) 安装配置yum -y install zabbix-2.0.8-3.el6.x86_64.rpm zabbix-agent-2.0.8-3.el6.x86_64.rpm zabbix-sender-2.0.8-3.el6.x86_64.rpm# 编辑配置文件vim /etc/zabbix/zabbix_agentd.confServer=172.16.43.5 (#86)ServerActive=172.16.43.5 (#127)Hostname=slave4.king.com (#138)# 启动zabbix-agent服务service zabbix-agent start

# 查看10050端口是否开启

4. 配置自动发现规则将客户端添加至监控体系

# 配置代理服务器

Administration -> DM -> Create Proxy (均指在WebGui下菜单栏路径)

wKiom1N4mp7g8iSoAAEOhZt7uyQ370.jpg

# 配置自动发现规则

Configuration -> Discovery -> Create discovery rule ->

wKioL1N4mqvCxrsmAAGS4mwglAI194.jpg

# 配置发现后的动作

Configuration -> Actions -> Create action -> Event source(Discovery) ->

wKioL1N4msjCQ-LVAAHLAK7rMVw909.jpg

wKiom1N4mvTCMDMOAAIH0sbkzRg341.jpg

wKioL1N4msmjtfC2AAEPU3qz59U014.jpg

# 配置完毕重启zabbix-proxy等待即可

wKiom1N4nT-jrNHbAAbR5CNqfPU505.jpg

wKioL1N4nRTQdR9AAAOVWq_jCZc624.jpg

5. 使用基本规则完成对cpu,io,net参数的监控

# zabbix内置了很多模板,我们可以使用来完成第5项的监控

# 改动刚才Actions除了发现主机将主机添加至监控列表外,额外定义link to templates即可

# 可以选择 Template OS Linux

# 这样发现之后的主机便可以完成对cpu,io,net的基本监控

wKioL1N4nTjCjTpSAAJxRuf7vwc822.jpg

# 最后我们还可以定义自动移除规则

Configuration -> Actions -> Create action -> Event source(Discovery) ->

wKiom1N4nYGDlENiAAHlSxqaTQI873.jpg

6. 使用自定义函数完成对 nginx , varnish , mysql等服务的监控

# zabbix已经对mysql的自定义参数做出了范例,我们可以进行访问来完成对更多服务的监控vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf## 监控nginx的连接活动数,访问数,处理个数vim /etc/zabbix/zabbix_agentd.d/nginx.confUserParameter=Nginx.active[*], /usr/bin/curl -s "http://$1:$2/status" | awk '/^Active/ {print $NF}'UserParameter=Nginx.accepted[*], /usr/bin/curl -s "http://$1:$2/status" | awk '/^[ /t]+[0-9]+[ /t]+[0-9]+[ /t]+[0-9]+/ {print $$1}'UserParameter=Nginx.handled[*], /usr/bin/curl -s "http://$1:$2/status" | awk '/^[ /t]+[0-9]+[ /t]+[0-9]+[ /t]+[0-9]+/ {print $$2}'## 监控varnish的连接数,命中数,命中率vim /etc/zabbix/zabbix_agentd.d/varnish.confUserParameter=varnish.conn,/usr/bin/varnishstat -1 | grep "client_conn" | awk '{print $2}' UserParameter=varnish.hit,/usr/bin/varnishstat -1 | grep "cache_hit" | awk '{print $2}'#

# 定义好后可以将自动key添加到item,

wKiom1N4niHQYcG_AASSTFhtx6I752.jpg

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQL: String Data Types and ENUMs?MySQL: String Data Types and ENUMs?May 13, 2025 am 12:05 AM

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

MySQL BLOB: how to optimize BLOBs requestsMySQL BLOB: how to optimize BLOBs requestsMay 13, 2025 am 12:03 AM

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),