2015年4月15日 星期三

v7000 中的三種 FlashCopy 方式

In the Actions menu, you will see options for creating three types of mappings: Snapshot, Clone, and Backup. 

A Snapshot mapping creates an auto-expand, thin-provisioned target volume. A Snapshot mapping has a background copy rate of zero. This means that you will normally not get 100% completion, or a full copy of the source. Instead, the target volume contains only copy-on-write data. 

A Clone mapping creates a target volume with the same properties as the source volume, including thin-provision settings. Clone mappings are deleted automatically when the background copy process completes, and are used as a one time only copy. If you want to refresh the Clone target, you have to create a new mapping. 

A Backup mapping also creates a target volume with the same properties as the source volume, including thin-provision settings, and incremental FlashCopy is also enabled. A Backup mapping remains in the system when the background copy completes and can be restarted, which causes an efficient refresh of the target because it is done as incremental FlashCopy. 

All three types of mappings create a target volume that is located in the same managed-disk group as the source volume.



http://www-01.ibm.com/support/knowledgecenter/ST3FR7_7.3.0/com.ibm.storwize.v7000.730.learning/fc_script.html?cp=ST3FR7&lang=en

在原本頁面最底下選 non-flash version 

2015年1月30日 星期五

oracle 大量佔用 undo

java.sql.SQLException - ORA-01562: failed to extend rollback segment number 83

早上接到同事通知有這個錯誤記錄

發現 UNDO 用的量比以前多很多

用
set pagesize 400
set linesize 200
col name for a25
col program for a50
col username for a12
col osuser for a12
SELECT a.inst_id, a.sid, c.username, c.osuser, c.program, b.name,
a.value, d.used_urec, d.used_ublk
FROM gv$sesstat a, v$statname b, gv$session c, gv$transaction d
WHERE a.statistic# = b.statistic#
AND a.inst_id = c.inst_id
AND a.sid = c.sid
AND c.inst_id = d.inst_id
AND c.saddr = d.ses_addr
AND a.statistic# = 176
AND a.value > 0
ORDER BY a.value DESC

找出佔用的 SID  再從 session 裡找出來源 關閉程式.



---------
There are some views that show information related to undo activity:

* V$UNDOSTAT: histogram-like view that shows statistics for 10-minute intervals.
* V$TRANSACTION: present time view providing information on current transactions.
* V$SESSTAT: individual session statistics, which includes one for undo usage.

V$UNDOSTAT will provide a who did hint, recording the longest running query for that 10-interval, through the MAXQUERYID column which may be linked to V$SQL and use columns PARSING_USER_ID or PARSING_SCHEMA_NAME the get a grip on the suspect.

V$TRANSACTION linked with V$SESSION will show current used undo blocks for ongoing transactions. This query may help:
SELECT  a.sid, a.username, b.used_urec, b.used_ublk
FROM v$session a, v$transaction b
WHERE a.saddr = b.ses_addr
ORDER BY b.used_ublk DESC


V$SESSTAT provides another view, a who uses the undo kind of view, but we must avoid to get lost in the maze of Oracle statistics and focus on just one: Undo change vector size, which will accumulate the bytes of undo used during the session lifetime. Following query is designed to pinpoint who is having a high undo activity.
SELECT a.sid, b.name, a.value
FROM v$sesstat a, v$statname b
WHERE a.statistic# = b.statistic#
AND a.statistic# = 176    <-- Which stands for undo change vector size
ORDER BY a.value DESC 



Then the script for Oracle 11g is as follows:
set pagesize 400
set linesize 140
col name for a25
col program for a50
col username for a12
col osuser for a12
SELECT a.inst_id, a.sid, c.username, c.osuser, c.program, b.name,
a.value, d.used_urec, d.used_ublk
FROM gv$sesstat a, v$statname b, gv$session c, gv$transaction d
WHERE a.statistic# = b.statistic#
AND a.inst_id = c.inst_id
AND a.sid = c.sid
AND c.inst_id = d.inst_id
AND c.saddr = d.ses_addr
AND a.statistic# = 284
AND a.value > 0
ORDER BY a.value DESC

