我有一个名为“加密”的卷组,其设备名称是/dev/xvdj
。
[root@s-mysql /]# lsblk
xvdj 202:144 0 3T 0 disk
└─xvdj1 202:145 0 3T 0 part
├─encrypted-home_vol 253:6 0 2G 0 lvm /home
├─encrypted-local_vol 253:7 0 2G 0 lvm /usr/local
├─encrypted-opt_vol 253:8 0 4G 0 lvm /opt
├─encrypted-tmp_vol 253:9 0 4G 0 lvm /tmp
└─encrypted-var_vol 253:10 0 3T 0 lvm /var
我有另一个磁盘。此磁盘也是 LVM,其组名也encrypted
因磁盘的创建方式而得名。我想执行以下操作:
创建从 new_disk (/var/lib/mysql) 到 old_disk (/var/lib/mysql) 的符号链接
所以我做了以下事情。
# rename the old encrypted to old
vgrename encrypted old
# update cahce
pvscan --cache
到目前为止,我已经
[root@s-mysql /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
xvdf 202:80 0 3T 0 disk
└─xvdf1 202:81 0 3T 0 part
xvdj 202:144 0 3T 0 disk
└─xvdj1 202:145 0 3T 0 part
├─old-home_vol 253:6 0 2G 0 lvm /home
├─old-local_vol 253:7 0 2G 0 lvm /usr/local
├─old-opt_vol 253:8 0 4G 0 lvm /opt
├─old-tmp_vol 253:9 0 4G 0 lvm /tmp
└─old-var_vol 253:10 0 3T 0 lvm /var
通知/dev/xvdf
尚未发布。我希望到目前为止一切正常。
[root@s-mysql /]# pvdisplay
--- Physical volume ---
PV Name /dev/sdf1
VG Name encrypted
PV Size <3.00 TiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 786431
Free PE 13056
Allocated PE 773375
PV UUID TSeqC4-EsEA-NBYf-3ACd-aNh7-9q7o-Op5yJU
--- Physical volume ---
PV Name /dev/sdj1
VG Name old
PV Size <3.00 TiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 786431
Free PE 15359
Allocated PE 771072
PV UUID usM0iR-1eGw-CeC8-BQd3-Hr9I-BezY-PRyp1K
现在,如果我挂载,我会得到这个:
[root@s-mysql /]# vgchange -a y
6 logical volume(s) in volume group "encrypted" now active
5 logical volume(s) in volume group "old" now active
[root@s-mysql /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdb 202:16 0 25G 0 disk
└─xvdb1 202:17 0 25G 0 part
xvdf 202:80 0 3T 0 disk
└─xvdf1 202:81 0 3T 0 part
├─encrypted-home_vol 253:0 0 2G 0 lvm /home
├─encrypted-local_vol 253:1 0 2G 0 lvm /usr/local
├─encrypted-opt_vol 253:2 0 4G 0 lvm /opt
├─encrypted-tmp_vol 253:3 0 4G 0 lvm /tmp
├─encrypted-var_vol 253:4 0 3T 0 lvm /var
└─encrypted-usr_vol 253:5 0 9G 0 lvm
xvdj 202:144 0 3T 0 disk
└─xvdj1 202:145 0 3T 0 part
├─old-home_vol 253:6 0 2G 0 lvm /home
├─old-local_vol 253:7 0 2G 0 lvm /usr/local
├─old-opt_vol 253:8 0 4G 0 lvm /opt
├─old-tmp_vol 253:9 0 4G 0 lvm /tmp
└─old-var_vol 253:10 0 3T 0 lvm /var
这可不好。我们有/var
。我的问题是,我该如何/var/lib/mysql
从新磁盘挂载“”/dev/xvdf
并创建符号链接,这样我就可以替换旧磁盘,/var/lib/mysql
因为它们都存在/var
?
答案1
您可以创建不同的挂载点(例如/var2
),在那里挂载所需的 LV,删除当前/var/lib/mysql
并创建软链接
ln -s /var2/lib/mysql /var/lib/mysql