posts - 88, comments - 3, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理


          1. install vncserver
          sudo yum install vnc-server

          2. set password for login user
            
          vncpasswd
          3. start one server to generate setting file ~/.vnc/xstartup
           
          vncserver :1
          4. edit ~/.vnc/xstartup as suggestion of comments to uncomment two lines:
            unset SESSION_MANAGER
            
          exec /etc/X11/xinit/xinitrc

          5. restart the server
           vncserver -kill :1
           vncserver -geometry 1200x900 -depth 16 :1
          寬屏的話
           vncserver -geometry 1366x768 -depth 16 :1, 如果不順眼 可以微調,我當前的最佳分辨率是
           vncserver -geometry 1346x680 -depth 16 :1

          6. access by vncviewer
           vncviewer SERVER_IP:5901

          Ref: VNC How TO

          posted @ 2012-03-20 11:06 Milo的海域 閱讀(363) | 評論 (0)編輯 收藏

          # parepare test database
          createDB="drop database if exists $database; create database if not exists $database;"
          mysql -$vip --port=$port -uadmin -padmin -"$createDB"

          # prepare data
          prepare="$sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=$row"
          prepare
          ="$prepare --mysql-port=$port --mysql-host=$vip --mysql-db=$database"
          prepare
          ="$prepare --mysql-password=admin --mysql-user=admin prepare"
          $prepare

          # run sysbench
          #
           http://sysbench.sourceforge.net/docs/#database_mode see this link for more options
          run="$sysbench --test=oltp --mysql-table-engine=innodb --init-rng --oltp-table-size=$row"
          run
          ="$run --max-requests=0 --max-time=900 --num-threads=128 --oltp-test-mode=complex"
          run
          ="$run --oltp-point-selects=2 --oltp-simple-ranges=1 --oltp-sum-ranges=2"
          run
          ="$run --oltp-index-updates=10 --oltp-non-index-updates=5 --mysql-port=$port"
          run
          ="$run --mysql-db=$database --mysql-host=$vip --mysql-password=admin --mysql-user=admin"

          # support oltp-user-delay-min to add delay for each sysbench request
          if [[ "$lag" != "nolag" ]]
          then
              run
          ="$run --oltp-user-delay-min=$lag"
          fi
          run
          ="$run run"

          posted @ 2012-03-19 16:35 Milo的海域 閱讀(360) | 評論 (0)編輯 收藏

          參考 jmap & jhat
          通過分析heap中對象的數量還有大小可以定位哪個類出了問題。

          posted @ 2012-03-16 09:45 Milo的海域 閱讀(304) | 評論 (0)編輯 收藏

          1. 盡量避免拋出異常
              異常是有代價的,比如盡量避免使用異常來實現流程控制
          2. 盡量處理異常
              有能力處理異常則處理掉,不然外層函數會累積太多的異常
          3. 處理不了則拋出異常
              自己問自己,這個異常能夠處理么,不行的話直接拋出,可以參考原則4
          4. Throw early and catch late
              一般底層函數不會處理異常,外層函數會根據上下文捕獲異常進行處理或者轉換
          5. 不要覆蓋異常
          6. try塊不應該太大(代碼規范)
          7. 函數拋出的異常不應該太多(代碼規范)

          參考

          posted @ 2012-03-12 16:35 Milo的海域 閱讀(252) | 評論 (0)編輯 收藏

          Ref http://ubuntudaily.net/archives/15

          Enhanced version
          trim()
          {
              trimmed
          =$1
              trimmed
          =${trimmed%%\s*}
              trimmed
          =${trimmed##\s*}
              echo "$trimmed"
          }
          var=" a bc   "
          var=$(trim $var)

          posted @ 2012-03-07 18:58 Milo的海域 閱讀(414) | 評論 (0)編輯 收藏

          同事寫的auto ssh login script:

          #!/usr/bin/expect -f
          # by gwang

          # default password list
          array set passwd {
              
          0 "password1"
              
          1 "password2"
              
          2 "password3"
          }

          # try login
          spawn $env(SHELL)
          match_max 
          100000
          send 
          -- "ssh -p $port $user@$ip\r"
          foreach i [array names passwd] {
              expect {
                  
          "(yes/no)" {
                      send 
          -- "yes\r"
                          exp_continue
                  }
                  
          "password:" {
                      send 
          -- "$passwd($i)\r"
                  }
                  
          "Last login" {
                      
          break
                  }
              }
          }
          interact

          由于ssh client默認支持的密碼錯誤重試是3, 所以這里只支持3個備選密碼。
          Google for "ssh client password retry" and find link which could help:
          ssh login retry  介紹了只要修改ssh client配置文件里/etc/ssh/ssh_config的NumberOfPasswordPrompts選項就可以了。無需重啟sshd...

          posted @ 2012-03-02 15:35 Milo的海域 閱讀(1079) | 評論 (0)編輯 收藏

          Disable/Enable PORT
          #disable port 29600
          iptables -I INPUT -p tcp --dport 
          29600 -j DROP
          iptables -I OUTPUT -p tcp --dport 
          29600 -j DROP

          #enable port 29600 after disabled
          iptables -D INPUT -p tcp --dport 29600 -j DROP
          iptables -D OUTPUT -p tcp --dport 
          29600 -j DROP

          Block Ipaddress
          # Block comming packets of ipaddress, then all packets come from this address will be dropped
          iptables -A INPUT -s 192.168.1.5 -j DROP

          # Block outgoing packets of ipaddress, then all packets sent to that address will be dropped
          iptables -A OUTPUT -p tcp -d 192.168.1.2  -j DROP

          Disable NIC traffic
          # disable
          iptables -A INPUT -jDROP -i eth1
          iptables -A OUTPUT -jDROP -o eth1

          # enable back
          iptables -D INPUT -jDROP -i eth1
          iptables -D OUTPUT -jDROP -o eth1

          links
          http://wiki.centos.org/HowTos/Network/IPTables
          http://www.thegeekstuff.com/2011/06/iptables-rules-examples/

          posted @ 2012-02-27 10:41 Milo的海域 閱讀(230) | 評論 (0)編輯 收藏

          Official ref: innodb_flush_log_at_trx_commit

          這個參數的配置涉及trax提交寫trax log文件的行為
          innodb_flush_log_at_trx_commit = 0
          # 每秒寫一次trax log
          ,并執行fsync

          innodb_flush_log_at_trx_commit 
          = 1
          # 每次trax 提交的時候寫一次trax log
          , 并執行fsync

          innodb_flush_log_at_trx_commit 
          = 2
          # 每次trax 提交的時候寫一次trax log
          , 不會執行fsync

          posted @ 2012-02-23 16:28 Milo的海域 閱讀(667) | 評論 (0)編輯 收藏

          改壞/etc/fstab文件會導致linux系統啟動時fsck失敗,從而進入"repair filesystem". 解決方法是:
              1. 執行 
                   mount -o remount rw /
                 進入讀寫模式
              
          2. edit /etc/fstab to correct typo or invalid setting
              
          3. exit repair filesystem to reboot


          posted @ 2012-02-21 17:09 Milo的海域 閱讀(324) | 評論 (0)編輯 收藏

          This is gnome behavior if you find some device volumes created on your gnome desktop.
          Ref:
          fedora 8/9/10的gnome下解決自動掛載windows分區的最佳辦法

          posted @ 2012-02-21 17:02 Milo的海域 閱讀(296) | 評論 (0)編輯 收藏

          僅列出標題
          共9頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 
          主站蜘蛛池模板: 收藏| 思南县| 商南县| 稻城县| 仁寿县| 南雄市| 上饶县| 郎溪县| 酒泉市| 四川省| 神池县| 樟树市| 重庆市| 林西县| 天全县| 无极县| 宁安市| 黎城县| 梨树县| 明星| 渭源县| 古丈县| 鄂州市| 泰兴市| 嘉义县| 黄大仙区| 永靖县| 巴东县| 通化市| 理塘县| 山西省| 汉源县| 萝北县| 庄浪县| 三穗县| 浑源县| 衢州市| 德兴市| 卫辉市| 乐至县| 雷山县|