ITPub博客

首页 > 数据库 > Oracle > CentOS 7.6 标准分区修改为lvm

CentOS 7.6 标准分区修改为lvm

原创 Oracle 作者:tiny_cion 时间:2020-09-29 20:24:14 0 删除 编辑

术语介绍:

PV(Physical Volume)- 物理卷

物理卷在逻辑卷管理中处于最底层,它可以是实际物理硬盘上的分区,也可以是整个物理硬盘

VG(Volumne Group)- 卷组

卷组建立在物理卷之上,一个卷组中至少要包括一个物理卷,在卷组建立之后可动态添加物理卷到卷组中。一个逻辑卷管理系统工程中可以只有一个卷组,也可以拥有多个卷组。

LV(Logical Volume)- 逻辑卷

逻辑卷建立在卷组之上,卷组中的未分配空间可以用于建立新的逻辑卷,逻辑卷建立后可以动态地扩展和缩小空间。系统中的多个逻辑卷可以属于同一个卷组,也可以属于不同的多个卷组。

方法:

1.划分lvm和扩大lvm

1.1)创建lv

#fdisk /dev/sdc

#pvcreate /dev/sdc1

Physical volume "/dev/sdc1" successfully created.

#vgcreate vg2020 /dev/sdc1

Volume group "vg2020" successfully created

#vgdisplay   查看Free PE

 Free  PE / Size       76799 / <300.00 GiB

#lvcreate -L 299G -n LV20 vg2020

 Logical volume "LV20" created.

#lvcreate -L 100%VG -n LV20 vg2020

#lvscan

ACTIVE            '/dev/vg2020/LV20' [299.00 GiB] inherit

#mkfs.xfs /dve/vg2020/LV20

1.2)添加

umount最好提前做好备份(有丢失数据的风险)

#umount /data

如果busy执行下面的语句

# fuser -mv -k /data

#umount /data

#fdisk /dev/sdd

#pvcreate /dev/sdd

将/dev/sdd1添加到vg2020卷组中

#vgextend vg2020 /dev/sdd1

查看大小

#pvdisplay

#lvscan 或lvdisplay 查看路径

ACTIVE            '/dev/vg2020/LV20' [299.00 GiB] inherit

#mount /dev/vg2020/LV20 /data

增加逻辑卷100G

#lvextend -L +100G /dev/vg2020/LV20

此时/data文件大小并没有变,还需使用resize2fs,重新定义文件系统大小

#resize2f  /dev/vg2020/LV20

#vi /etc/fstab

/dev/vg2020/LV20    /data    xfs      defaults   0 0

挂载之后记得要写入开机文本中

#df -h    看空间是否增加

#reboot 看是否自动挂载

其它命令可参考如下

https://jingyan.baidu.com/article/fedf0737772d2835ac897790.html


思路:
1、添加空间,然后将磁盘修改为lvm,然后将u01目录迁移过去
2、有空余空间可作为创建lvm分区,然后迁移

现场是/home目录有足够的空间,/u01是单独的挂载目录,所以考虑将u01目录打包发送到/home目录下,然后将u01重新设置成lvm分区

详细操作:

1、查看pvcreate命令
[root@tsdb01 bin]# pvcreate
-bash: pvcreate: command not found
没有这个命令,即通过yum进行安装(两节点)
# yum -y install lvm*

2.停数据库、集群、监听(两节点)

3.备份u01目录到/home/bak下(两节点)
#mkdir -p /home/bak
#cd /home/bak
#tar -zcvf u01.tar.gz /u01

查看blkid

节点1
[root@tsdb01 home]# blkid
/dev/vda2: UUID="e4bc0543-19de-4c04-8667-6f6a9e09f7c9" TYPE="xfs"
/dev/vda1: UUID="28de0b80-fb53-4bd2-96e3-02d15135385f" TYPE="xfs"
/dev/vda3: UUID="ea09e041-0a0a-4be1-a77b-aac6d04632cf" TYPE="swap"
/dev/vda5: UUID="65972b46-175b-47b5-ad70-700b282a7781" TYPE="xfs"
/dev/vdb1: UUID="748892f0-dcb0-4511-9b30-133d746dfde3" TYPE="xfs"
/dev/sr0: UUID="2018-11-25-23-54-16-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sde1: TYPE="oracleasm"
/dev/sdb1: TYPE="oracleasm"
/dev/sdh1: TYPE="oracleasm"
/dev/sdd1: TYPE="oracleasm"
/dev/sda1: TYPE="oracleasm"
/dev/sdg1: TYPE="oracleasm"
/dev/sdc1: TYPE="oracleasm"
/dev/sdf1: TYPE="oracleasm"

