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的海域 阅读(347) | 评论 (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的海域 阅读(345) | 评论 (0)编辑 收藏

参考 jmap & jhat
通过分析heap中对象的数量还有大小可以定位哪个类出了问题。

posted @ 2012-03-16 09:45 Milo的海域 阅读(288) | 评论 (0)编辑 收藏

1. 尽量避免抛出异常
    异常是有代价的,比如尽量避免使用异常来实现流程控制
2. 尽量处理异常
    有能力处理异常则处理掉,不然外层函数会累积太多的异常
3. 处理不了则抛出异常
    自己问自己,这个异常能够处理么,不行的话直接抛出,可以参考原则4
4. Throw early and catch late
    一般底层函数不会处理异常,外层函数会根据上下文捕获异常进行处理或者转换
5. 不要覆盖异常
6. try块不应该太大(代码规范)
7. 函数抛出的异常不应该太多(代码规范)

参考

posted @ 2012-03-12 16:35 Milo的海域 阅读(239) | 评论 (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的海域 阅读(401) | 评论 (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的海域 阅读(1054) | 评论 (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的海域 阅读(220) | 评论 (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的海域 阅读(654) | 评论 (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的海域 阅读(309) | 评论 (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的海域 阅读(279) | 评论 (0)编辑 收藏

仅列出标题
共9页: 上一页 1 2 3 4 5 6 7 8 9 下一页