Posts

Showing posts from October, 2009

[Level 1] How to let our source code display with colors in Vim.

In TWOSUG , someone ask about how to display colors in shell. 1. Setting TERM variables. # export TERM=xterm-color; 2. Use Vim to open the source. # vim ./test.c; 3. Turn on the syntax mode in Vim. In last line mode, type the following command. :syntax on Wish this helps. regards, Stanley Huang

[Level 3] Clone multi-server on VirtualBox guest by ZFS clone.

How to save your disk space while you need multi VirtualBox guest? You can use ZFS clone to clone ZFS filesystem. But while you import the vdi, you willgot an error message with duplicated disk uuid. So you need to modify the disk uuid by command VBoxManage. The complete steps as the following: 1. create zfs pool for VirtualBox VDI. # zpool create vdiPool c1t0d0s0; # default folder is /vdiPool 2. create zfs filesystem for Source VDI. # zfs create vdiPool/vdiSource; # default folder is /vdiPool/vdiSource 3. create VirtualBox guest, and create vdi on /vdiPool/vdiSource/OpenSolaris.vdi 4. clone vdi source # zfs snapshot vdiPool/vdiSource@installed # zfs clone vdiPool/vdiSource@installed vdiPool/vdiTarget1 # VBoxManage internalcommands setvdiuuid /vdiPool/vdiTarget1/OpenSolaris.vdi Wish this helps. regards, Stanley Huang

chm reader in OpenSolaris

If you want to install chm reader on OpenSolaris, you can install xchm from Blastwave repository. Wish this helps. regards, Stanley Huang

ScaleDB storage engine for MySQL.

Image
Here comes a new commercial storage engine for MySQL called "ScaleDB". The architecture ScaleDB just similar like "Oracle RAC", but now, ScaleDB only support Linux and Windows. All the db instant are active and supports shared storage. Expecting the storage engine be mature. PS. If you don't have shared storage, and you just use VirtualBox as I do, you can use "DRBD" to simulate the shared storage, but now, DRDB only supoort Linux. The architecture of SacleDB as below. (All pictures rights belows to www.scaledb.com) Ref: http://www.scaledb.com The DRDB architecture as below. (All picture rights below to DRDB.org) Ref: http://www.drbd.org Wish this helps. regards, Stanley Huang

[Level 3] Solaris 10 Technical Conference ( 2009/10/25,11/13,12/4 ) -- Advanced ZFS hands-on lab

The following is my lab file, please refer to it.  Wish this helps. regards, Stanley Huang **************************************************************************************************** The purpose of this lab is to let you have advanced ZFS filesystem administration skill. And then you will have the following capabilities. Lab 1: * replace zpool disk. Lab 2: * take ZFS filesystem snapshot, rollback ZFS filesystem. * clone ZFS filesystem. Lab 3: * use ZFS L2ARC * use ZFS ZIL Lab 1: 1. replace zpool disk. # cd /labs/ZFS/files; # zpool create mypool mirror `pwd`/f1 `pwd`/f2 spare `pwd`/f3; # zpool replace mypool `pwd`/f2 `pwd`/f3; # zpool status mypool; -------------------------------------------------------------------------------   pool: mypool  state: ONLINE  scrub: resilver completed after 0h0m with 0 errors on Sun Oct 18 11:13:15 2009 config:     NAME            STATE     READ WRITE CKSUM     mypool                 ONLINE       0     0     0

[Level 2] Solaris 10 Technical Conference ( 2009/10/25,11/13,12/4 ) -- Basic ZFS hands-on lab

The following is my lab file, please refer to it.  Wish this helps. regards, Stanley Huang **************************************************************************************************** The purpose of this lab is to let you have basic ZFS administration skill. And then you will have the following capabilities. Lab 1: * create ZFS pool. * check ZFS pool status. * set ZFS pool properties. * destroy ZFS pool. Lab 2: * create ZFS filesystem. * check ZFS filesystem status. * set ZFS filesystem properties. * destroy ZFS filesystem. Lab 1: 1. prepare files with command mkfile. # mkdir -p /labs/ZFS/files; # cd /labs/ZFS/files; # mkfile 128m f1 f2 f3 f4 f5 f6 f7 f8 f9; 2. create ZFS pool. # zpool create mypool mirror `pwd`/f1 `pwd`/f2 spare `pwd`/f3; # zpool create myraidz raidz `pwd`/f4 `pwd`/f5 `pwd`/f6 spare `pwd`/f7; 3. list ZFS pools, and check pool status. # zpool list; --------------------------------------------------- # zpool list mypool; N

