在AIX上,回收LVM中的磁盘会经历这么几个阶段:

1. 停掉目标上的应用与服务
2. 文件系统:取消挂载
3. VG:删除LV
4. VG:删除PV
5. PV:删除PV
6. 回收磁盘

——————————————————————
首先,确认要移动的是那些LV

然后停掉这些LV上面运行的程序或者服务,并取消挂载:
umount xxx

再次查看LV:

root@uxgdc106:/ # lsvg -l datavg | grep ora
fslv02              jfs2       3000    3000    1    closed/syncd  /oracle
lv_arch_new         jfs2       3634    3634    7    closed/syncd  /oracle/ERN/oraarch
lv_oraarch          jfs2       100     100     1    closed/syncd  /oracle/ERN/oraarch_old
lv03                jfs2       660     660     3    closed/syncd  /oracle/ERN/sapdata10
lv04                jfs2       840     840     4    closed/syncd  /oracle/ERN/sapdata11
lv_sapdata12        jfs2       1020    1020    4    closed/syncd  /oracle/ERN/sapdata12
lv_sapdata13        jfs2       1023    1023    8    closed/syncd  /oracle/ERN/sapdata13
lg_sapdata14        jfs2       1020    1020    3    closed/syncd  /oracle/ERN/sapdata14
lg_sapdata15        jfs2       960     960     3    closed/syncd  /oracle/ERN/sapdata15
lg_sapdata16        jfs2       720     720     3    closed/syncd  /oracle/ERN/sapdata16
lv_sapdata17        jfs2       780     780     3    closed/syncd  /oracle/ERN/sapdata17
lv_sapdata18        jfs2       1320    1320    3    closed/syncd  /oracle/ERN/sapdata18
lv_sapdata19        jfs2       780     780     4    closed/syncd  /oracle/ERN/sapdata19
lv_sapdata20        jfs2       740     740     4    closed/syncd  /oracle/ERN/sapdata20
lv_sapdata21        jfs2       740     740     3    closed/syncd  /oracle/ERN/sapdata21
lv_sapdata22        jfs2       1394    1394    5    closed/syncd  /oracle/ERN/sapdata22
lv_sapdata23        jfs2       1080    1080    4    closed/syncd  /oracle/ERN/sapdata23
lv_sapdata24        jfs2       981     981     3    closed/syncd  /oracle/ERN/sapdata24
lv_sapdata6         jfs2       813     813     3    closed/syncd  /oracle/ERN/sapdata6
lv_sapdata7         jfs2       720     720     5    closed/syncd  /oracle/ERN/sapdata7
lv_sapdata8         jfs2       1120    1120    5    closed/syncd  /oracle/ERN/sapdata8
lv_sapdata9         jfs2       1104    1104    4    closed/syncd  /oracle/ERN/sapdata9
lv_ora_backup       jfs2       25604   25604   4    open/syncd    /oracle_backup
root@uxgdc106:/ # 

你可以看到,他们的状态是【closed/syncd】,而非【open/syncd】

closed状态的lv,就可以删除了,类似这样:

root@uxgdc106:/ # rmlv lv_sapdata9
Warning, all data contained on logical volume lv_sapdata9 will be destroyed.
rmlv: Do you wish to continue? y(es) n(o)? y
rmlv: Logical volume lv_sapdata9 is removed.
root@uxgdc106:/ #

再次查看LV与VG的关联

root@uxgdc106:/ # lsvg datavg -l | grep ora
lv_ora_backup       jfs2       25604   25604   4    open/syncd    /oracle_backup
root@uxgdc106:/ # 

查看VG:

root@uxgdc106:/ # lsvg datavg
VOLUME GROUP:       datavg                   VG IDENTIFIER:  00cd765100004c000000014e7bbd5f46
VG STATE:           active                   PP SIZE:        512 megabyte(s)
VG PERMISSION:      read/write               TOTAL PPs:      59552 (30490624 megabytes)
MAX LVs:            256                      FREE PPs:       32137 (16454144 megabytes)
LVs:                13                       USED PPs:       27415 (14036480 megabytes)
OPEN LVs:           13                       QUORUM:         15 (Enabled)
TOTAL PVs:          28                       VG DESCRIPTORS: 28
STALE PVs:          0                        STALE PPs:      0
ACTIVE PVs:         28                       AUTO ON:        yes
MAX PPs per VG:     65536                    MAX PVs:        1024
LTG size (Dynamic): 256 kilobyte(s)          AUTO SYNC:      no
HOT SPARE:          no                       BB POLICY:      relocatable 
MIRROR POOL STRICT: off                                       
PV RESTRICTION:     none                     INFINITE RETRY: no
root@uxgdc106:/ # 

可以看到【FREE PPs】空出来了。

开始清理PV。

查看PV的状态:

root@uxgdc106:/ # lspv
hdisk0          00cd7651bf1cd905                    rootvg          active      
hdisk1          00cc37c298f35cbb                    rootvg          active      
hdisk2          00cd7661b5479fc2                    rootvg          active      
hdisk3          00cd7651b521c300                    rootvg          active      
hdisk4          00cd76515d26cced                    datavg          active      
hdisk5          00cd76517f129ed2                    datavg          active      
hdisk31         00cd765185d58327                    datavg          active      
hdisk9          00cd7651812de1cc                    datavg          active      
hdisk6          00cd7651f5cc22f4                    datavg          active      
hdisk7          00cd7651f920d8e3                    datavg          active      
hdisk8          00cd76515a4936b8                    datavg          active      
hdisk10         00cd7651cf913b39                    datavg          active      
hdisk11         00cd76510af824ee                    datavg          active      
hdisk12         00cd765133e8e886                    datavg          active      
hdisk13         00cd765154e18c41                    datavg          active      
hdisk14         00cd7651bba54981                    datavg          active      
hdisk15         00cd7651bbfaa194                    datavg          active      
hdisk16         00cd7651227303c0                    datavg          active      
hdisk17         00cd765166046229                    datavg          active      
hdisk18         00cd765184acc859                    datavg          active      
hdisk19         00cd765184ad5a25                    datavg          active      
hdisk20         00cd765184b44c9f                    datavg          active      
hdisk21         00cd7651e7481ac3                    datavg          active      
hdisk22         00cd7651e748753f                    datavg          active      
hdisk23         00cd7651f1464933                    datavg          active      
hdisk24         00cd7651abb6064c                    datavg          active      
hdisk25         00cd7651c8ea9e05                    datavg          active      
hdisk26         00cd765142576fde                    datavg          active      
hdisk27         00cd76517b9b0488                    datavg          active      
hdisk28         00cd7651ecb8f2f4                    datavg          active      
hdisk29         00cd7651e8e17c49                    datavg          active      
hdisk30         00cd7651b3fd1a33                    datavg          active      
root@uxgdc106:/ # 
root@uxgdc106:/ # lsvg -p datavg
datavg:
PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
hdisk4            active            14335       12524       2833..2802..2867..2315..1707
hdisk6            active            6143        417         00..00..417..00..00
hdisk7            active            599         599         120..120..119..120..120
hdisk5            active            6143        4679        93..1229..900..1228..1229
hdisk8            active            399         399         80..80..79..80..80
hdisk9            active            399         399         80..80..79..80..80
hdisk10           active            399         399         80..80..79..80..80
hdisk11           active            399         399         80..80..79..80..80
hdisk12           active            399         399         80..80..79..80..80
hdisk13           active            399         399         80..80..79..80..80
hdisk14           active            399         399         80..80..79..80..80
hdisk15           active            399         399         80..80..79..80..80
hdisk16           active            999         999         200..200..199..200..200
hdisk17           active            599         599         120..120..119..120..120
hdisk18           active            599         599         120..120..119..120..120
hdisk19           active            599         599         120..120..119..120..120
hdisk20           active            399         399         80..80..79..80..80
hdisk21           active            599         599         120..120..119..120..120
hdisk22           active            599         599         120..120..119..120..120
hdisk23           active            5999        1920        00..1200..720..00..00
hdisk24           active            399         399         80..80..79..80..80
hdisk25           active            599         599         120..120..119..120..120
hdisk26           active            599         599         120..120..119..120..120
hdisk27           active            239         239         48..48..47..48..48
hdisk28           active            599         599         120..120..119..120..120
hdisk29           active            779         779         156..156..155..156..156
hdisk30           active            1199        1199        240..240..239..240..240
hdisk31           active            14335       0           00..00..00..00..00
root@uxgdc106:/ # 