节点2
[root@tsdb02 home]# blkid
/dev/vda2: UUID="9ac9aa76-6847-4e8c-81ff-53bf2c0bc367" TYPE="xfs"
/dev/vda1: UUID="a212255f-464e-46b4-99dc-2ad8d5baffdf" TYPE="xfs"
/dev/vda3: UUID="dd1566ef-1ea5-4d43-a525-ce79ffaef956" TYPE="swap"
/dev/vda5: UUID="f1e4ce93-4d16-464c-86de-b391167f662b" TYPE="xfs"
/dev/vdb1: UUID="a4be0692-e0b6-44e7-bb30-d7e4ee806ff0" TYPE="xfs"
/dev/sr0: UUID="2018-11-25-23-54-16-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sdc1: TYPE="oracleasm"
/dev/sdh1: TYPE="oracleasm"
/dev/sde1: TYPE="oracleasm"
/dev/sdb1: TYPE="oracleasm"
/dev/sdg1: TYPE="oracleasm"
/dev/sdd1: TYPE="oracleasm"
/dev/sdf1: TYPE="oracleasm"
/dev/sda1: TYPE="oracleasm"

4.fdisk -l查看分区情况

节点1
Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 sectors
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   629145599   314571776   83  Linux
节点2
Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 sectors
  Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   629145599   314571776   83  Linux

5.重新划分空间

节点1

先umount
# fuser -mv -k /u01
                     USER        PID ACCESS COMMAND
/u01:                root     kernel mount /u01
                     grid      13435 F.c.. sleep
                     grid      13500 F.c.. sleep
                     root      30940 F..e. java
[root@tsdb01 bak]# umount /u01
#fdisk /dev/vdb
[root@tsdb01 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): q

[root@tsdb01 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-629145599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599):
Using default value 629145599
Partition 1 of type Linux and of size 300 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

节点2
先umount
# fuser -mv -k /u01
                     USER        PID ACCESS COMMAND
/u01:                root     kernel mount /u01
                     grid      13435 F.c.. sleep
                     grid      13500 F.c.. sleep
                     root      30940 F..e. java
[root@tsdb02 bak]# umount /u01
# fdisk /dev/vdb

6.建立lvm分区并查看

节点1:因之前没有umount报如下错误
#pvcreate /dev/vdb1
[root@tsdb01 ~]# pvcreate /dev/vdb1
  Device vg2020 not found.
  Can't open /dev/vdb1 exclusively.  Mounted filesystem?
  Can't open /dev/vdb1 exclusively.  Mounted filesystem?
[root@tsdb01 ~]# umount /u01
umount: /u01: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@tsdb01 /]# umount /u01
umount: /u01: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@tsdb01 /]# fuser -mv -k /u01
                     USER        PID ACCESS COMMAND
/u01:                root     kernel mount /u01
                     ogg        6014 ....m mgr
                     grid      23000 F.c.. OSWatcher.sh
                     grid      24111 F.c.. OSWatcherFM.sh
                     root      31927 F..e. java
                     grid      36355 F.c.. sleep
                     grid      36513 F.c.. sleep

立即
# umount /u01
#pvcreate /dev/vdb1
#vgcreate vg2020 /dev/vdb1
[root@tsdb01 u01]# vgcreate vg2020 /dev/vdb1
WARNING: xfs signature detected on /dev/vdb1 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/vdb1.
  Physical volume "/dev/vdb1" successfully created.
  Volume group "vg2020" successfully created

节点2
[root@tsdb02 bak]# pvcreate  /dev/vdb1
  Device vg2020 not found.
WARNING: xfs signature detected on /dev/vdb1 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/vdb1.
  Physical volume "/dev/vdb1" successfully created.

节点1遇到如下错误处理方法
[root@tsdb01 u01]# pvcreate /dev/vdb1
  Can't initialize physical volume "/dev/vdb1" of volume group "vg2020" without -ff
  /dev/vdb1: physical volume not initialized.
[root@tsdb01 u01]# vgreduce vg2020 /dev/vdb1
  Can't remove final physical volume "/dev/vdb1" from volume group "vg2020"
[root@tsdb01 u01]# vg
vgcfgbackup    vgck           vgdisplay      vgimport       vgmknodes      vgrename       vgsplit
vgcfgrestore   vgconvert      vgexport       vgimportclone  vgreduce       vgs            
vgchange       vgcreate       vgextend       vgmerge        vgremove       vgscan         
[root@tsdb01 u01]# vgremove vg2020 /dev/vdb1
  Volume group "vg2020" successfully removed
  Volume group "vdb1" not found
  Cannot process volume group vdb1
[root@tsdb01 u01]# pvcreate /dev/vdb1
  Physical volume "/dev/vdb1" successfully created.

节点2
[root@tsdb02 bak]# vgcreate vg2020 /dev/vdb1
  Volume group "vg2020" successfully created

节点1
# # vgdisplay
  --- Volume group ---
  VG Name               vg2020
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <300.00 GiB
  PE Size               4.00 MiB
  Total PE              76799
  Alloc PE / Size       0 / 0   
  Free  PE / Size       76799 / <300.00 GiB
  VG UUID               o3f0g5-jgMW-KhIf-v9jk-Kujo-vhY3-Hmff1Y


