首页 > 代码库 > 使用cply移动jfs/jfs2文件系统从一个卷组到另一个卷组中

使用cply移动jfs/jfs2文件系统从一个卷组到另一个卷组中

移动jfs/jfs2文件系统从一个卷组到另一个卷组中的目的是是当一个卷组中的空间越来越少,而另外一个卷组中的空间还比较有富余,我们可以把空间紧张中的卷组移动到空间较多的卷组中;

root@testdb:/# uname -ML
IBM,9131-52A 2 aix7001

root@testdb:/# lspv
hdisk0          0007388ca583b447                    rootvg          active      
hdisk1          0007388ca7a889a1                    altinst_rootvg              
hdisk2          000b0856ec68f5de                    testvg          active      
hdisk3          000b0856eede6bdd                    None                  


root@testdb:/# lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       1       1    closed/syncd  N/A
hd6                 paging     6       6       1    open/syncd    N/A
hd8                 jfs2log    1       1       1    open/syncd    N/A
hd4                 jfs2       82      82      1    open/syncd    /
hd2                 jfs2       9       9       1    open/syncd    /usr
hd9var              jfs2       50      50      1    open/syncd    /var
hd3                 jfs2       5       5       1    open/syncd    /tmp
hd1                 jfs2       37      37      1    open/syncd    /home
hd10opt             jfs2       3       3       1    open/syncd    /opt
hd11admin           jfs2       1       1       1    open/syncd    /admin
lg_dumplv           sysdump    4       4       1    open/syncd    N/A
livedump            jfs2       1       1       1    open/syncd    /var/adm/ras/livedump


root@testdb:/# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT


在rootvg 上创建一个jfs2文件系统,移动其到testvg中;

操作过程如下:

root@testdb:/# lsvg rootvg
VOLUME GROUP:       rootvg                   VG IDENTIFIER:  000b08560000d70000000147b7501511
VG STATE:           active                   PP SIZE:        256 megabyte(s)
VG PERMISSION:      read/write               TOTAL PPs:      546 (139776 megabytes)
MAX LVs:            256                      FREE PPs:       346 (88576 megabytes)
LVs:                12                       USED PPs:       200 (51200 megabytes)
OPEN LVs:           11                       QUORUM:         2 (Enabled)
TOTAL PVs:          1                        VG DESCRIPTORS: 2
STALE PVs:          0                        STALE PPs:      0
ACTIVE PVs:         1                        AUTO ON:        yes
MAX PPs per VG:     32512                                     
MAX PPs per PV:     1016                     MAX PVs:        32
LTG size (Dynamic): 256 kilobyte(s)          AUTO SYNC:      no
HOT SPARE:          no                       BB POLICY:      relocatable
PV RESTRICTION:     none                     INFINITE RETRY: no



root@testdb:/# smit lv


root@testdb:/# lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       1       1    closed/syncd  N/A
hd6                 paging     6       6       1    open/syncd    N/A
hd8                 jfs2log    1       1       1    open/syncd    N/A
hd4                 jfs2       82      82      1    open/syncd    /
hd2                 jfs2       9       9       1    open/syncd    /usr
hd9var              jfs2       50      50      1    open/syncd    /var
hd3                 jfs2       5       5       1    open/syncd    /tmp
hd1                 jfs2       37      37      1    open/syncd    /home
hd10opt             jfs2       3       3       1    open/syncd    /opt
hd11admin           jfs2       1       1       1    open/syncd    /admin
lg_dumplv           sysdump    4       4       1    open/syncd    N/A
livedump            jfs2       1       1       1    open/syncd    /var/adm/ras/livedump
testlv              jfs2       4       4       1    closed/syncd  N/A



                                               Add an Enhanced Journaled File System

Type or select values in entry fields.
Press Enter AFTER making all desired changes.
 
                                                        [Entry Fields]
* LOGICAL VOLUME name                               testlv              

                                                      +
