Friday, October 31, 2008

Unix Command

1. Disk Usage
#du -sk (Show summary disk usage in K byte)
#du -k (Show detail disk usage in K byte)
2. Find text on File.
$find . grep filename
3. Search String
Unix
====
$strings -a XXXX.exe | grep header
Windows
=======
C:>find /N "Version" XXXX.exe

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
/OFF[LINE] Do not skip files with offline attribute set.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.

If a path is not specified, FIND searches the text typed at the prompt
or piped from another command.

4. Replace word

sed s/"opt"/"d02"/g create_nsdb.sql>create_nsdb.sql.new


5. Remove ^M from file by $vi

On Vi Screen

:%s/^V^M//g

The ^v is a CONTROL-V character and ^m is a CONTROL-M. When you type this, it will look like this:

6. tar

pack file $tar -cvf tar-file directory

unpack $tar -xvf tar-file







Tuesday, October 14, 2008

PostgreSQL Command on Ubuntu

1. Start/Stop PostgreSQL Database

root@postgre:~# sudo /etc/init.d/postgresql-8.3 stop
* Stopping PostgreSQL 8.3 database server [ OK ]
root@postgre:~# sudo /etc/init.d/postgresql-8.3 start
* Starting PostgreSQL 8.3 database server [ OK ]

Thursday, October 9, 2008

Ubuntu Command

Install ksh shell
-----------------
$sudo apt-get install ksh

Environment
-----------
$sudo vi /etc/environment

Friday, October 3, 2008

Oracle Startup Oracle Database on Linux

1. คำสั่ง Start Oracle Console
Your_Server_Shell> $ORACLE_HOME/bin/emctl start dbconsole
http://localhost:1158/em
2. export ORACLE_HOME=path i.e. /opt/oracle/production/10gR2
export ORACLE_SID=instance database i.e. PROD or TEST
3. คำสั่ง Start Database Instance
- shell> $ORACLE_HOME/bin/sqlplus sys/password_sys as sysdba
- sqlplus>startup
- shell> $ORACLE_HOME/bin/lsnrctl start
- shell> $ORACLE_HOME/bin/emctl start dbconsole

การสร้าง auto startup เมื่อ boot เครื่อง ไว้ใน /etc/init.d/oracle ครับ
#!/bin/bash

ORA_HOME="/u01/app/oracle/product/10.1.0/Db\_1"
ORA_OWNR="oracle"
ORACLE_SID="dev"

# if the executables do not exist -- display error

if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNR -c $ORA_HOME/bin/dbstart
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl start dbconsole"
touch /var/lock/subsys/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNR -c $ORA_HOME/bin/dbshut
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl stop dbconsole"
rm -f /var/lock/subsys/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 start|stop|restart|reload"
exit 1
esac
exit 0

##อย่าลืมแก้ค่า ORA_OWNR, ORA_HOME, ORACLE_SID
แล้ว ln -s /etc/init.d/oracle /etc/rc{3,5}.d/S99oracle
และ ln -s /etc/init.d/oracle /etc/rc{0,6}.d/K01oracle
แล้วจะเลือกว่าจะให้ DB ไหน AutoStart บ้างก็ไปแก้ที่ /etc/oratab ครับ อันหลังสุดให้เปลี่ยนเป็น Y

Thursday, October 2, 2008

Oracle 10g on Ubuntu 8.40

  1. Login to ubuntu from your usual administrative account which has sudo access

  2. Make sure you have enough ram, swap space and disk space as per oracle requirements.

  3. Install the required packages (first make sure ‘universe’ is enabled in your sources.list):

    • sudo apt-get install build-essential libaio rpm lesstif2-dev alien

    • apt-get install gcc libaio1 libc6 libstdc++5 make lesstif2 lesstif2-dev rpm

  4. Create the users and groups oracle needs:

    • sudo groupadd oinstall

    • sudo groupadd dba

    • sudo groupadd nobody

    • sudo useradd -g oinstall -G dba,nobody -d /opt/oracle -s /bin/bash oracle

  5. Set oracle user’s password

    • sudo passwd oracle

  6. Create the directory for the software installation and assign ownership to oracle:oinstall

    • sudo mkdir /opt/oracle

    • sudo chown -R oracle:oinstall /opt/oracle

    • sudo chmod -R 775 /opt/oracle

  7. In another console, login as oracle to make sure it works fine, then logout.

  8. Append user oracle’s .bashrc with PATH and ORACLE:BASE,HOME and SID information

    • sudo vi /opt/oracle/.bashrc

    • export ORACLE_BASE=/opt/oracle

    • export ORACLE_HOME=$ORACLE_BASE/product/10gR2

    • export ORACLE_SID=orcl

    • export PATH=$PATH:$ORACLE_HOME/bin

  9. Make sure the correct kernel parmeters are appended to /etc/sysctl.conf

    • kernel.shmall = 2097152

    • kernel.shmmax = 2147483648

    • kernel.shmmni = 4096

    • kernel.sem = 250 32000 100 128

    • net.core.rmem_default = 262144

    • net.core.rmem_max = 262144

    • net.core.wmem_default = 262144

    • net.core.wmem_max = 262144

    • fs.file-max = 65536

    • net.ipv4.ip_local_port_range = 1024 65000

  10. Set the kernel parameters or reboot

    • /sbin/sysctl -p

  11. Set /etc/security/limits.conf

    • * soft nproc 2047

    • * hard nproc 16384

    • * soft nofile 1024

    • * hard nofile 65536

  1. Create symbolic links and camoflage Kubuntu to look more like an enterprise rpm based distro because the oracle installer is expecting rhel, sles or asianux based distros.

    • sudo ln -s /usr/bin/awk /bin/awk

    • sudo ln -s /usr/bin/rpm /bin/rpm

    • sudo ln -s /lib/libgcc_s.so.1 /lib/libgcc_s.so

    • sudo ln -s /usr/bin/basename /bin/basename

  2. Mount the Oracle10g CD and run the installer

    • /runInstaller -ignoreSysPrereqs

  3. Installation will be uneventful provided above steps are followed

  4. Enable the oracle user to dbshut, dbstart and lsnrctl start

    • sudo vi /etc/oratab and change :N to :Y