节点2
[root@tsdb02 bak]# vgdisplay
  --- Volume group ---
  VG Name               vg2020
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <300.00 GiB
  PE Size               4.00 MiB
  Total PE              76799
  Alloc PE / Size       0 / 0   
  Free  PE / Size       76799 / <300.00 GiB
  VG UUID               PU6eiu-x3tq-X3v3-IENR-M9Sn-yQ6O-cHSC7y

节点1
[root@tsdb01 u01]# lvcreate -L 300G -n LV20 vg2020
  Volume group "vg2020" has insufficient free space (76799 extents): 76800 required.
[root@tsdb01 u01]# lvcreate -L 299G -n LV20 vg2020
  Logical volume "LV20" created.

节点2
[root@tsdb02 bak]# lvcreate -L 299G -n LV20 vg2020
  Logical volume "LV20" created.

节点1
[root@tsdb01 u01]# lvscan
  ACTIVE            '/dev/vg2020/LV20' [299.00 GiB] inherit
# mkfs.xfs /dev/vg2020/LV20

节点2
[root@tsdb02 bak]# lvscan
  ACTIVE            '/dev/vg2020/LV20' [299.00 GiB] inherit

[root@tsdb02 bak]# mkfs.xfs /dev/vg2020/LV20
meta-data=/dev/vg2020/LV20       isize=512    agcount=4, agsize=19595264 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=78381056, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=38272, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

节点1
[root@tsdb01 ~]# mount /dev/vg2020/LV20 /u01

节点2
[root@tsdb02 bak]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda2        47G   24G   24G  51% /
devtmpfs         32G     0   32G   0% /dev
tmpfs            32G     0   32G   0% /dev/shm
tmpfs            32G  226M   32G   1% /run
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/vda5        72G   28G   44G  39% /home
/dev/vda1       950M  185M  766M  20% /boot
tmpfs           6.3G     0  6.3G   0% /run/user/0
[root@tsdb02 bak]# mount /dev/vg2020/LV20 /u01
[root@tsdb02 bak]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/vda2                 47G   24G   24G  51% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  226M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda5                 72G   28G   44G  39% /home
/dev/vda1                950M  185M  766M  20% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
/dev/mapper/vg2020-LV20  299G   33M  299G   1% /u01

节点1
[root@tsdb01 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/vda2                 47G   40G  7.1G  85% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  714M   31G   3% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda5                 72G   23G   50G  32% /home
/dev/vda1                950M  185M  766M  20% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
/dev/mapper/vg2020-LV20  299G   33M  299G   1% /u01

节点2:
修改/etc/fstab
原:
[root@tsdb02 bak]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Oct  8 03:03:59 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9ac9aa76-6847-4e8c-81ff-53bf2c0bc367 /                       xfs     defaults        0 0
UUID=a212255f-464e-46b4-99dc-2ad8d5baffdf /boot                   xfs     defaults        0 0
UUID=f1e4ce93-4d16-464c-86de-b391167f662b /home                   xfs     defaults        0 0
UUID=dd1566ef-1ea5-4d43-a525-ce79ffaef956 swap                    swap    defaults        0 0
tmpfs    /dev/shm    tmpfs    rw,exec    0 0
/dev/vdb1    /u01    xfs      defaults   0 0
修改后:
[root@tsdb02 bak]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Oct  8 03:03:59 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9ac9aa76-6847-4e8c-81ff-53bf2c0bc367 /                       xfs     defaults        0 0
UUID=a212255f-464e-46b4-99dc-2ad8d5baffdf /boot                   xfs     defaults        0 0
UUID=f1e4ce93-4d16-464c-86de-b391167f662b /home                   xfs     defaults        0 0
UUID=dd1566ef-1ea5-4d43-a525-ce79ffaef956 swap                    swap    defaults        0 0
tmpfs    /dev/shm    tmpfs    rw,exec    0 0
#/dev/vdb1    /u01    xfs      defaults   0 0
/dev/vg2020/LV20    /u01    xfs      defaults   0 0
先确认/etc/fstab里面是否已经修改为最新的,不然重启会报错
#reboot


7.将u01.tar.gz解压到/u01下
节点1
#tar -xzvf u01.tar.gz -C /u01/
#mv /u01/u01/* .
节点2
[root@tsdb02 bak]# tar -xzvf u01.tar.gz  -C /u01/

8.启动数据库集群

这里遇到一个问题,就是在节点2压缩拷贝的时候,没有压缩完,结果cancle了,后面解压还原回去的时候少了lsInventory目录还有少了审计目录。

解决方法:root用户将节点1的lsInventory目录打包发送到节点2对应路径解压还原,根据spfile.ora文件创建审计目录问题解决。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30654353/viewspace-2725167/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2015-12-23

  • 博文量
    18
  • 访问量
    7854