If you want to run this script on versions 10g1 and 10g2, just replace the statistic# with 176; 216 if your database is 11gR1... or use the following version independent script!!! (Hope we don't change the statistic name).

set pagesize 400
set linesize 140
col name for a25
col program for a50
col username for a12
col osuser for a12
SELECT a.inst_id, a.sid, c.username, c.osuser, c.program, b.name,
a.value, d.used_urec, d.used_ublk
FROM gv$sesstat a, v$statname b, gv$session c, gv$transaction d
WHERE a.statistic# = b.statistic#
AND a.inst_id = c.inst_id
AND a.sid = c.sid
AND c.inst_id = d.inst_id
AND c.saddr = d.ses_addr
AND b.name = 'undo change vector size'
AND a.value > 0
ORDER BY a.value DESC

---------
REF:
https://community.oracle.com/message/4281280

http://oracledisect.blogspot.tw/2008/05/who-is-using-your-undo-space.html

http://dba.stackexchange.com/questions/39466/oracle-undo-tablespace-users

http://oracledisect.blogspot.tw/2011/11/who-is-using-your-undo-space-improved.html

oracle 大量 recovery



https://srakwal.wordpress.com/2008/03/09/wait-for-stopper-event-to-be-increased/

https://magnusjohanssontuning.wordpress.com/2012/08/22/fast-parallel-transaction-recovery/

先下了一個大量的 DELETE 之後,過一段時間發現做不完 所以下了

alter session killed / disconnected

然後發現 session 處於 Marked for kill 狀態一直不動
再隔了一天發現 session 還在 所以透過 

 SELECT inst_id, status, event, state, blocking_session, sid, serial#, program FROM gv$session WHERE status = 'KILLED';
找到 spid 然後 kill -9

接下來冒出一堆 P000 - P129 的 process 

透過 

select qcsid "Query Coordinator", count(*) as "Slaves Count" from v$px_session group by qcsid; 

找出來開 parallel slave process 的頭是 SMON

然後 SMON 在 wait for stopper event to be increased / 等 undo / 等原本table所在的DBF

根據 http://www.eygle.com/archives/2008/05/oracle_smon_process.html

SMON 應該是在清 undo

然後找到

https://srakwal.wordpress.com/2008/03/09/wait-for-stopper-event-to-be-increased/

https://magnusjohanssontuning.wordpress.com/2012/08/22/fast-parallel-transaction-recovery/

If we have long running transactions (insert,delete,update) aborted by killing the session or aborting the instance,we must clean up the aborted transaction.
We can expect the clean up to take a long time. SMON is handling the roll back and will use parallel roll back when appropriate.
(when recovery work reaches a certain limit)
When the limit is reached smon will start parallel processes handling the roll back.Forsome transactions PQ slaves can start competing with each other about resources,
when that happens parallel transaction recovery can be slower then serial transaction recovery. At times the database appear to hang when doing parallel transaction recovery.
可以調 fast_start_parallel_rollback 
False Parallel rollback is disabled
Low (default) DOP can be maximum 2 * CPU_COUNT
High DOP can be maximum 4 * CPU_COUNT
Note Do not change the parameter dynamically on a system with many active transaction, it can cause severe problems.
Rollback strategy for active transactions may change. Do this change with a restart of the database.

可以從 v$fast_start_transactions. 看現在進行的事 但不曉得要做多少

重點是不可以砍掉 SMON 跟 PXXX . 

因為
1. SMON 是重要的 background process . 砍掉它可能會把 instance 拉下來
2. UNDO 裡面 還是有記錄 . 就算 shutdown abort . 開機做 recovery 的時候還是會再出現.

最後等了六個多小時讓它做完.



REF
https://docs.oracle.com/cd/E18283_01/server.112/e16541/parallel006.htm

http://www.oracle.com/technetwork/articles/database-performance/geist-parallel-execution-1-1872400.html

