Posts

Showing posts from December, 2009

[Level 3] Clone ZFS Permissions

One day, someone ask me how to clone ZFS permissions from one ZFS file system to another ZFS file system. It seems that zfs command doesnot support the permission like getfacl setfacl to clone the file system permissions. Therefore I try to write a script to implement that, please refer to the following code. #!/usr/bin/bash showUsage() {   cat <<EOF Usage:   $0 source_zfs target_zfs Ex.   $0 rpool/fs1 karajon/fs2 EOF } ##################################### main sSZFS=$1 sTZFS=$2 declare -i fPermSet=0 declare -i fLocalPerm=0 zfs allow $sSZFS | while read s do   ( echo $s | grep "^---- Permissions on " > /dev/null ) && continue   ( echo $s | grep "^Permission sets:$" > /dev/null ) && fPermSet=1 && fLocalPerm=0 && continue   ( echo $s | grep "^Local+Descendent permissions:$" > /dev/null ) && fLocalPerm=1 && fPermSet=0 && continue   if [ $fPermSet -eq 1 ] ...

[Level 2] MySQL Query with Regular Expression.

If you  want to let your query more powerful, you can use regular expression to enhance your SQL query. mysql> create table testRegExp (name varchar(32)); mysql> insert into testRegExp values('Stanley'),('Christy'),('Joseph'),('Chantelle'); Query OK, 4 rows affected (0.00 sec) Records: 4  Duplicates: 0  Warnings: 0 mysql> select * from testRegExp where name regexp '^(S|C)'; +-----------+ | name      | +-----------+ | Stanley   | | Christy   | | Chantelle | +-----------+ 3 rows in set (0.00 sec) mysql>  Ref: http://dev.mysql.com/doc/refman/5.1/en/regexp.html Wish this helps. regards, Stanley Huang

[Level 2] MySQL XML Functions.

One day, a friends of mine asked me if MySQL support XML? Actually, MySQL havs two XML functions, called "ExtractValue" and "UpdateValue". You can use these two function as the following samples: mysql> CREATE TABLE persons ( id int auto_increment primary key, data text ); mysql> INSERT INTO persons(data) values (' <person>   <name>stanley</name>   <sex>m</sex>   <addr>taipei</addr>   <tels>     <tel>12340001</tel>     <tel>12340002</tel>     <tel>12340003</tel>   </tels> </person> '), (' <person>   <name>joseph</name>   <sex>m</sex>   <addr>taipei</addr>   <tels>     <tel>12350001</tel>     <tel>12350002</tel>     <tel>12350003</tel> ...

[Level 1] MySQL 5.5 new features -- Semisynchronous Replication.

MySQL 5.5 m2 has released. In m2, MySQL 5.5 has a great called "Semisynchronous Replication". How the semi works? 1. First, the client connect to server and be indicated that is semi or not. 2. If semi is enable on server site and there is at least one client and waits untilone semi client acknowledges that it has received. please refer to the following link for more info. http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html Wish this helps. regards, Stanley Huang

[Level 3] Using DTrace for MySQL DB.

I'm glade to here that, in MySQL 5.4 beta, it supports that to use Solaris DTrace to monitor MySQL SQL statement. About the probe for MySQL, please refer to the following link: http://dev.mysql.com/doc/refman/5.4/en/dba-dtrace-mysqld-ref.html I use one of the scripts to demo the result of DTrace, http://dev.mysql.com/doc/refman/5.4/en/dba-dtrace-ref-query.html The result as below: Sessin 1: [stanley@Stanley-NB]:/usr/mysql# mysql Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.4.3-beta MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. stanley@localhost:stanley mysql> show tables; Empty set (0.00 sec) stanley@localhost:stanley mysql> Sessin 2: root@Stanley-NB:/tmp# ./MySQL_query.d Who                  Database     ...

[Level 3] Script for clone VirtualBox 3.1.0 .

Before, I wrote a script to clone VirtualBox with ZFS technology. After new VirtualBox release, because of the architecture and command changed, the previous script will occur error while running. Therefore, I modify the script for version 3.1.0 later of VirtualBox. #!/usr/bin/bash showUsage() {   cat <<EOF Usage:   $0 [c]reate/[d]elete New_Machine_Name Source_Machine_Name interface begin_index end_index Ex.   $0 [c]reate OS128a_MySQL OS128a yge0 1 10   $0 [d]elete OS128a_MySQL OS128a yge0 1 10   $0 [d]elete OS128a_MySQL OS128a yge0 VMMachine: `showVMS | sed -e 's/^/  /'` EOF } ## Usage: ##   setUUID vdi_file ## Ex. ##   setUUID /Karajon/VBoxes/Guest/guest.vdi setUUID() {   sVDI=$1   VBoxManage -q internalcommands setvdiuuid $sVDI } ## Usage: ##   createVM vm_name os_type. ## Ex. ##   createVM S10u8_MySQL Solaris_64 ## PS. ##   OS Type: Solaris Solaris_64 Open...

Gnome-commander in OpenSolaris

If you like to use the utility on Windows called "Total Commander", you would like "Gnome-commander" in OpenSolaris. You can download the Gnome-commander in opensolaris.org repository. The package name called "SUNWgnome-commander". Wish this helps. regards, Stanley Huang

[Level 3] Get process pid which open port!

How to get your process that open port. The following will help you to check it! #!/usr/bin/bash showUsage() {   cat <<EOF Usage:   $0 [port/pid/program](sort column, default is sort by 'port'.) Ex.   $0 1/port   $0 2/pid   $0 3/program EOF } ####################################### main typeset -i nSortKey case $1 in 1|port|"")   sFlag="-n"   nSortKey=1   ;; 2|pid)   sFlag="-n"   nSortKey=2   ;; 3|program)   nSortKey=3   ;; *)   showUsage   exit 0   ;; esac echo "port\tpid\tcmd" ps -eo pid,comm | while read pid cmd do   pfiles $pid 2> /dev/null | grep port: | awk "{printf(\"%s\t%s\t%s\n\",\$5,\"$pid\",\"$cmd\")}" done | sort $sFlag -u -k $nSortKey  Wish this helps. regards, Stanley Huang

[Level 2] Enhance the performance with MySQL checksum table with MyISAM engine.

You can create MyISAM table with the option "checksum=1", to let MyISAM table store the checksum value. Otherwise, checksum table, will need to do a full table scan. PS. This only support on MyISAM engine. mysql> create table t (id int) engine=MyISAM checksum=1; mysql> checksum table t; Wish this helps. regards, Stanley Huang Publish Post

VirtualBox 3.1 released

Sun Microsystems release VirtualBox 3.1 at 11/30. The new version has new features that people looking forward to: 1. Teleportaion (aka live migration): It supports that to let virtual machine to migration between different platform, it enhances the virtual server with HA and flexibility. 2. Snapshots flexibility: The guest can rollback from different revision, and also can have branched snapshots. 3. Network attachement on the fly: The guest can modify the network interace on line. More information, please refer to: http://www.virtualbox.org/wiki/Changelog Wish this helps. regards, Stanley Huang