Skip to content


Mysql数据库在flickr,fotolog,wikipedia,facebook等知名网站中的使用数量

来源:http://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/

Here is the list of questions and answers from panelists:

 How many servers Number of DBAs How many web servers Number of caching servers Version of MySQL Language, platform Operating System
MySQL

1 M, 3 S

1/10

2

2

5.1.23

Perl,php and bash

Linux fedora

Sun

2 clustered, 2 individual

1.5

160+

8

5.0.21

Lots of stuff (java mostly)

Open Solaris

Flickr

166

At present 0

244

14

5.0.51

Php and some Java

Linux

Fotolog

140 databases on 37 instances

10 instances a DBA

70

40 ( 2 on each, 80 total)

4.11 and 4.4

Php, 90% Java

Solaris 10

Wikipedia

20

None, but everybody is kind of a  DBA

70+200

40 ( 2 on each, 80 total)

Â

Php, c++, python

Fedora / Ubuntu

Facebook

30000 databases, 1800 db servers

2

1200

805

5.0.44 with relay log corruption patch

Php, python, c++ and erlang

Fedora / RHEL

Youtube

I can not say

3

I can not say

 

     

I can not say

     

5.0.24

Python

SuSE 9

Posted in Mysql, 技术, 网站架构.

Tagged with , .


网站架构收集