* MOUNT POINT                         [/test]
  Mount AUTOMATICALLY at system restart?            yes  

                                                                     +
  PERMISSIONS                                         read/write 

                                                               +
  Mount OPTIONS                                      []

                                                                          +
  Block Size (bytes)                                  4096                                                                       +
  Logical Volume for Log                                                                                                         +
  Inline Log size (MBytes)                           []                                                                           #
  Extended Attribute Format                                                                                                      +
  ENABLE Quota Management?                            no                                                                         +
  Enable EFS?                                         no                                                                         +
  Allow internal snapshots?                           no                                                                         +
  Mount GROUP                                        []          

挂载文件系统


root@testdb:/# mount
  node       mounted        mounted over    vfs       date        options      
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /proc            /proc            procfs Sep 01 21:44 rw              
         /dev/hd10opt     /opt             jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Sep 01 21:44 rw,log=/dev/hd8

root@testdb:/# mount /test
root@testdb:/# mount
  node       mounted        mounted over    vfs       date        options      
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /proc            /proc            procfs Sep 01 21:44 rw              
         /dev/hd10opt     /opt             jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/testlv      /test            jfs2   Sep 02 15:15 rw,log=/dev/hd8



在创建的文件系统上创建文件

root@testdb:/# cd /test
root@testdb:/test# ls -al
total 8
drwxr-xr-x    3 root     system          256 Sep 02 15:14 .
drwxr-xr-x   28 root     system         4096 Sep 02 15:14 ..
drwxr-xr-x    2 root     system          256 Sep 02 15:14 lost+found
root@testdb:/test#
root@testdb:/test#
root@testdb:/test# mkdir xiaowang
root@testdb:/test# touch xiaowangfile
root@testdb:/test# ls -al
total 8
drwxr-xr-x    4 root     system          256 Sep 02 15:16 .
drwxr-xr-x   28 root     system         4096 Sep 02 15:14 ..
drwxr-xr-x    2 root     system          256 Sep 02 15:14 lost+found
drwxr-xr-x    2 root     system          256 Sep 02 15:16 xiaowang
-rw-r--r--    1 root     system            0 Sep 02 15:16 xiaowangfile


移动文件系统到新的卷组中

1、首先要卸载要迁移的文件系统/test


root@testdb:/# umount /test
root@testdb:/# mount
  node       mounted        mounted over    vfs       date        options      
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /proc            /proc            procfs Sep 01 21:44 rw              
         /dev/hd10opt     /opt             jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Sep 01 21:44 rw,log=/dev/hd8

2、使用cplv 命令拷贝源逻辑卷到目的的卷组testvg中

root@testdb:/# cplv -v testvg -y testlvcp testlv

cplv [ -v VolumeGroup ] [ -y NewLogicalVolume | -Y Prefix ] SourceLogicalVolume

cplv: Logical volume testlv successfully copied to testlvcp .
root@testdb:/# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
testlvcp            jfs2       8       8       1    closed/syncd  N/A


3、在testvg上创建日志设备并格式化

root@testdb:/# mklv -t jfs2log testvg 1
loglv00
root@testdb:/# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
testlvcp            jfs2       8       8       1    closed/syncd  N/A
loglv00             jfs2log    1       1       1    closed/syncd  N/A
root@testdb:/# logform /dev/loglv00
logform: destroy /dev/rloglv00 (y)?y
root@testdb:/# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
testlvcp            jfs2       8       8       1    closed/syncd  N/A
loglv00             jfs2log    1       1       1    closed/syncd  N/A 

4、使用chfs 命令改变文件系统以引用新的卷组和新的逻辑卷中的日志设备


root@testdb:/# chfs -a dev=/dev/testlvcp -a log=/dev/loglv00 /test
root@testdb:/# 


5、运行fsck 确保文件系统的完整性

root@testdb:/# fsck   
 