[Level 2] Solaris 10 Technical Conference ( 2009/10/25,11/13,12/4 ) -- Basic DTrace hands-on lab

The following is my lab file, please refer to it.  Wish this helps. regards, Stanley Huang **************************************************************************************************** The purpose of this lab is to let you have basic DTrace skill. And then you will have the following capabilities. Lab 1: * know dtrace probes. * use dtrace tool kits to monitor your system. * download dtrace tool kits. * write your first D-script. 1. list dtrace probes. # dtrace -l; 2. list demo dtrace tools # cd /usr/demo/dtrace; # ls -l *.d; ------------------------------------------------------------------ -rw-r--r--   1 root     bin         1677  5月 14 23:52 applicat.d -rw-r--r--   1 root     bin         1699  5月 14 23:52 badopen.d -rw-r--r--   1 root     bin         1732  5月 14 23:52 begin.d -rw-r--r--   1 root     bin         1668  5月 14 23:52 callout.d -rw-r--r--   1 root     bin         2220  5月 14 23:52 clause.d -rw-r--r--   1 root     bin         1717  5月 14 2

[Level 2] Solaris 10 Technical Conference ( 2009/10/25,11/13,12/4 ) -- Basic SMF hands-on lab

The following is my lab file, please refer to it. Wish this helps. regards, Stanley Huang **************************************************************************************************** The purpose of this lab is to let you have basic SMF administration skill. And then you will have the following capabilities. Lab 1: * list service. * check service dependenty. * manage service. Lab 1: 1. list services # svcs -a; ## list all service included 'disabled services' ---------------------------- STATE          STIME    FMRI ... ---------------------------- # svcs */milestone/*; ---------------------------------------------------------------------------- STATE          STIME    FMRI online          8:40:05 svc:/milestone/network:default online          8:40:08 svc:/milestone/name-services:default online          8:40:08 svc:/milestone/devices:default online          8:40:09 svc:/milestone/single-user:default online          8:40:13 svc:/milestone/sysco

[Level 3] Solaris 10 Technical Conference ( 2009/10/25,11/13,12/4 ) -- Advanced SMF hands-on lab

The following is my lab file, please refer to it.  Wish this helps. regards, Stanley Huang **************************************************************************************************** The purpose of this lab is to let you have advanced SMF administration skill. And then you will have the following capabilities. Ref:   1. smfmanifest_howto.pdf   2. http://www.sun.com/software/solaris/howtoguides/servicemgmthowto.jsp Lab 1: * create new SMF service. Lab 1: 1. copy smfSample.xml to /temp/. # mkdir /temp; # cp ./smfSample.xml /temp/myService.xml; 2. modify xml file. # cd /temp; # vi /temp/myService.xml; [ find all "REPLACE_ME" to replace ] 3. create myService method. # vi /temp/myService; [ service method just like init method, ex. /etc/init.d/apache ] 4. create myService.main. # vi /temp/myService.main; [ the service main program ] 5. import service configuration. # svccfg import /temp/myService.xml; 6. check service status. # svcs m

[Level 3] Solaris 10 Technical Conference ( 2009/10/25,11/13,12/4 ) -- Advanced DTrace hands-on lab

The following is my lab file, please refer to it.  Wish this helps. regards, Stanley Huang   **************************************************************************************************** The purpose of this lab is to let you have advanced DTrace skill. And then you will have the following capabilities. Lab 1: * well known about D-script. Lab 2: * use DTrace to debug your own program. Lab 1: 1. D-script arguments. # cd /temp; # cat ./testArgs.d; ------------------------------------ #!/usr/sbin/dtrace -qs /*  * $ is for digital argument,  * $$ is for quated string argument.  */ BEGIN {   printf("args1=%d\n",$1);   printf("args2=%s\n",$$2); } ------------------------------------ # chmod u+x ./testArgs.d; # ./testArgs.d 1 "a"; ------- args1=1 args2=a ------- ^C 2. D-script control # cd /temp; # cat ./0-60.d; ---------------------------------------------------------------------- #!/usr/sbin/dtrace -qs dtrace