来自sudone.com 服务器系统架构分析日志

  • csdn.net的系统架构研究
  • 图片服务器的hash架构
  • 天涯bbs系统架构分析
  • v.2008.163.com对新架构的尝试
  • nginx和squid配合搭建的web服务器前端系统
  • nginx作为最前端的web cache系统
  • 新型的大型bbs架构(squid+nginx)
  • 当前比较适用的海量小文件系统架构方案
  • nginx图片服务器的架构方案
  • 来源: http://www.hiadmin.com/网站架构收集/

    DBA notes上果然好东西很多 许多大型(只是访问量,而不是公司规模)的web 2.0的网站架构 上面都有 现在收集整理一下有关网站架构的资料,其中许多来自DBA notes 这种资料.向来可遇不可求啊

    WikiPedia 技术架构学习分享 http://www.dbanotes.net/opensource/wikipedia_arch.html

    YouTube 的架构扩展 http://www.dbanotes.net/opensource/youtube_web_arch.html

    Internet Archive 的海量存储浅析 http://www.dbanotes.net/database/internet_archive_storage.html

    LinkedIn 架构笔记 http://www.dbanotes.net/arch/linkedin.html

    Tailrank 网站架构 http://www.dbanotes.net/review/tailrank_arch.html

    Twitter 的架构扩展: 100 倍性能提升 http://www.dbanotes.net/arch/twitter_arch.html

    财帮子(caibangzi.com)网站架构 http://www.dbanotes.net/arch/caibangzi_web_arch.html

    Yupoo! 的网站技术架构 http://www.dbanotes.net/arch/yupoo_arch.html

    37Signals 架构 http://www.dbanotes.net/arch/37signals_arch.html

    Flickr 的访问统计实现以及其他 http://www.dbanotes.net/arch/flickr_stats_and_dathan.html

    PlentyOfFish 网站架构学习 http://www.dbanotes.net/arch/plentyoffish_arch.html

    Yahoo!社区架构 http://www.dbanotes.net/arch/yahoo_arch.html

    有关 Alexa 与 AOL 部署集群文件系统 http://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html

    eBay 的存储一瞥 http://www.dbanotes.net/arch/ebay_storage.html

    eBay 的数据量 http://www.dbanotes.net/database/ebay_storage.html

    eBay 的数据库分布扩展架构 http://www.dbanotes.net/database/ebay_database_scale_out.html

    eBay 的数据层扩展经验 http://www.dbanotes.net/arch/ebay_db_scale_out.html

    eBay 的应用服务器规模 http://www.dbanotes.net/web/ebay_application_server.html

    性能扩展问题要趁早 http://www.dbanotes.net/arch/scaling_an_early_stage_startup.html

    Scaling an early stage startup

    (function() { var scribd = document.createElement(“script”); scribd.type = “text/javascript”; scribd.async = true; scribd.src = “https://www.scribd.com/javascripts/embed_code/inject.js”; var s = document.getElementsByTagName(“script”)[0]; s.parentNode.insertBefore(scribd, s); })()

    Facebook 的 PHP 性能与扩展性 http://www.dbanotes.net/arch/facebook_php.html

    Skype 用 PostgreSQL 支撑海量用户 http://www.dbanotes.net/arch/skype_postgresql.html

    闲谈 Web 图片服务器 http://www.dbanotes.net/web/web_image_server.html

    说说北京奥运购票系统瘫痪这事儿 http://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html

    Architectures You’ve Always Wondered About http://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82

    eBay’s Architectural Principles http://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf

    Building a large scale SaaS app http://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf

    Scaling an early stage startup

    (function() { var scribd = document.createElement(“script”); scribd.type = “text/javascript”; scribd.async = true; scribd.src = “https://www.scribd.com/javascripts/embed_code/inject.js”; var s = document.getElementsByTagName(“script”)[0]; s.parentNode.insertBefore(scribd, s); })()

    互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载) http://www.flashmov.com/blog_1632.html

    QQ游戏百万人同时在线服务器架构实现 http://www.libing.net.cn/read.php?41

    大型Web2.0站点构建技术初探 http://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx

    Web站点数据库分布存储浅谈 http://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx

    QQ的架构讨论 http://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285

    Notes from Scaling MySQL – Up or Out http://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/

    Yapache-Yahoo! Apache 的秘密 http://www.dbanotes.net/web/yapache_yahoo_apache.html

    LinkedIn 架构与开发过程 http://www.dbanotes.net/arch/linkedin_soa.html

    Scalability Best Practices: Lessons from eBay http://www.infoq.com/articles/ebay-scalability-best-practices

    看 Twitter 人谈架构扩展问题 http://www.dbanotes.net/arch/twitter_interview.html

    Facebook 海量数据处理 http://www.dbanotes.net/arch/facebook_photos_arch.html

    web 2.0海量小文件cache集群探讨 http://www.ourlinux.net/operation-tips/web20-small-file-cache-cluster/

    2008-10-09 Cocolog 从 PostgreSQL 迁移到 MySQL 的经验 http://www.dbanotes.net/arch/cocolog_postgresql_mysql.html

    疯狂代码:大型网站架构系列(未完待续)收藏 http://blog.csdn.net/heiyeshuwu/archive/2008/10/01/3006964.aspx

    Amazon Architecture http://highscalability.com/amazon-architecture

    Scaling Twitter http://highscalability.com/scaling-twitter-making-twitter-10000-percent-faster

    37signals Architecture http://highscalability.com/37signals-architecture

    Digg Architecture http://highscalability.com/digg-architecture

    Flickr Architecture http://highscalability.com/flickr-architecture

    YouTube Architecture http://highscalability.com/youtube-architecture

    Google Architecture http://highscalability.com/google-architecture

    LiveJournal’s Backend http://www.danga.com/words/2005_mysqlcon/mysql-slides-2005.pdf

    LiveJournal Architecture http://highscalability.com/livejournal-architecture

    eBay Architecture http://highscalability.com/ebay-architecture

    LinkedIn Architecture http://highscalability.com/linkedin-architecture-0

    Posted in 技术, 网站架构.

    Tagged with .


    在线迁移ucenter数据库

    1.情况: 现有服务器数台。 A:新DB server B:旧DB server C:多台APP server

    由于机房问题导致C不能连接B,现在将B的ucenter数据库迁至A机(A和B的mysql版本一致) 注意:使用直接拷迁贝方式,迁移时会影响在线业务的使用

    2.准备工作 A机使用phpmyadmin创建C机程序所需用户,并刷新权限 下载并修改C机程序的相关数据库配置文件 B机修改my.cnf,开启query log,如果数据库迁移后程序依然往这里写,可以进行补救

    log = /opt/mysql/var/query_log.log

    reload B机 mysql

    /opt/mysql/bin/mysql reload

    3.开始迁移 在B机上打开2个ssh客户端。 在1客户端上锁定B机数据库,此时访问有写请求的程度时会出错长时间不响应,或404错误 锁表可能会有写丢失,关闭mysql后再拷靠谱点。

    /opt/mysql/bin/mysql -uroot -p #输入root密码 mysql>FLUSH TABLES WITH READ LOCK;

    执行锁定后,另一个客户端开始打包

    cd /opt/mysql/var tar cf ucenter.tar ucenter #移至可以下载目录 mv ucenter.tar /opt/lampp/htdocs/sns/

    4.下载解压并启用新数据库 A机,下载数据库并解压

    cd /opt/mysql/var wget -c http://i.c1gstudio.com/ucenter.tar tar xf ucenter.tar mv ucenter.tar ..

    让数据库生效

    /opt/mysql/bin/mysql reload

    5.更新数据库配置文件 C机上机并更新程序配置文件

    6.检查迁移情况 通过phpmyadmin查看更新情况 正常情况下A机ucenter不断更新

    7.解锁 B机,释放锁

    mysql>UNLOCK TABLES;

    这时B机的ucenter库应该不再有更新。

    7.清理文件 迁移已完成,按需要进行清理

    B机 删除mysql旧账号 关闭query log

    #log = /opt/mysql/var/query_log.log

    删除ucenter数据库,reload B机 mysql

    rm -rf /opt/mysql/var/discuz /opt/mysql/bin/mysql reload

    删除数据库打包文件

    rm /opt/lampp/htdocs/sns/ucenter.tar

    A机 删除打包文件

    rm /opt/mysq/discuz.tar

    Posted in Mysql, 技术.

    Tagged with , .


    软件项目版本号的命名规则及格式介绍

     版本控制比较普遍的 3 种命名格式 :   一、GNU 风格的版本号命名格式 :   主版本号 . 子版本号 [. 修正版本号 [. 编译版本号 ]]   英文对照 : Major_Version_Number.Minor_Version_Number[.Revision_Number[.Build_Number]]   示例 : 1.2.1, 2.0, 5.0.0 build-13124   二、Windows 风格的版本号命名格式 :   主版本号 . 子版本号 [ 修正版本号 [. 编译版本号 ]]   英文对照 : Major_Version_Number.Minor_Version_Number[Revision_Number[.Build_Number]]   示例: 1.21, 2.0   三、.Net Framework 风格的版本号命名格式:   主版本号.子版本号[.编译版本号[.修正版本号]]   英文对照: Major_Version_Number.Minor_Version_Number[.Build_Number[.Revision_Number]]   版本号由二至四个部分组成:主版本号、次版本号、内部版本号和修订号。主版本号和次版本号是必选的;内部版本号和修订号是可选的,但是如果定义了修订号部分,则内部版本号就是必选的。所有定义的部分都必须是大于或等于 0 的整数。   应根据下面的约定使用这些部分:   Major :具有相同名称但不同主版本号的程序集不可互换。例如,这适用于对产品的大量重写,这些重写使得无法实现向后兼容性。   Minor :如果两个程序集的名称和主版本号相同,而次版本号不同,这指示显著增强,但照顾到了向后兼容性。例如,这适用于产品的修正版或完全向后兼容的新版本。   Build :内部版本号的不同表示对相同源所作的重新编译。这适合于更改处理器、平台或编译器的情况。   Revision :名称、主版本号和次版本号都相同但修订号不同的程序集应是完全可互换的。这适用于修复以前发布的程序集中的安全漏洞。   程序集的只有内部版本号或修订号不同的后续版本被认为是先前版本的修补程序 (Hotfix) 更新。   版本号管理策略   一、 GNU 风格的版本号管理策略:   1.项目初版本时 , 版本号可以为 0.1 或 0.1.0, 也可以为 1.0 或 1.0.0, 如果你为人很低调 , 我想你会选择那个主版本号为 0 的方式 ;   2.当项目在进行了局部修改或 bug 修正时 , 主版本号和子版本号都不变 , 修正版本号加 1;   3. 当项目在原有的基础上增加了部分功能时 , 主版本号不变 , 子版本号加 1, 修正版本号复位为 0, 因而可以被忽略掉 ;   4.当项目在进行了重大修改或局部修正累积较多 , 而导致项目整体发生全局变化时 , 主版本号加 1;   5.另外 , 编译版本号一般是编译器在编译过程中自动生成的 , 我们只定义其格式 , 并不进行人为控制 .   二、 Window 下的版本号管理策略:   1.目初版时 , 版本号为 1.0 或 1.00;   2. 当项目在进行了局部修改或 bug 修正时,主版本号和子版本号都不变 , 修正版本号加 1;   3. 当项目在原有的基础上增加了部分功能时 , 主版本号不变 , 子版本号加 1, 修正版本号复位为 0, 因而可以被忽略掉 ;   4. 当项目在进行了重大修改或局部修正累积较多 , 而导致项目整体发生全局变化时 , 主版本号加 1;   5. 另外 , 编译版本号一般是编译器在编译过程中自动生成的 , 我们只定义其格式 , 并不进行人为控制 .   另外 , 还可以在版本号后面加入 Alpha, Beta, Gamma, Current, RC (Release Candidate), Release, Stable 等后缀 , 在这后缀后面还可以加入 1 位数字的版本号 .   对于用户来说 , 如果某个软件的主版本号进行了升级 , 用户还想继续那个软件 , 则发行软件的公司一般要对用户收取升级费用 ; 而如果子版本号或修正版本号发生了升级 , 一般来说是免费的 . 附: alphal 内部测试版    beta 外部测试版    demo 演示版    Enhance 增强版或者加强版 属于正式版    Free 自由版    Full version 完全版 属于正式版    shareware 共享版    Release 发行版 有时间限制    Upgrade 升级版    Retail 零售版    Cardware 属共享软件的一种,只要给作者回复一封电邮或明信片即可。(有的作者并由此提供注册码等),目前这种形式已不多见。    Plus 属增强版,不过这种大部分是在程序界面及多媒体功能上增强。    Preview 预览版    Corporation & Enterprise 企业版    Standard 标准版    Mini 迷你版也叫精简版只有最基本的功能    Premium — 贵价版    Professional — 专业版    Express — 特别版    Deluxe — 豪华版    Regged — 已注册版    CN — 简体中文版    CHT — 繁体中文版    EN — 英文版    Multilanguage — 多语言版   注释:   α版   此版本表示该软件仅仅是一个初步完成品,通常只在软件开发者内部交流,也有很少一部分发布给专业测试人员。一般而言,该版本软件的 bug 较多,普通用户最好不要安装。   β(beta)版   该版本相对于α版已有了很大的改进,消除了严重的错误,但还是存在着一些缺陷,需要经过大规模的发布测试来进一步消除。这一版本通常由软件公司免费发布,用户可从相关的站点下载。通过一些专业爱好者的测试,将结果反馈给开发者,开发者们再进行有针对性的修改。该版本也不适合一般用户安装。   γ版   该版本已经相当成熟了,与即将发行的正式版相差无几,如果用户实在等不及了,尽可以装上一试。   trial(试用版)   试用版软件在最近的几年里颇为流行,主要是得益于互联网的迅速发展。该版本软件通常都有时间限制,过期之后用户如果希望继续使用,一般得交纳一定的费用进行注册或购买。有些试用版软件还在功能上做了一定的限制。   unregistered(未注册版)   未注册版与试用版极其类似,只是未注册版通常没有时间限制,在功能上相对于正式版做了一定的限制,例如绝大多数网络电话软件的注册版和未注册版,两者之间在通话质量上有很大差距。还有些虽然在使用上与正式版毫无二致,但是动不动就会弹出一个恼人的消息框来提醒你注册,如看图软件 acdsee 、智能陈桥汉字输入软件等。   demo版   也称为演示版,在非正式版软件中,该版本的知名度最大。 demo 版仅仅集成了正式版中的几个功能,颇有点像 unregistered 。不同的是, demo 版一般不能通过升级或注册的方法变为正式版。   以上是软件正式版本推出之前的几个版本,α、β、γ可以称为测试版,大凡成熟软件总会有多个测试版,如 windows 98 的β版,前前后后将近有 10 个。这么多的测试版一方面为了最终产品尽可能地满足用户的需要,另一方面也尽量减少了软件中的 bug 。而 trial 、 unregistered 、 demo 有时统称为演示版,这一类版本的广告色彩较浓,颇有点先尝后买的味道,对于普通用户而言自然是可以免费尝鲜了。   正式版 不同类型的软件的正式版本通常也有区别。   release   该版本意味“最终释放版”,在出了一系列的测试版之后,终归会有一个正式版本,对于用户而言,购买该版本的软件绝对不会错。该版本有时也称为标准版。 一般情况下, release 不会以单词形式出现在软件封面上,取而代之的是符号 (r) ,如 windows nt(r) 4.0 、 ms-dos(r) 6.22 等。   registered   很显然,该版本是与 unregistered 相对的注册版。注册版、 release 和下面所讲的 standard 版一样,都是软件的正式版本,只是注册版软件的前身有很大一部分是从网上下载的。   standard   这是最常见的标准版,不论是什么软件,标准版一定存在。标准版中包含了该软件的基本组件及一些常用功能,可以满足一般用户的需求。其价格相对高一级版本而言还是“平易近人”的。   deluxe   顾名思义即为“豪华版”。豪华版通常是相对于标准版而言的,主要区别是多了几项功能,价格当然会高出一大块,不推荐一般用户购买。此版本通常是为那些追求“完美”的专业用户所准备的。   reference   该版本型号常见于百科全书中,比较有名的是微软的 encarta 系列。 reference 是最高级别,其包含的主题、图像、影片剪辑等相对于 standard 和 deluxe 版均有大幅增加,容量由一张光盘猛增至三张光盘,并且加入了很强的交互功能,当然价格也不菲。可以这么说,这一版本的百科全书才能算是真正的百科全书,也是发烧友们收藏的首选。   professional(专业版)   专业版是针对某些特定的开发工具软件而言的。专业版中有许多内容是标准版中所没有的,这些内容对于一个专业的软件开发人员来说是极为重要的。如微软的 visual foxpro 标准版并不具备编译成可执行文件的功能,这对于一个完整的开发项目而言显然是无法忍受的,若客户机上没有 foxpro 将不能使用。如果用专业版就没有这个问题了。   enterprise(企业版)   企业版是开发类软件中的极品(相当于百科全书中的 reference 版)。拥有一套这种版本的软件可以毫无障碍地开发任何级别的应用软件。如著名的 visual c++ 的企业版相对于专业版来说增加了几个附加的特性,如 sql 调试、扩展的存储过程向导、支持 as/400 对 ole db 的访问等。而这一版本的价格也是普通用户无法接受的。如微软的 visual studios 6.0 enterprise 中文版的价格为 23000 元。   其他版本 除了以上介绍的一些版本外,还有一些专有版本名称。   update(升级版)   升级版的软件是不能独立使用的,该版本的软件在安装过程中会搜索原有的正式版,如果不存在,则拒绝执行下一步。如 microsoft office 2000 升级版、 windows 9x 升级版等等。   OEM版   OEM版通常是捆绑在硬件中而不单独销售的版本。将自己的产品交给别的公司去卖,保留自己的著作权,双方互惠互利,一举两得。   单机(网络)版   网络版在功能、结构上远比单机版复杂,如果留心一下软件的报价,你就会发现某些软件单机版和网络版的价格相差非常大,有些网络版甚至多一个客户端口就要加不少钱。   普及版   该版本有时也会被称为共享版,其特点是价格便宜(有些甚至完全免费)、功能单一、针对性强(当然也有占领市场、打击盗版等因素)。与试用版不同的是,该版本的软件一般不会有时间上的限制。当然,如果用户想升级,最好还是去购买正式版。   以上是一些常见软件版本的简要介绍,随着软件市场行为的变化,现在也出现了一些新的版本命名方式,比如windows xp中的xp是取自于experience中的第二、第三个字母。希望以上内容能够对大家的购买、使用和下载软件有所帮助。   基于商业上考虑,很多的软件都不是非常严谨的遵循这个规则的。最有名的就是微软了。例如他的 NT 系列版本。大家比较熟悉的是从 NT 4.0 开始的。 99 年推出了 windows 2000 , 2001 年退出了 windows xp , 2003 年推出了 windows 2003 ,乍一看版本区别蛮大的,但是看他们的内部版本号就会发现,变化其实并不大,只是界面变化的大了而已。这是软件公司经常干的事情。 Window 2000 的版本号是 NT 5.0 , windows xp 的版本号是 NT 5.1 , windows 2003 的版本号是 NT 5.2 ,而现在的 longhorn 才是真正的 NT 6.0 (印象中是,不敢确认)。这样就可以持续的赚广大客户的钱。毕竟人的眼睛看得东西是最直观的,所以给人感觉也是变化最大的。

    Posted in 其它, 项目管理.

    Tagged with , .


    使用NDOUtils将Nagios监控信息存入mysql

     参考 http://nagios.sourceforge.net/docs/ndoutils/NDOUtils.pdf

    1.NDOUtils安装需求

    nagios mysql cpan DBI #非必需 cpan DBD::mysql #非必需

    2.关联mysql头文件和库 不做关联可能在config或make时出错

    ln -s /opt/mysql/include/* /usr/include/ ln -s /opt/mysql/lib/* /usr/lib/ echo ‘/usr/lib’ >> /etc/ld.so.conf ldconfig -v

    3.安装ndoutils http://sourceforge.net/project/showfiles.php?group_id=26589

    wget -c http://nchc.dl.sourceforge.net/sourceforge/nagios/ndoutils-1.4b7.tar.gz tar zxvf ndoutils-1.4b7.tar.gz cd ndoutils-1.4b7 ./configure –prefix=/usr/local/nagios –enable-mysql –disable-pgsql LDFLAGS=-L/opt/mysql/lib –with-mysql-inc=/opt/mysql/include/mysql –with-mysql-lib=/opt/mysql/lib/mysql

    *config时使用以下mysql参数

    –with-mysql-inc=/opt/mysql/include –with-mysql-lib=/opt/mysql/lib #config成功 #make出错

    *config时使用以下mysql参数

    –with-mysql-inc=/opt/mysql/include/mysql –with-mysql-lib=/opt/mysql/lib/mysql #config出错 #make成功并生成文件 #启动ndo2db会出错

    *没有LDFLAGS=-L/opt/mysql/lib

    LDFLAGS=-L/opt/mysql/lib #ndo2db不能导入到数据库

    相关错误

    In file included from io.c:10: ../include/config.h:261:25: mysql/mysql.h: 没有那个文件或目录 ../include/config.h:262:26: mysql/errmsg.h: 没有那个文件或目录 make[1]: *** [io.o] 错误 1 checking for mysql/mysql.h… no *** MySQL include file could not be located… ********************** You chose to compile NDBXT with MySQL support, but I was unable to locate on your system. If the include file is installed, use the –with-mysql-inc argument to specify the location of the MySQL include file. make ll ./src

    看看是否有以下文件 ndo2db-2x ndo2db-3x ndomod-2x.o ndomod-3x.o

    4.拷贝文件 # 我的Nagios是3.0.6,所以拷贝的是ndomod-3x.o、ndo2db-3x,如果你的是2.X.x请拷贝ndomod-2x.o、ndo2db-2x

    cp ./src/ndomod-3x.o /usr/local/nagios/bin cp ./src/ndo2db-3x /usr/local/nagios/bin cp ./src/log2ndo /usr/local/nagios/bin cp ./src/file2sock /usr/local/nagios/bin chown nagios:nagios /usr/local/nagios/bin/*

    5.拷贝配置文件

    cp ./config/ndo* /usr/local/nagios/etc/ chown nagios:nagios /usr/local/nagios/etc/*

    6.创建ndo的mysql 数据库及用户

    CREATE DATABASE `nagios` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT select,insert,update,delete ON nagios.* TO nagiosndo@localhost identified by ‘password123’; FLUSH PRIVILEGES ;

    7.导入数据库结构 使用db/installdb脚本 需要以下支持

    cpan DBI cpan DBD::mysql
    cd ./db/ ./installdb -u root -p 123456 -h localhost -d nagios

    用命令导入(其实和用脚本是一回事,也可以用phpmyadmin来导入)

    /opt/mysql/bin/mysql -u root -p -D nagios -h localhost

    输入密码

    成功导入59张表

    8.修改配置文件 vi /usr/local/nagios/etc/ndo2db.cfg

    db_user=nagiosndo db_pass=password123

    vi /usr/local/nagios/etc/nagios.cfg

    # 修改下面参数的值为-1(一般默认如此)。 event_broker_options=-1 # 复制下面内容粘贴到#broker_module=…下面。 # 注意broker_module= 和config_file是在一行上 # Uncomment the line below if you’re running Nagios 3.x broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg

    9.启动ndo2db

    /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg echo ‘rm -f /usr/local/nagios/var/ndo.sock’ >> /etc/rc.local echo ‘/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg’ >> /etc/rc.local #开机启动 Support for the specified database server is either not yet supported, or was not found on your system. /usr/local/nagios/bin/ndo2db-3x: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory

    出现以上错误请执行第2步

    10.重启动nagios

    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg service nagios restart

    一般情况下到此已完成安装,可以去数据库里看下记录有无增加

    11.检查安装是否正确

    tail -20 /usr/local/nagios/var/nagios.log

    [1242971625] ndomod: Successfully flushed 80 queued items to data sink. [1242971625] ndomod: Error writing to data sink! Some output may get lost…

    貌似有点问题 参考: http://www.nagios.net.cn/blog/blog.php?do-showone-itemid-62-type-blog.html

    先改成输出成文件 #vi ndomod.cfg

    instance_name=default #output_type=tcpsocket #output=127.0.0.1 output_type=file output=/usr/local/nagios/var/ndo.dat service nagios restart

    看看有没有/usr/local/nagios/var/ndo.dat文件,ok,发现文件,说明第一步可以生成文件 查看文件内容

    cd /usr/local/nagios/var/ head -30 ndo.dat HELLO PROTOCOL: 2 AGENT: NDOMOD AGENTVERSION: 1.4b7 STARTTIME: 1243393299 DISPOSITION: REALTIME CONNECTION: FILE CONNECTTYPE: INITIAL INSTANCENAME: default STARTDATADUMP 202: 1=300 2=0 3=0 4=1243393292.450675 73=1243393292 74=262144 72=ndomod: Error writing to data sink! Some output may get lost… 999 201: 1=205 2=0

    使用file2sock尝试socket方式

    ../bin/file2sock -s /usr/local/nagios/var/ndo.dat -d /usr/local/nagios/var/ndo.sock -t unix -p 5668

    Error while writing to destination socket: Connection reset by peer

    尝试tcp方式 vi ndo2db.cfg

    #socket_type=unix socket_type=tcp

    重新载入ndo2db

    ps aux|grep ndo2db kill $pid /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg ../bin/file2sock -s ndo.dat -d localhost -t tcp -p 5668

    Error while writing to destination socket: Connection reset by peer

    依然不行,重新编译ndoutils并加上 LDFLAGS=-L/opt/mysql/lib 参考 http://www.itnms.net/discuz/viewthread.php?tid=1357&extra=pageD1&page=1

    ./configure –prefix=/usr/local/nagios –enable-mysql –disable-pgsql LDFLAGS=-L/opt/mysql/lib –with-mysql-inc=/opt/mysql/include/mysql –with-mysql-lib=/opt/mysql/lib/mysql make #再执行一下安装过程后,通过

    ================= 200912-07 更新

    tail /var/log/messages

    Dec 7 14:09:13 localhost nagios: ndomod: Still unable to connect to data sink. 10547 items lost, 5000 queued items to flush. Dec 7 14:09:29 localhost nagios: ndomod: Still unable to connect to data sink. 10746 items lost, 5000 queued items to flush.

    连接不到mysql,重启一下

    /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg

    Could not bind socket: Address already in use

    ps aux|grep ndo2db 没有

    查看套接字文件是否存在,删除之 ll /usr/local/nagios/var/ndo.sock rm /usr/local/nagios/var/ndo.sock

    重启 /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg

    tail /var/log/messages

    Dec 7 14:09:45 localhost nagios: ndomod: Successfully connected to data sink. 10861 items lost, 5000 queued items to flush. Dec 7 14:09:45 localhost nagios: ndomod: Successfully flushed 5000 queued items to data sink. Dec 7 14:09:45 localhost ndo2db-3x: Successfully connected to MySQL database

    解决

    Posted in Nagios.

    Tagged with , , .


    telnet 退出的命令

    telnet localhost 5668 Trying 127.0.0.1… Connected to localhost.localdomain (127.0.0.1). Escape character is ‘^]’.

    试了下建入q,quit,exit,然后ctrl+c,ctrl+d,ctrl+z,ctrl+q,esc无果。。。

    仔细看看上面的提示明明写着“Escape character is ‘^]’.” ctrl+]然后q

    提示还是很重要的,郁闷下下

    Posted in Linux 命令, 技术.

    Tagged with .


    c10k 问题 简介

    编写连接数巨大的高负载服务器程序时,经典的多线程模式和select模式都不再适用。 应当抛弃它们,采用epoll/kqueue/dev_poll来捕获I/O事件。

    C10K问题 由来

    网络服务在处理数以万计的客户端连接时,往往出现效率低下甚至完全瘫痪,这被称为 C10K问题。随着互联网的迅速发展,越来越多的网络服务开始面临C10K问题,作为大型 网站的开发人员有必要对C10K问题有一定的了解。

    C10K问题的最大特点是:设计不够良好的程序,其性能和连接数及机器性能的关系往往 是非线性的。举个例子:如果没有考虑过C10K问题,一个经典的基于select的程序能在 旧服务器上很好处理1000并发的吞吐量,它在2倍性能新服务器上往往处理不了并发 2000的吞吐量。

    这是因为在策略不当时,大量操作的消耗和当前连接数n成线性相关。会导致单个任务 的资源消耗和当前连接数的关系会是O(n)。而服务程序需要同时对数以万计的socket进 行I/O处理,积累下来的资源消耗会相当可观,这显然会导致系统吞吐量不能和机器性 能匹配。为解决这个问题,必须改变对连接提供服务的策略。

    详细内容参看 http://www.kegel.com/c10k.html

    Posted in 其它, 文档理论.

    Tagged with .


    Trac 介绍

    版权声明:可以任意转载,但转载时必须标明原作者charlee、原始链接http://tech.idv2.com/2007/02/10/trac-intro/以及本声明。

    Trac,一个基于Web的bug管理系统。

    Trac拥有强大的bug管理功能,并集成了Wiki用于文档管理。它还支持代码管理工具Subversion,这样可以在 bug管理和Wiki中方便地参考程序源代码。

    bug管理

    在Trac中,项目中出现的问题称为ticket。像bug、功能改进、 TODO等都可以写成一个ticket。

    • 可设置ticket的优先级别。
    • 可以设置ticket的里程碑,表明这个ticket应在何时完成,并能够通过条形图方式显示里程碑的完成度。
    • 可以自定义条件生成bug报告,并可以通过SQL语句自定义报告的格式。

    Subversion集成

    通过Subversion集成,开发者可在Trac中以Web方式浏览代码库中各个版本的代码和代码的修改历史,并可方便地比较各个版本间的差别。

    Wiki

    支持常用的Wiki语法。同时增加了许多bug管理的专用标记,可以方便地创建到ticket、代码行甚至修改历史的链接。

    Trac使用Python写成,后台使用SQLite或PostgreSQL数据库,因此构筑一个完整的Trac系统需要安装以下软件:

    • Apache
    • Python
    • Subversion
    • PostgreSQL(可选)

    Posted in 项目管理.

    Tagged with .


    Nagios 定义hostescalation控制报警频率

    最近上海移动机房在做调整(调到现在还没搞完…都换了几次IP了),导致nagios服务器不能连通应用服务器。 然后nagios每半小时就给我发短信囧,受不了了

    1.hostescalation定义格式;蓝色为可选项

    define hostescalation{
      host_name host_name
      hostgroup_name hostgroup_name
      contacts contacts
      contact_groups contactgroup_name
      first_notification #
      last_notification #
      notification_interval #
      escalation_period timeperiod_name
      escalation_options [d,u,r]
        }

    2.定义hostescalation将报警频率延长 vi /usr/local/nagios/etc/objects/lavida.cfg

    define host{ use linux-server,host-pnp host_name lavida alias apply address 192.168.1.2 check_command check-host-alive max_check_attempts 5 check_period 24×7 contact_groups admins notification_interval 60 #正常报警频率改成60分钟 notification_period 24×7 notification_options d,u,r } #第三次到第五次报警频率为120分钟 define hostescalation{ host_name lavida first_notification 3 last_notification 5 notification_interval 120 contact_groups admins } #第6次以后为240分钟一次 define hostescalation{ host_name lavida first_notification 6 #第六次 last_notification 0 #不限次数 notification_interval 240 #4小时,也可以改小成10分钟等 contact_groups admins #可以增加组如:admins,managers }

    3.检查nagios配置

    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

    4.重启nagios

    service nagios reload

    针对service的定义方法

    define serviceescalation{ host_name lavida service_description Root Partition first_notification 6 last_notification 0 notification_interval 240 contact_groups admins }

    参考: http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#hostescalation http://nagios.sourceforge.net/docs/3_0/escalations.html

    Posted in Nagios, 技术.

    Tagged with .


    linux下查看nginx,apache,mysql,php的编译参数[转]

    转自linuxtone.org 哈密瓜 http://bbs.linuxtone.org/thread-2776-1-1.html

    有时候nginx,apache,mysql,php编译完了想看看编译参数可以用以下方法

    nginx编译参数: #/usr/local/nginx/sbin/nginx -V

    nginx version: nginx/0.6.32 built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42) configure arguments: –user=www –group=www –prefix=/usr/local/nginx/ –with-http_stub_status_module –with-openssl=/usr/local/openssl

    apache编译参数:

    cat /usr/local/apache2/build/config.nice

    #! /bin/sh # # Created by configure “./configure” \ “–prefix=/usr/local/apache2” \ “–with-included-apr” \ “–enable-so” \ “–enable-deflate=shared” \ “–enable-expires=shared” \ “–enable-rewrite=shared” \ “–enable-static-support” \ “–disable-userdir” \ “$@”

    php编译参数:

    /usr/local/php/bin/php -i |grep configure

    Configure Command => ‘./configure’ ‘–prefix=/usr/local/php’ ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–with-config-file-path=/usr/local/php/etc’ ‘–with-mysql=/usr/local/mysql’ ‘–with-libxml-dir=/usr/local/libxml2/bin’ ‘–with-gd=/usr/local/gd2’ ‘–with-jpeg-dir’ ‘–with-png-dir’ ‘–with-bz2’ ‘–with-xmlrpc’ ‘–with-freetype-dir’ ‘–with-zlib-dir’

    mysql编译参数:

    cat /usr/local/mysql/bin/mysqlbug|grep configure

    # This is set by configure CONFIGURE_LINE=”./configure ‘–prefix=/usr/local/mysql’ ‘–localstatedir=/var/lib/mysql’ ‘–with-comment=Source’ ‘–with-server-suffix=-Linuxtone’ ‘–with-mysqld-user=mysql’ ‘–without-debug’ ‘–with-big-tables’ ‘–with-charset=gbk’ ‘–with-collation=gbk_chinese_ci’ ‘–with-extra-charsets=all’ ‘–with-pthread’ ‘–enable-static’ ‘–enable-thread-safe-client’ ‘–with-client-ldflags=-all-static’ ‘–with-mysqld-ldflags=-all-static’ ‘–enable-assembler’ ‘–without-isam’ ‘–without-innodb’ ‘–without-ndb-debug'”

    我补充下mysql_config也可以获得编译参数

    Posted in Apache, Mysql, Nginx, PHP, 技术.

    Tagged with , , , , .