The current volume is: /dev/hd1
File system is currently mounted.
Primary superblock is valid.
fsck: Performing read-only processing does not produce dependable results.
*** Phase 1 - Initial inode scan
*** Phase 2 - Process remaining directories
*** Phase 3 - Process remaining files
*** Phase 4 - Check inode allocation map
*** Phase 5 - Check block allocation map
File system is currently mounted.
fsck: Performing read-only processing does not produce dependable results.

The current volume is: /dev/hd10opt
File system is currently mounted.
Primary superblock is valid.
fsck: Performing read-only processing does not produce dependable results.
*** Phase 1 - Initial inode scan
*** Phase 2 - Process remaining directories
*** Phase 3 - Process remaining files
*** Phase 4 - Check inode allocation map
*** Phase 5 - Check block allocation map
File system is currently mounted.
fsck: Performing read-only processing does not produce dependable results.


6、挂载文件系统

root@testdb:/# mount /test
root@testdb:/# mount
  node       mounted        mounted over    vfs       date        options      
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Sep 01 21:43 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /proc            /proc            procfs Sep 01 21:44 rw              
         /dev/hd10opt     /opt             jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Sep 01 21:44 rw,log=/dev/hd8
         /dev/testlvcp    /test            jfs2   Sep 02 15:35 rw,log=/dev/loglv00


root@testdb:/# cd /test

root@testdb:/test# ls -al
total 8
drwxr-xr-x    4 root     system          256 Sep 02 15:16 .
drwxr-xr-x   28 root     system         4096 Sep 02 15:14 ..
drwxr-xr-x    2 root     system          256 Sep 02 15:14 lost+found
drwxr-xr-x    2 root     system          256 Sep 02 15:16 xiaowang
-rw-r--r--    1 root     system            0 Sep 02 15:16 xiaowangfile


7、删除原来的逻辑卷源


root@testdb:/test# lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       1       1    closed/syncd  N/A
hd6                 paging     6       6       1    open/syncd    N/A
hd8                 jfs2log    1       1       1    open/syncd    N/A
hd4                 jfs2       82      82      1    open/syncd    /
hd2                 jfs2       9       9       1    open/syncd    /usr
hd9var              jfs2       50      50      1    open/syncd    /var
hd3                 jfs2       5       5       1    open/syncd    /tmp
hd1                 jfs2       37      37      1    open/syncd    /home
hd10opt             jfs2       3       3       1    open/syncd    /opt
hd11admin           jfs2       1       1       1    open/syncd    /admin
lg_dumplv           sysdump    4       4       1    open/syncd    N/A
livedump            jfs2       1       1       1    open/syncd    /var/adm/ras/livedump
testlv              jfs2       4       4       1    closed/syncd  N/A
root@testdb:/test# rmlv testlv
Warning, all data contained on logical volume testlv will be destroyed.
rmlv: Do you wish to continue? y(es) n(o)? y
rmlv: Logical volume testlv is removed.
root@testdb:/test# lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       1       1    closed/syncd  N/A
hd6                 paging     6       6       1    open/syncd    N/A
hd8                 jfs2log    1       1       1    open/syncd    N/A
hd4                 jfs2       82      82      1    open/syncd    /
hd2                 jfs2       9       9       1    open/syncd    /usr
hd9var              jfs2       50      50      1    open/syncd    /var
hd3                 jfs2       5       5       1    open/syncd    /tmp
hd1                 jfs2       37      37      1    open/syncd    /home
hd10opt             jfs2       3       3       1    open/syncd    /opt
hd11admin           jfs2       1       1       1    open/syncd    /admin
lg_dumplv           sysdump    4       4       1    open/syncd    N/A
livedump            jfs2       1       1       1    open/syncd    /var/adm/ras/livedump


需要注意

1、移动前要卸载源文件系统

2、在目的卷组上使用chfs命令创建日志设备以引用新的卷组;

使用cply移动jfs/jfs2文件系统从一个卷组到另一个卷组中