注意,上面的【TOTAL PPs】和【FREE PPs】。
只有这两个相等的PV,才可以被清除。
也就是,只有没有使用的PV才可以被清除。

上面的命令行可能不太好看,整理到EXCEL中,更清楚:

从VG中,删除PV:

root@uxgdc106:/ # reducevg datavg hdisk7
root@uxgdc106:/ # reducevg datavg hdisk8
root@uxgdc106:/ # reducevg datavg hdisk9
root@uxgdc106:/ # reducevg datavg hdisk10
root@uxgdc106:/ #

如果PV不为空,你做清理,则会遇到错误:

root@uxgdc106:/ # reducevg datavg hdisk23
0516-016 ldeletepv: Cannot delete physical volume with allocated
        partitions. Use either migratepv to move the partitions or
        reducevg with the -d option to delete the partitions.
0516-884 reducevg: Unable to remove physical volume hdisk23.
root@uxgdc106:/ #

当全部清理后,你看到的PV状态就是这样的:

root@uxgdc106:/ # lspv
hdisk0          00cd7651bf1cd905                    rootvg          active      
hdisk1          00cc37c298f35cbb                    rootvg          active      
hdisk2          00cd7661b5479fc2                    rootvg          active      
hdisk3          00cd7651b521c300                    rootvg          active      
hdisk4          00cd76515d26cced                    datavg          active      
hdisk5          00cd76517f129ed2                    datavg          active      
hdisk31         00cd765185d58327                    datavg          active      
hdisk9          00cd7651812de1cc                    None                        
hdisk6          00cd7651f5cc22f4                    datavg          active      
hdisk7          00cd7651f920d8e3                    None                        
hdisk8          00cd76515a4936b8                    None                        
hdisk10         00cd7651cf913b39                    None                        
hdisk11         00cd76510af824ee                    None                        
hdisk12         00cd765133e8e886                    None                        
hdisk13         00cd765154e18c41                    None                        
hdisk14         00cd7651bba54981                    None                        
hdisk15         00cd7651bbfaa194                    None                        
hdisk16         00cd7651227303c0                    None                        
hdisk17         00cd765166046229                    None                        
hdisk18         00cd765184acc859                    None                        
hdisk19         00cd765184ad5a25                    None                        
hdisk20         00cd765184b44c9f                    None                        
hdisk21         00cd7651e7481ac3                    None                        
hdisk22         00cd7651e748753f                    None                        
hdisk23         00cd7651f1464933                    datavg          active      
hdisk24         00cd7651abb6064c                    None                        
hdisk25         00cd7651c8ea9e05                    None                        
hdisk26         00cd765142576fde                    None                        
hdisk27         00cd76517b9b0488                    None                        
hdisk28         00cd7651ecb8f2f4                    None                        
hdisk29         00cd7651e8e17c49                    None                        
hdisk30         00cd7651b3fd1a33                    None                        
root@uxgdc106:/ # 

其实这个时候,就可以回收磁盘了。

但是理论上,还是应该先对PV做一个删除,如下:

root@uxgdc106:/ # lspv
hdisk0          00cd7651bf1cd905                    rootvg          active      
hdisk1          00cc37c298f35cbb                    rootvg          active      
hdisk2          00cd7661b5479fc2                    rootvg          active      
hdisk3          00cd7651b521c300                    rootvg          active      
hdisk4          00cd76515d26cced                    datavg          active      
hdisk5          00cd76517f129ed2                    datavg          active      
hdisk31         00cd765185d58327                    datavg          active      
hdisk9          00cd7651812de1cc                    None                        
hdisk6          00cd7651f5cc22f4                    datavg          active      
hdisk7          00cd7651f920d8e3                    None                        
hdisk8          00cd76515a4936b8                    None                        
hdisk10         00cd7651cf913b39                    None                        
hdisk11         00cd76510af824ee                    None                        
hdisk12         00cd765133e8e886                    None                        
hdisk13         00cd765154e18c41                    None                        
hdisk14         00cd7651bba54981                    None                        
hdisk15         00cd7651bbfaa194                    None                        
hdisk16         00cd7651227303c0                    None                        
hdisk17         00cd765166046229                    None                        
hdisk18         00cd765184acc859                    None                        
hdisk19         00cd765184ad5a25                    None                        
hdisk20         00cd765184b44c9f                    None                        
hdisk21         00cd7651e7481ac3                    None                        
hdisk22         00cd7651e748753f                    None                        
hdisk23         00cd7651f1464933                    datavg          active      
hdisk24         00cd7651abb6064c                    None                        
hdisk25         00cd7651c8ea9e05                    None                        
hdisk26         00cd765142576fde                    None                        
hdisk27         00cd76517b9b0488                    None                        
hdisk28         00cd7651ecb8f2f4                    None                        
hdisk29         00cd7651e8e17c49                    None                        
hdisk30         00cd7651b3fd1a33                    None                        
root@uxgdc106:/ # 
root@uxgdc106:/ # rmdev -Rdl hdisk30
hdisk30 deleted
root@uxgdc106:/ # 
root@uxgdc106:/ # lspv
hdisk0          00cd7651bf1cd905                    rootvg          active      
hdisk1          00cc37c298f35cbb                    rootvg          active      
hdisk2          00cd7661b5479fc2                    rootvg          active      
hdisk3          00cd7651b521c300                    rootvg          active      
hdisk4          00cd76515d26cced                    datavg          active      
hdisk5          00cd76517f129ed2                    datavg          active      
hdisk31         00cd765185d58327                    datavg          active      
hdisk9          00cd7651812de1cc                    None                        
hdisk6          00cd7651f5cc22f4                    datavg          active      
hdisk7          00cd7651f920d8e3                    None                        
hdisk8          00cd76515a4936b8                    None                        
hdisk10         00cd7651cf913b39                    None                        
hdisk11         00cd76510af824ee                    None                        
hdisk12         00cd765133e8e886                    None                        
hdisk13         00cd765154e18c41                    None                        
hdisk14         00cd7651bba54981                    None                        
hdisk15         00cd7651bbfaa194                    None                        
hdisk16         00cd7651227303c0                    None                        
hdisk17         00cd765166046229                    None                        
hdisk18         00cd765184acc859                    None                        
hdisk19         00cd765184ad5a25                    None                        
hdisk20         00cd765184b44c9f                    None                        
hdisk21         00cd7651e7481ac3                    None                        
hdisk22         00cd7651e748753f                    None                        
hdisk23         00cd7651f1464933                    datavg          active      
hdisk24         00cd7651abb6064c                    None                        
hdisk25         00cd7651c8ea9e05                    None                        
hdisk26         00cd765142576fde                    None                        
hdisk27         00cd76517b9b0488                    None                        
hdisk28         00cd7651ecb8f2f4                    None                        
hdisk29         00cd7651e8e17c49                    None                        
root@uxgdc106:/ # 

可以看到,【hdisk30】已经被清除了。

这样,AIX上的操作就结束了。

后面就可以物理上清理磁盘了。

——————————————————————————
Done。

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