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

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

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

    waterye

    2009年12月29日 #

    使用rsync+ssh同步n個(gè)文件

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

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

    mysql備份

    1. 使用Replication進(jìn)行實(shí)時(shí)備份
    參考mysql docs
    2. 定期在slave上使用shell,mysqldump,sftp,crontab進(jìn)行永久備份
    #!/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級(jí)別的可以每天作一次備份,100G級(jí)別看帶寬和硬盤,T級(jí)沒有經(jīng)驗(yàn)

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

    2009年2月19日 #

    檢查哪些文件以\n結(jié)束

    #!/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è),但能完成任務(wù)就行

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

    2008年12月4日 #

    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 閱讀(1076) | 評(píng)論 (0)編輯 收藏

    2008年10月31日 #

    memcached java client

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

    a. 使用whalin版會(huì)導(dǎo)致File Descriptor leak,而使用spy版則不會(huì),原因是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 閱讀(1554) | 評(píng)論 (2)編輯 收藏

    2008年10月21日 #

    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 閱讀(1003) | 評(píng)論 (0)編輯 收藏

    2008年10月5日 #

    ubuntu查看網(wǎng)絡(luò)流量

    1. iftop
    sudo apt-get install iftop
    sudo iftop -i ppp0
    2. slurm
    sudo apt-get install slurm
    slurm -i ppp0
    3. vnstat
    sudo apt-get install vnstat
    sudo chmod o+x /usr/bin/vnstat
    sudo chmod o+wx /var/lib/vnstat/
    vnstat -u -i ppp0
    vnstat -i ppp0
    vnstat -l -i ppp0

    因?yàn)椴皇莝erver就沒有用復(fù)雜的mrtg

    posted @ 2008-10-05 22:19 waterye 閱讀(6282) | 評(píng)論 (3)編輯 收藏

    2008年9月28日 #

    刪除最后一行\(zhòng)n

    vi,gedit會(huì)在最后一行加上\n,實(shí)在找不到好的解決方法,只好自己寫個(gè)shell script刪掉
    #!/usr/bin/env python
    import sys

    oldfile
    =sys.argv[1]
    newfile
    =sys.argv[2]
    print oldfile,newfile,
    print
    linecount 
    = 0
    str 
    = ''
    = open(oldfile,'r')
    for line in f:   
        linecount 
    += 1
    = open(oldfile,'r')
    for i,line in enumerate(f):
        
    if (i==linecount-1):
            str 
    += line.replace('\n','')
    #        print line.replace('\n','')
        else:
            str 
    += line
    #        print line,
    #
    print len(str),str
    f2 = open(newfile, 'w')
    f2.write(str)
    quit()


    posted @ 2008-09-28 19:58 waterye 閱讀(1148) | 評(píng)論 (0)編輯 收藏

    2008年9月24日 #

    memory info

    free -lmt
    cat /proc/meminfo
    dmesg |grep [mM][eE][mM]
    cat /proc/pid/status

    posted @ 2008-09-24 19:56 waterye 閱讀(967) | 評(píng)論 (0)編輯 收藏

    2008年9月22日 #

    rm many file directory

    1. find . -type f -exec rm -v {} \;

    2. nice -n 19 rm -rf directory

    3. ls | xargs rm

    4. find . -mtime +90 -type f -exec rm -v {} \;

    采用第四種最好,把一些舊的文件先刪除

    posted @ 2008-09-22 20:06 waterye 閱讀(838) | 評(píng)論 (0)編輯 收藏

    僅列出標(biāo)題  下一頁
    主站蜘蛛池模板: 亚洲成av人片天堂网无码】| 一级做a爱片特黄在线观看免费看| 国产AⅤ无码专区亚洲AV| fc2成年免费共享视频18| 亚洲处破女AV日韩精品| 日韩精品无码区免费专区| 久热综合在线亚洲精品| 久久不见久久见免费影院| 成人免费网站视频www| 亚洲v高清理论电影| 国产在线a不卡免费视频| 二区久久国产乱子伦免费精品 | 国产亚洲精品成人a v小说| 亚洲av综合av一区二区三区| 亚洲人成人无码网www电影首页| 亚洲免费在线视频播放| 羞羞视频免费网站日本| 亚洲国产精品成人久久久| 免费人妻av无码专区| 5g影院5g天天爽永久免费影院 | 无码免费一区二区三区免费播放 | 男性gay黄免费网站| 久久久亚洲精品国产| 又大又硬又爽免费视频| 99re热精品视频国产免费| 色吊丝性永久免费看码| 亚洲国产美女精品久久| 国产成人亚洲影院在线观看| 大地资源在线观看免费高清| 国产真人无码作爱视频免费| 亚洲经典千人经典日产| 亚洲一区二区中文| 国产亚洲成人在线播放va| 成人免费无码精品国产电影| 18未年禁止免费观看| a级毛片100部免费观看| 日韩精品无码永久免费网站| 亚洲熟妇无码AV不卡在线播放| 亚洲精品免费观看| 亚洲中文字幕在线观看| 亚洲国产天堂久久久久久|