<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    waterye

    2008年10月21日 #

    使用rsync+ssh同步n個文件

    rsync -avz -e ssh bak@192.168.0.138:/home/res /home/res/bak

    posted @ 2009-12-29 20:24 waterye 閱讀(519) | 評論 (0)編輯 收藏

    mysql備份

    1. 使用Replication進行實時備份
    參考mysql docs
    2. 定期在slave上使用shell,mysqldump,sftp,crontab進行永久備份
    #!/bin/sh
    export d
    =`date +%Y%m%d%H%M%S`
    mkdir 
    -/data/dbbak/baktables/$d
    for i in `echo "show tables" | mysql -u bak -ppassword db|grep -v Tables`;
    do    
      echo $i; mysqldump 
    --add-drop-table --allow-keywords ----u bak -ppasswod mbook_hd $i > backup/$d/$i.sql
    done

    tar czf backup
    /$d.tar.gz backup/$d/
    rm 
    -rf backup/$d/

    lftp 
    -"cd /dbbak/; mput -c $d.tar.gz; quit" -u bak,password sftp://192.168.0.138
    參考http://ocaoimh.ie/simple-mysql-backup/
    10G級別的可以每天作一次備份,100G級別看帶寬和硬盤,T級沒有經驗

    posted @ 2009-12-29 20:17 waterye 閱讀(1057) | 評論 (0)編輯 收藏

    檢查哪些文件以\n結束

    #!/usr/bin/env python
    import string, os, sys  
       
    dir 
    = '/home/waterye/works/'  

    files 
    = os.listdir(dir)
    for f in files:
        
    if not os.path.isfile(dir+os.sep+f): continue
        linecount 
    = 0
        fp 
    = open(dir+os.sep+f,'r')
        
    for line in fp:
            linecount 
    += 1
        fp 
    = open(dir+os.sep+f,'r')
        
    for i,line in enumerate(fp):
            
    if (i==linecount-1 and line.endswith('\n')):
                
    print f
                
    print "--------------------------------"
    * bash太難理解,還是用py看上去舒服,雖然不專業(yè),但能完成任務就行

    posted @ 2009-02-19 22:33 waterye 閱讀(913) | 評論 (0)編輯 收藏

    perl milliseconds

    "perldoc DateTime" would have told you how to format milliseconds.

      
    use DateTime;
      
    use Time::HiRes qw(time);
      
    my $dt = DateTime->from_epoch( epoch => time() );
      
    print $dt->strftime('%Y-%m-%d %H-%M-%S-%3N'), "\n";

    * sudo apt-get install libdatetime-perl

    perl真麻煩

    posted @ 2008-12-04 23:33 waterye 閱讀(1073) | 評論 (0)編輯 收藏

    memcached java client

    1. http://www.whalin.com/memcached/ v2.0.1
    2. http://code.google.com/p/spymemcached/ v2.2

    a. 使用whalin版會導致File Descriptor leak,而使用spy版則不會,原因是whalin版沒有使用selector管理socketchannel.
           Thread.sleep(1000 * 30);
            System.out.println(
    "begin");

            Selector selector 
    = null;
            SocketChannel channel 
    = null;
            
    try {
                String host 
    = "192.168.0.74";
                
    int port = 11211;
                
    int timeout = 1000 * 60;

                selector 
    = Selector.open();
                channel 
    = SocketChannel.open();
                channel.configureBlocking(
    false);

                channel.connect(
    new InetSocketAddress(host, port));
                channel.register(selector, channel.validOps());

                
    try {
                    selector.select();
                } 
    catch (IOException e) {
                    e.printStackTrace();
                }

                Iterator it 
    = selector.selectedKeys().iterator();
                
    int i = 0;
                
    while (it.hasNext()) {
                    i
    ++;
                    System.out.println(i);
                    SelectionKey selKey 
    = (SelectionKey) it.next();
                    it.remove();

                    
    try {
                        processSelectionKey(selKey);
                    } 
    catch (IOException e) {
                        e.printStackTrace();
                        selKey.cancel();
                    }
                }

                System.out.println(
    "unclose");
                Thread.sleep(
    1000 * 30);
            } 
    catch (Exception e) {
                e.printStackTrace();
            } 
    finally {
                
    if (channel != null && channel.isOpen()) {
                    
    try {
                        channel.close();
                    } 
    catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                
    if (selector!=null) {
                    selector.close();      
    // not fd leak
                }
            }

            System.out.println(
    "end");
            Thread.sleep(
    1000 * 30 * 1);
    通過lsof -p pid | grep pipe可以觀察是否有fd leak.

    b. w版set 1000000 object 需要600s左右,s版只需150s左右

    posted @ 2008-10-31 19:55 waterye 閱讀(1548) | 評論 (2)編輯 收藏

    cacti-memcached

    192.168.0.74 [root avi]$ python /root/memcached/cacti-memcached-1.0/memcached.py localhost
    total_items:2002344 get_hits:3 uptime:50291 cmd_get:3 time:1224521129 bytes:58888890 curr_connections:1 connection_structures:8 bytes_written:16167008 limit_maxbytes:402653184 cmd_set:2002344 curr_items:1000000 rusage_user:101.730357 get_misses:0 rusage_system:199.092442 bytes_read:63849044 total_connections:314

    posted @ 2008-10-21 00:50 waterye 閱讀(998) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 国产99视频精品免费观看7| 国产精品九九久久免费视频| 亚洲婷婷国产精品电影人久久| 亚洲日本久久一区二区va| 亚洲AV无码AV日韩AV网站| 国产人在线成免费视频| 亚洲一区二区三区高清不卡| 久久久久久国产精品免费免费 | 亚洲国产精彩中文乱码AV| 日本亚洲精品色婷婷在线影院| 国产精品1024永久免费视频| 亚洲成年看片在线观看| 亚洲白色白色永久观看| v片免费在线观看| www.黄色免费网站| 亚洲国产成人久久综合| 免费在线观看视频a| a级毛片免费播放| 亚洲国产香蕉人人爽成AV片久久| 性生大片视频免费观看一级| 亚洲av日韩av高潮潮喷无码| 91精品免费久久久久久久久| 中文字幕亚洲综合久久菠萝蜜| 成人爽a毛片免费| 亚洲欧洲中文日产| 免费不卡中文字幕在线| 91免费福利视频| 亚洲中文字幕人成乱码| 日韩免费的视频在线观看香蕉| 亚洲成无码人在线观看| 免费亚洲视频在线观看| 久久久国产精品福利免费| 亚洲国产综合精品中文第一| 久操视频免费观看| 在线aⅴ亚洲中文字幕| 国产精品永久免费10000| 春暖花开亚洲性无区一区二区| 情人伊人久久综合亚洲| 成人无遮挡毛片免费看| 中文在线日本免费永久18近| 亚洲桃色AV无码|