https://docs.oracle.com/cd/E18283_01/server.112/e16541/parallel005.htm

http://os2ora.com/monitor-parallel-execution/

http://www.remote-dba.net/t_op_sql_use_of_parallel.htm

http://www.dbaqhs.com/archives/category/oracle


linux extend filesystem

[root@ms2 ~]# fdisk -l

Disk /dev/sda: 290.9 GB, 290984034304 bytes
255 heads, 63 sectors/track, 35376 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       35376   284053297+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdg doesn't contain a valid partition table


[root@ms2 ~]#  cd /proc/scsi/sg
[root@ms2 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
0       2       0       0       0       1       128     0       1
5       0       0       0       0       1       254     0       1
5       0       0       1       0       1       254     0       1
5       0       0       2       0       1       254     1       1
5       0       0       3       0       1       254     0       1
5       0       0       4       0       1       254     0       1
5       0       0       5       0       1       254     0       1
[root@ms2 sg]# echo "- - -" > /sys/class/scsi_host/host5/scan
[root@ms2 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
0       2       0       0       0       1       128     0       1
5       0       0       0       0       1       254     1       1
5       0       0       1       0       1       254     0       1
5       0       0       2       0       1       254     0       1
5       0       0       3       0       1       254     0       1
5       0       0       4       0       1       254     0       1
5       0       0       5       0       1       254     0       1
5       0       0       6       0       1       254     0       1
5       0       0       7       0       1       254     0       1
5       0       0       8       0       1       254     0       1
[root@ms2 sg]#
[root@ms2 sg]#  fdisk -l

Disk /dev/sda: 290.9 GB, 290984034304 bytes
255 heads, 63 sectors/track, 35376 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       35376   284053297+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdg doesn't contain a valid partition table

Disk /dev/sdh: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdh doesn't contain a valid partition table

Disk /dev/sdi: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdi doesn't contain a valid partition table

Disk /dev/sdj: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdj doesn't contain a valid partition table
原本只有到 sdg 現在多了 h i j 三個 1TB 的 disk

[root@ms2 sg]# pvcreate /dev/sdh
  Physical volume "/dev/sdh" successfully created
[root@ms2 sg]# pvcreate /dev/sdi
  Physical volume "/dev/sdi" successfully created
[root@ms2 sg]# pvcreate /dev/sdj
  Physical volume "/dev/sdj" successfully created
[root@ms2 sg]#
[root@ms2 sg]# pvscan
  PV /dev/sdb    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdc    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdd    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sde    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdf    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdg    VG mboxvg          lvm2 [500.00 GB / 109.98 GB free]
  PV /dev/sda2   VG VolGroup00      lvm2 [270.88 GB / 110.72 GB free]
  PV /dev/sdh                       lvm2 [1.00 TB]
  PV /dev/sdi                       lvm2 [1.00 TB]
  PV /dev/sdj                       lvm2 [1.00 TB]
  Total: 10 [6.19 TB] / in use: 7 [3.19 TB] / in no VG: 3 [3.00 TB]
[root@ms2 sg]#
[root@ms2 sg]# vgextend mboxvg /dev/sdh
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# vgextend mboxvg /dev/sdi
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# vgextend mboxvg /dev/sdj
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# pvscan
  PV /dev/sdb    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdc    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdd    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sde    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdf    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdg    VG mboxvg       lvm2 [500.00 GB / 109.98 GB free]
  PV /dev/sdh    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sdi    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sdj    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sda2   VG VolGroup00   lvm2 [270.88 GB / 110.72 GB free]
  Total: 10 [6.19 TB] / in use: 10 [6.19 TB] / in no VG: 0 [0   ]
[root@ms2 sg]#
[root@ms2 sg]# vgdisplay
  --- Volume group ---
  VG Name               mboxvg
  System ID
  Format                lvm2
  Metadata Areas        9
  Metadata Sequence No  17
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                9
  Act PV                9
  VG Size               5.93 TB
  PE Size               4.00 MB
  Total PE              1554423
  Alloc PE / Size       739840 / 2.82 TB
  Free  PE / Size       814583 / 3.11 TB
  VG UUID               Xtfhe3-APFS-MFzs-wZq0-QNeE-aqEo-1CK1YV

  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               270.88 GB
  PE Size               32.00 MB
  Total PE              8668
  Alloc PE / Size       5125 / 160.16 GB
  Free  PE / Size       3543 / 110.72 GB
  VG UUID               LOAoah-0vIN-pWRq-sLkP-A9mG-zypc-uyLcGa

[root@ms2 sg]#
[root@ms2 sg]# lvdisplay

  --- Logical volume ---
  LV Name                /dev/mboxvg/mbox01
  VG Name                mboxvg
  LV UUID                G15z3j-lomU-encc-LQnS-BNq3-3zyl-qzhiqJ
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                2.82 TB
  Current LE             739840
  Segments               6
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4


[root@ms2 sg]#
[root@ms2 sg]# lvresize -l +100%FREE /dev/mboxvg/mbox01
  Extending logical volume mbox01 to 5.93 TB
  Logical volume mbox01 successfully resized
[root@ms2 sg]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/mboxvg/mbox01
  VG Name                mboxvg
  LV UUID                G15z3j-lomU-encc-LQnS-BNq3-3zyl-qzhiqJ
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.93 TB
  Current LE             1554423
  Segments               9
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                iYqCos-T3g8-Sf00-5GTb-UkQQ-fTeD-qTge70
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                39.06 GB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol03
  VG Name                VolGroup00
  LV UUID                fTrr9M-46ZG-Hi2X-18wf-jkCm-CpYk-OXGtXx
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                39.06 GB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol02
  VG Name                VolGroup00
  LV UUID                XlBlhu-inCm-6vsL-OsGw-zuuA-UBUZ-fr1qIj
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                78.12 GB
  Current LE             2500
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                6edOs6-pyle-Bbn3-4FQT-UCyW-Ud5q-LcSWHS
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.91 GB
  Current LE             125
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

[root@ms2 sg]#
[root@ms2 sg]# resize2fs /dev/mapper/mboxvg-mbox01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/mboxvg-mbox01 is mounted on /home01; on-line resizing required
Performing an on-line resize of /dev/mapper/mboxvg-mbox01 to 1591729152 (4k) blocks.
The filesystem on /dev/mapper/mboxvg-mbox01 is now 1591729152 blocks long.
[root@ms2 sg]# df -g
df: invalid option -- g
Try `df --help' for more information.
[root@ms2 sg]# df -g
df: invalid option -- g
Try `df --help' for more information.
[root@ms2 sg]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       38G  9.5G   27G  27% /
/dev/mapper/VolGroup00-LogVol03
                       38G  177M   36G   1% /tmp
/dev/mapper/VolGroup00-LogVol02
                       76G  9.6G   63G  14% /var
/dev/sda1              99M   19M   76M  20% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
/dev/mapper/mboxvg-mbox01
                      5.9T  1.7T  3.9T  31% /home01
[root@ms2 sg]#

REF:
http://linux.vbird.org/linux_basic/0420quota.php#lvm_whatis

http://linux.vbird.org/linux_basic/0230filesystem.php#fdisk

http://www.thegeekstuff.com/2011/04/identify-file-system-type/

http://linternux.com/2009/06/adding-san-disk/

http://www.milliondollarserver.com/add-new-hard-drive-in-centosrheloel-without-reboot/

http://setaoffice.com/2010/03/28/resizing-an-ext3-filesystem-mounted-on-a-logical-volume-in-a-linux/


2014年12月18日 星期四

ksh for loop

#!/usr/bin/ksh
c=1
while [[ $c -le 100 ]]
do
  # your-unix-command-here
   echo "$c"
   let c=c+1
done
http://www.cyberciti.biz/faq/unix-for-loop-1-to-10/