2009-08-13

LINUX LVM

1 Create LVM partition

1.1 Create LVM partition:

  • fdisk /dev/[disk]
  • change partition type from LINUX to LVM

1.2 Initialize LVM partition:

  • pvcreate /dev/[disk_partiton1] /dev/[disk_partition2]
  • verifycommands:
    • pvs
    • pvdisplay

1.3 Create LVM group:

  • vgcreate [group_name] /dev/[disk_partition1] /dev/[disk_partition2]
  • verify commands:
    • vgs
    • vgdisplay

1.4 Create logical volumes which is attached to group:

  • lvcreate -L[size]M -n [vol_name] [group_name]
  • verify commands:
    • lvs
    • lvdisplay

1.5 Volume format:

  • mkfs.ext3 [lv_name_from_lvdisplay]

2 Snapshot

2.1 Desc

  • Snapshot covers process of writing block to special area before writing to this block, so if you want to make changes to block at first you must copy this block to special area
  • So it is neccesary to set volume snapshot size, and when it will be full the snapshot is broken

2.2 Steps

  1. lvcreate -s -L[size]G -n [lv_snap] /dev/[vg_name]/[lv_2snap]
  2. dd if=/dev/[vg_name]/[lv_snap] of=[file_name].img
    • The size of file is similar to "lvdisplay /dev/[vg_name]/[lv_snap]"
    • If snapshot size is oversized the warning is "input/ouput error"
  3. lvcreate -n [lv_new] -L[size_bigger_then_above] [vg_name]
    • It is possible to expand by resize2fs
  4. dd if=[file_name].img of=/dev/[vg_name]/[lv_new]
  5. lvremove /dev/[vg_name]/[lv_snap]

3 Move data inside group

  1. pvs
  2. pvmove /dev/sd...
  3. pvs

4 Remove disk from group

  • lvreduce [vg_name] /dev/sd...

5 Add disk to group

  1. pvcreate /dev/sd...
  2. pvs
  3. vgextend [vg_name] /dev/sd...

6 Reduce volume size

  1. umount...
  2. e2fsck -f /dev/[vg_name]/[lv_name]
  3. resize2fs /dev/[vg_name]/[lv_name] [nr]G
  4. lvreduce -L[nr]G /dev/[vg_name]/[lv_name]
  5. mount...

7 Extend volume size

  1. lvextend /dev/[vg_name]/[lv_name]
  2. e2fsck -f /dev/[vg_name]/[lv_name]
  3. resize2fs /dev/[vg_name\/[lv_name]

8 Activate group

  • vgscan
  • vgchange -ay

9 Extend partition

  • fdisk
  • d #remove partition
  • n #make a new one with start section at the same point

2009-08-03

ORACLE WAITS

TIME_STATISTICS = true

v$event_name #describe events with parameters P and share to 12 wait_class

v$system_event #based on events which was collected when instance was started for all sessions (please check TIME_WAITED regard to  STARTUP_TIME.v$instance)
  • TOTAL_WAITS #how many times session was waiting on this event
  • TOTAL_TIMEOUTS #how often default time was reached, default time is set for each event
  • TIME_WAITED # time used by event (1/100 sek)
  • TIME_WAITED_MICRO #as above (/1000000 sek)
  • AVERAGE_WAIT #average time TIME_WAITED/TOTAL_WAITS (1/100 sek)
v$session_event #the same as v$system_event but for session, added SID column

v$session_wait #present events which was expected by session
  • SEQ #internal seqence nr for any event, it is increased any time when session wait at event
  • STATE #value WAITING and WAITED UNKNOWN TIME show that TIMES_STATISTICS is FALSE
  • SECONDS_IN_WAIT #time spending by session

from 10g
v$session_wait_history #the same as v$session_wait but there is last 10 wait events for any session but col SEQ# means something diferent
v$active_session_history #last 30 min probes which was collected every 1 sec., more probes than at v$session_wait_history

v$system_wait_class #waits grouped by class category
v$session_wait_class #waits grouped by class and session category

v$event_histogram #share between events which spend less than 1,2,4,8,16 ms