Thursday, October 20, 2011

add hard drive to linux

1. find the added disk
ls /dev/hd* for ide drive
or ls /dev/sd8 for scsi drive

2. fdisk -l /dev/sdb # find out the label of the new drive

3. fdisk /dev/sdb #create partition on new drive

4. mkfs -t ext3 /dev/sdb1 # create file system

5. mkdir /newdrive # create mount point

6. mount /dev/sdb1 /newdrive # mount the new drive

then you can use it

*** to add new drive to LVM group
1. pvdisplay # list physical volume

2. pvcreate /dev/sdb1 # create physical volume on sdb1

3. vgextend volumegroupname /dev/sdb1 #add new physical volume to exist volume group

4. lvextend -L+20G /dev/volumegroupname/root #extend logical volume

5. resize2fs /dev/volumegroupname/root #resize file system

You have space in new drive to user now.


To make access of disk block devices in RHL5/OEL5,

Step 1: Make an entry in /etc/udev/rules.d/60-raw.rules or create your own file for example ., /etc/udev/rules.d/-oracle-raw.rules (eg. 63-oracle-raw.rules)


#vi /etc/udev/rules.d/63-oracle-raw.rules
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdf1", RUN+="/bin/raw /dev/raw/raw5 %N"
KERNEL=="raw[1-2]*", OWNER="root", GROUP="oinstall", MODE="640"
KERNEL=="raw[3-5]*", OWNER="oracle", GROUP="oinstall", MODE="644"


So our sdb1 will be recognized as /dev/raw/raw1, sdb2 will be as /dev/raw/raw2 and so on.

Step 2: For the mapping to have immediate effect, run below command

#/bin/raw /dev/raw/raw1 /dev/sdb1
/bin/raw /dev/raw/raw2 /dev/sdc1
/bin/raw /dev/raw/raw3 /dev/sdd1
/bin/raw /dev/raw/raw4 /dev/sde1
/bin/raw /dev/raw/raw5 /dev/sdf1

Step3: Adjust the permission settings by,
chown root:oinstall /dev/raw/raw1
chown root:oinstall /dev/raw/raw2
chown oracle:oinstall /dev/raw/raw3
chown oracle:oinstall /dev/raw/raw4
chown oracle:oinstall /dev/raw/raw5
chmod 640 /dev/raw/raw1
chmod 640 /dev/raw/raw2
chmod 640 /dev/raw/raw3
chmod 640 /dev/raw/raw4
chmod 640 /dev/raw/raw5

Open /etc/sysconfig/rawdevices and add following lines:

/dev/raw/raw1 /dev/sdb1 /dev/raw/raw2 /dev/sdc1 /dev/raw/raw3 /dev/sdd1 /dev/raw/raw4 /dev/sde1

Restart the rwdevices service to make your changes effective.

# service rawdevices restart Assigning devices: /dev/raw/raw1 --> /dev/sdb1 /dev/raw/raw1: bound to major 8, minor 17 /dev/raw/raw2 --> /dev/sdc1 /dev/raw/raw2: bound to major 8, minor 33 /dev/raw/raw3 --> /dev/sdd1 /dev/raw/raw3: bound to major 8, minor 49 /dev/raw/raw4 --> /dev/sde1 /dev/raw/raw4: bound to major 8, minor 65 done


reference
http://www.turnkeylinux.org/blog/extending-lvm
http://arjudba.blogspot.com/2008/08/on-rhl5-rawdevices-unrecognized-service.html
http://oracleflash.com/11/How-to-Configure-ASM-disks-using-ASMLib-or-Raw-Disks.html

Thursday, October 6, 2011

virtual console switch

alt-crl-fx

usually f7 is the gui console

yum and rpm

yum list package-name
yum install package-name or yum update package-name/rpm
yum erase package-name
yum search package-name # find package from repository
yum provides command-name # find package according to commmand

rpm -q package-name
rpm -i package-name
rpm -e package-name

yum will not install a package that public key is not imported, but rpm will install it with warning.

rlwrap

package: rlwrap-0.37-1.el5.i386.rpm

Now I could call sqlplus this way:
$ rlwrap sqlplus user/password@sid.

Finally I create an alias
alias sqlp =”rlwrap sqlplus”



alias sqlplus=”rlwrap sqlplus”

this I would avoid. rlwrap does not support non-interactive mode (echo xxx | sqlplus), is not an oracle support tool, and crashes occasionnaly.

Personnaly I do
alias q=”rlwrap sqlplus”
so that I can always use sqlplus to run important script, and keep rlwrap for not-productive stuff.


the first variant is ok:
$ alias sqlplus=”rlwrap sqlplus”

If you want history, then you run alias:
$ sqlplus

To run command instead of the alias you add backslash:
$ \sqlplus

Friday, September 16, 2011

du command

du -sh *
du -h --max-depth=1
du -k /u02 | sort -rn | less

screen command

$ screen
$ commands-here
(ctrl-a then ctrl-d) to detach
$ screen -r -ls (list screen session)
$ screen -r (to reattach to running screen session)

screen can be used to replace nohup

if you get error Cannot open your terminal '/dev/pts/1' - please check.
it is because you su to other user.

Try

sudo su - someuser
script /dev/null
screen

Thursday, September 8, 2011

AWR failed

when you can not run awr report because of awr is not initialized.
if you don't need old statistics.


run @?/rdbms/admin/catnoawr.sql
run @?/rdbms/admin/catawr.sql

shutdown immediate
startup