[Level 3] How to use DTrace to trace your program fuction steps.

Sometime when we want to debug our program, we have to verify what's the program real step of function calls. We can use the DTrace to achieve it. For example (scenario): 1. Create C file /tmp/t.c with following source. #include <stdio.h> int f1(int a) {   f2(a+2); } int f2(int b) {   printf("%d\n", b+3); } int main(int argc, char *argv) {   char a='1';   f1(a); } 2. compiler then run it. # gcc -o /tmp/t /tmp/t.c # /tmp/t 54 # When we got the answer 54, why the answer is '54', is rare(we think, 1+2+3, should be '6'). Then we can use DTrace to trace it. 3. write a D-Language script (/tmp/t.d), then change mode with 700. # cat /tmp/t.d #!/usr/sbin/dtrace -s #pragma D option quiet pid$1:t:f1:entry {   printf("f1: %d\n", arg0); } pid$1:t:f2:entry {   printf("f2: %d\n", arg0); } # chmod 700 4. use mdb to execute the program. (terminal 1) PS. _start:b, set breakpoint in _start function :

[Level 2] File ACL...

Someone ask me about how to "Copy/Backup files with acl", there are several ways to do so. 1. use cp -p command: # cp -p ./a.txt ./b.txt PS. If you copy a file from UFS to ZFS, is OK, if you copy a file from ZFS to UFS, that will be failed. 2. use tar cp command: # tar cp ./d.tar ./d PS. the same problem as case 1, while you extract the file between 2 different filesystem. 3. copy acl from another file with getfacl/setfacl command on UFS: # getfacl ./a.txt |  setfacl -f - ./b.txt PS. You can use above command on UFS, not on ZFS. 4. copy file with zfs send/recv command: # zfs snapshot poolname/fssource@sname # zfs send -R poolname/fssource@sname | zfs recv -dF poolname/fstarget Wish this helps. regards, Stanley Huang

[Level 2] How to share screen within 2 sessions.

Image
Someone ask me about, if the vendor ssh into the server from internet, how can we "monitor" the commands that vendor keyins, especially when vendor need the "root" privileges! You can use the share screen to for-fill your request. [ Session 1 : User with "root" account ] [ Sessioi 2: Vendor with "stanley" account ] root# chmod u+s /usr/bin/screen root# screen [ press Ctrl+a, then enter ": multiuser on" ] [ press Ctrl+a, then enter ": addacl stanley" ] [ press "Enter" ] stanley$ screen -x root/ Then, your session screen is shared to your vendor. Wish this helps. regards, Stanley Huang

[Level 2] How to clone VirtualBox vdi

The most easy way to clone a virtual box vdi file is by using the command "VBoxManage" by user root. ex. # pfexec VBoxManage clonehd ./source.vdi ./target.vdi # sUser=`whoami` # sGroup=`groups $sUser|cut -d' ' -f1` # chown $sUser:$sGroup ./target.vdi Wish this helps. regards, Stanley Huang

[Level 2] How to run commands at remote server through telnet client.

Today, someone ask me, "How to run commands at remote server through telnet client?" So I write a sample code for him and also share for you. Wish this helps. regards, Stanley Huang ################################################ #!/usr/bin/bash showUsage() {   cat<< EOF Usage:   $0 host [user] [pwd] [sleep_sec] [cmd_file] Ex.   $0 localhost root root123 3 $0.cmd   $0 localhost root root123 3   $0 localhost root root123   $0 localhost root   $0 localhost PS.   Default values:   user=root   pwd=root123   sleep_sec=3   cmd_file=$0 EOF } ################################## main sGrep="^#[$] " # default grep filter sHost=$1  && [ -z $sHost   ] && showUsage && exit 1 # sHost=b1500-16 sUsr=$2   && [ -z $sUsr    ] && sUsr=root           # whoami sPwd=$3   && [ -z $sPwd    ] && sPwd=root123        # passwd sSleep=$4 && [ -z $sSleep  ] && sSleep=3 sCmdF=$5  &