zoukankan      html  css  js  c++  java
  • 将Sphinx的日志放置到/dev/shm里需要注意的事情

    可以采用定时器控制,清空日志的办法:

    几种快速清空文件内容的方法:
      $ : > filename #其中的 : 是一个占位符, 不产生任何输出.
      $ > filename
      $ echo “” > filename
      $ echo /dev/null > filename
      $ echo > filename
      $ cat /dev/null > filename

    但是,日志是有一定作用的,比如下面是个例子:Sphinx重建索引失败安例分析

    重建Sphinx索引的时候,可以使用以下命令:
    
    /sphinx/bin/indexer –rotate idx_name
    但是这个命令并不是保证一定能重建成功的,有时候重建了之后,发现新的数据并没有加入到索引里,而从日志可以看到这样的记录:
    
    WARNING: rotating index ‘idx_m_tag’: lock: failed to lock /sphinx/data/idx_m_tag.new.spl: Resource temporarily unavailable; using old index
    WARNING: rotating index ‘idx_n_tag’: lock: failed to lock /sphinx/data/idx_n_tag.new.spl: Bad file descriptor; using old index
    [Sun Mar 24 06:40:01.084 2013] [12413] rotating finished
    日志记录了重建索引失败,继续使用旧的索引这一事实。
    
    要分析这个原因,首先要知道sphinx的重建索引的流程,日志里记录的spl文件,实际是一个空文件,只是sphinx加锁的一个标记而已。重建索引时,会生成新的索引文件,即在原来的文件名字后面加上.new标记为新文件,旧文件不变。然后重启searchd进程,所以我们在执行rotate index的时候会看到这样的输出:
    
    rotating indices: succesfully sent SIGHUP to searchd (pid=12413).
    searchd进程启动后,会执行一个操作,把旧文件命名为.old文件,把.new文件更新为正常的索引文件名,如果有问题,会有 一个回滚的操作。在这个过程中,通过对spl这个文件的加锁和解锁来进行文件切换。
    
    如果对spl的锁争用出现问题,就会导致新的索引文件不生效,这时候的解决办法是手动重启searchd进程。
    
    如何避免这个问题,最简单的就是对sphinx日志进行监控,通过脚本捕捉到lock spl文件失败的情况,马上处理。

     那么一般如何在运维中关注索引的生成情况呢?

    Nagios监控Sphinx的indexer日志
    
    http://os.51cto.com/art/201103/247290.htm
  • 相关阅读:
    洛谷—— P2234 [HNOI2002]营业额统计
    BZOJ——3555: [Ctsc2014]企鹅QQ
    CodeVs——T 4919 线段树练习4
    python(35)- 异常处理
    August 29th 2016 Week 36th Monday
    August 28th 2016 Week 36th Sunday
    August 27th 2016 Week 35th Saturday
    August 26th 2016 Week 35th Friday
    August 25th 2016 Week 35th Thursday
    August 24th 2016 Week 35th Wednesday
  • 原文地址:https://www.cnblogs.com/littlehb/p/3948510.html
Copyright © 2011-2022 走看看