Linux将Oracle安装目录从根目录下迁移到逻辑卷

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux将Oracle安装目录从根目录下迁移到逻辑卷相关的知识,希望对你有一定的参考价值。

Linux】将Oracle安装目录从根目录下迁移到逻辑卷

 

1.1  BLOG文档结构图

技术分享 

 

1.2  前言部分

1.2.1  导读和注意事项

各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~

Linux逻辑卷的创建和管理(重点)

 

1.2.2  相关文章链接

linux逻辑卷管理:http://blog.itpub.net/26736162/viewspace-2124620/,这篇文章非常不错。

1.2.3  本文简介

由于Oracle版本太多,鉴于学习使用,所以,小麦苗在RHEL6.5上安装了Oracle 11.2.0.3Oracle 10.2.0.1Oracle 10.2.0.4。但是由于没有采用逻辑卷的管理方式,现在根目录磁盘空间不足,而且也添加了好几块硬盘了,管理非常不方便。以后等Oracle 12cR2出来后还得安装在一起,想了想还是一次性将这些Oracle的安装目录都迁移到逻辑卷中,以后也好管理。本文记录了迁移过程,以备有同样需求的朋友使用。

 

1.3  迁移过程

1.3.1  磁盘现状

技术分享 

最后操作的结果就是把磁盘2、345去掉,只剩下1块或2块磁盘。

 

1.3.2  分区并创建物理卷

[[email protected]_lhr ~]# df -h

Filesystem                 Size  Used Avail Use% Mounted on

/dev/sda2                   48G   43G  3.0G  94% /

tmpfs                      2.0G  432M  1.6G  22% /dev/shm

/dev/sda1                  283M   58M  210M  22% /boot

/dev/mapper/testvg-testlv  380M  321M   40M  90% /var/lib/mysql

/dev/sdc1                  9.9G  4.0G  5.5G  43% /u03

/dev/sde1                   20G  7.3G   12G  39% /u04

/dev/sdf1                   50G   30G   18G  63% /u05

 

[[email protected]_lhr ~]# fdisk -l |grep dev

Disk /dev/sda: 107.4 GB, 107374182400 bytes

/dev/sda1   *           1          39      307200   83  Linux

/dev/sda2              39        6401    51104768   83  Linux

/dev/sda3            6401        6528     1015808   82  Linux swap / Solaris

/dev/sda4            6528       13054    52427455    5  Extended

Disk /dev/sdc: 10.7 GB, 10737418240 bytes

/dev/sdc1               1        1305    10482381   83  Linux

Disk /dev/sdd: 5368 MB, 5368709120 bytes

Disk /dev/sdf: 53.7 GB, 53687091200 bytes

/dev/sdf1               1        6527    52428096   83  Linux

Disk /dev/sdg: 21.5 GB, 21474836480 bytes

Disk /dev/sde: 21.5 GB, 21474836480 bytes

/dev/sde1               1        2610    20964793+  83  Linux

Disk /dev/mapper/testvg-testlv: 419 MB, 419430400 bytes

[[email protected]_lhr ~]#

[[email protected]_lhr ~]# fdisk /dev/sda

 

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to

         switch off the mode (command ‘c‘) and change display units to

         sectors (command ‘u‘).

 

Command (m for help): p

 

Disk /dev/sda: 107.4 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000bd0a0

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          39      307200   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              39        6401    51104768   83  Linux

/dev/sda3            6401        6528     1015808   82  Linux swap / Solaris

 

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition‘s system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 

Command (m for help): l

 

0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris       

1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-

2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-

3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-

4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx        

5  Extended        42  SFS             86  NTFS volume set da  Non-FS data   

6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .

7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility  

8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt        

9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access    

a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O       

b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor     

c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs       

e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT           

f  W95 Ext‘d (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/

10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b

11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor     

12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor     

14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary 

16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS   

17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE

18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep       

1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT           

1e  Hidden W95 FAT1

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Selected partition 4

First cylinder (6528-13054, default 6528):

Using default value 6528

Last cylinder, +cylinders or +size{K,M,G} (6528-13054, default 13054):

Using default value 13054

 

Command (m for help): t

Partition number (1-4): 4

Hex code (type L to list codes): 8e

Changed system type of partition 4 to 8e (Linux LVM)

 

Command (m for help): p

 

Disk /dev/sda: 107.4 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000bd0a0

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          39      307200   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              39        6401    51104768   83  Linux

/dev/sda3            6401        6528     1015808   82  Linux swap / Solaris

/dev/sda4            6528       13054    52427455   8e  Linux LVM

 

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.

[[email protected]_lhr ~]# partprobe

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdc (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sde (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdf (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

[[email protected]_lhr ~]#

[[email protected]_lhr ~]#

[[email protected]_lhr ~]# pvcreate /dev/sda4

  dev_is_mpath: failed to get device for 8:4

  dev_is_mpath: failed to get device for 8:4

  Device /dev/sda4 not found (or ignored by filtering).

[[email protected]_lhr ~]# fdisk -l /dev/sda

 

Disk /dev/sda: 107.4 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000bd0a0

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          39      307200   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              39        6401    51104768   83  Linux

/dev/sda3            6401        6528     1015808   82  Linux swap / Solaris

/dev/sda4            6528       13054    52427455   8e  Linux LVM

[[email protected]_lhr ~]#

 

[[email protected]_lhr ~]# pvcreate /dev/sda4

  Device /dev/sda4 not found (or ignored by filtering).

[[email protected]_lhr ~]# l /dev/sda4

brw-rw---- 1 root disk 8, 4 Dec 26 09:51 /dev/sda4

[[email protected]_lhr ~]# reboot

 

Broadcast message from [email protected]_lhr

        (/dev/pts/1) at 10:12 ...

 

The system is going down for reboot NOW!

[[email protected]_lhr ~]#

Last login: Mon Dec 26 10:06:09 2016 from 192.168.59.1

[[email protected]_lhr ~]#

[[email protected]_lhr ~]# df -h

Filesystem                 Size  Used Avail Use% Mounted on

/dev/sda2                   48G   43G  3.0G  94% /

tmpfs                      2.0G     0  2.0G   0% /dev/shm

/dev/sda1                  283M   58M  210M  22% /boot

/dev/mapper/testvg-testlv  380M  321M   40M  90% /var/lib/mysql

/dev/sdc1                  9.9G  4.0G  5.5G  43% /u03

/dev/sde1                   20G  7.3G   12G  39% /u04

/dev/sdf1                   50G   30G   18G  63% /u05

[[email protected]_lhr ~]# fdisk -l /dev/sda

 

Disk /dev/sda: 107.4 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000bd0a0

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          39      307200   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              39        6401    51104768   83  Linux

/dev/sda3            6401        6528     1015808   82  Linux swap / Solaris

/dev/sda4            6528       13054    52427455   8e  Linux LVM

[[email protected]_lhr ~]# pvcreate /dev/sda4

  Physical volume "/dev/sda4" successfully created

[[email protected]_lhr ~]#

[[email protected]_lhr ~]# pvs

  PV         VG     Fmt  Attr PSize  PFree

  /dev/sda4         lvm2 a--  50.00g 50.00g

[[email protected]_lhr ~]# pvs

  PV         VG     Fmt  Attr PSize  PFree

  /dev/sda4         lvm2 a--  50.00g 50.00g

[[email protected]_lhr ~]# pvdisplay  

  "/dev/sda4" is a new physical volume of "50.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sda4

  VG Name              

  PV Size               50.00 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               NgZ5Vl-Jbkn-9U71-9Ypp-i2nH-HhlT-cSPQ3o

 

 

 

 

1.3.3  创建卷组

[[email protected]_lhr ~]# vgcreate vg_orasoft /dev/sda4

  Volume group "vg_orasoft" successfully created

[[email protected]_lhr ~]# vgdisplay 

  --- Volume group ---

  VG Name               vg_orasoft

  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               50.00 GiB

  PE Size               4.00 MiB

  Total PE              12799

  Alloc PE / Size       0 / 0  

  Free  PE / Size       12799 / 50.00 GiB

  VG UUID               PyRYUt-ERDU-NU4o-NWHA-anpD-iTIA-aMGLnV

  

[[email protected]_lhr ~]# vgs

  VG         #PV #LV #SN Attr   VSize  VFree

  vg_orasoft   1   0   0 wz--n- 50.00g 50.00g

[[email protected]_lhr ~]# pvs

  PV         VG         Fmt  Attr PSize  PFree

  /dev/sda4  vg_orasoft lvm2 a--  50.00g 50.00g

[[email protected]_lhr ~]# pvdisplay

  --- Physical volume ---

  PV Name               /dev/sda4

  VG Name               vg_orasoft

  PV Size               50.00 GiB / not usable 2.69 MiB

  Allocatable           yes

  PE Size               4.00 MiB

  Total PE              12799

  Free PE               12799

  Allocated PE          0

  PV UUID               NgZ5Vl-Jbkn-9U71-9Ypp-i2nH-HhlT-cSPQ3o

 

 

 

 

1.3.4  创建逻辑卷

[[email protected]_lhr ~]#

[[email protected]_lhr ~]#  lvcreate -n lv_ora_soft_u01 -L 35G vg_orasoft

  Logical volume "lv_ora_soft_u01" created

[[email protected]_lhr ~]# lvdisplay  

  --- Logical volume ---

  LV Path                /dev/vg_orasoft/lv_ora_soft_u01

  LV Name                lv_ora_soft_u01

  VG Name                vg_orasoft

  LV UUID                FYWeeZ-DMxB-MKBo-Lpeb-kVEz-yCFY-M2Ddmr

  LV Write Access        read/write

  LV Creation host, time rhel6_lhr, 2016-12-26 11:06:03 +0800

  LV Status              available

  # open                 0

  LV Size                35.00 GiB

  Current LE             8960

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:1

  

[[email protected]_lhr ~]# lvs

  LV              VG         Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert

  lv_ora_soft_u01 vg_orasoft -wi-a-----  35.00g                                            

[[email protected]_lhr ~]#

[[email protected]_lhr ~]# vgs

  VG         #PV #LV #SN Attr   VSize  VFree

  vg_orasoft   1   1   0 wz--n- 50.00g 15.00g

[[email protected]_lhr ~]# pvs

  PV         VG         Fmt  Attr PSize  PFree

  /dev/sda4  vg_orasoft lvm2 a--  50.00g 15.00g

[[email protected]_lhr ~]# mkfs.ext4 /dev/vg_orasoft/lv_ora_soft_u01

mke2fs 1.43-WIP (20-Jun-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

2293760 inodes, 9175040 blocks

458752 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

280 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624

 

Allocating group tables: done                           

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done  

 

 

1.3.5  停止Oracle的所有进程

 

[[email protected]_lhr ~]# ps -ef|grep ora

grid      3087     1  0 10:18 ?        00:00:27 /u01/app/grid/11.2.0/bin/oraagent.bin

。。。。。。。。。。。。。。。。。。。。。。。。。。。

oracle    6197     1  0 11:04 ?        00:00:00 ora_w000_orclasm

oracle    6283     1  0 11:05 ?        00:00:00 ora_w001_orclasm

root      6361  2323  0 11:07 pts/1    00:00:00 grep ora

[[email protected]_lhr ~]# crsctl stop has -f

CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘rhel6_lhr‘

CRS-2673: Attempting to stop ‘ora.LISTENER.lsnr‘ on ‘rhel6_lhr‘

CRS-2673: Attempting to stop ‘ora.orclasm.db‘ on ‘rhel6_lhr‘

。。。。。。。。。。。。。。。。。

CRS-4133: Oracle High Availability Services has been stopped.

[[email protected]_lhr ~]# ps -ef|grep ora  

root      6420  2323  0 11:07 pts/1    00:00:00 grep ora

[[email protected]_lhr ~]# ps -ef|grep d.bin

root      6425  2323  0 11:07 pts/1    00:00:00 grep d.bin

 


内容太多,放不下,请看如下的连接。。。。。。。。。。。。。。。


About Me

...............................................................................................................................

本文作者:小麦苗,只专注于数据库的技术,更注重技术的运用

本文在itpub(http://blog.itpub.net/26736162)、博客园http://www.cnblogs.com/lhrbest和个人微信公众号(xiaomaimiaolhr)上有同步更新

本文itpub地址:http://blog.itpub.net/26736162/viewspace-2131488/

本文博客园地址:http://www.cnblogs.com/lhrbest/p/6227487.html

本文pdf版小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/

● QQ群:230161599     微信群:私聊

联系我请加QQ好友(642808185),注明添加缘由

2016-12-26 08:00 ~ 2016-12-27 24:00农行完成

文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解

版权所有,欢迎分享本文,转载请保留出处

...............................................................................................................................

手机长按下图识别二维码或微信客户端扫描下边的二维码来关注小麦苗的微信公众号:xiaomaimiaolhr,免费学习最实用的数据库技术。

技术分享

 

技术分享

以上是关于Linux将Oracle安装目录从根目录下迁移到逻辑卷的主要内容,如果未能解决你的问题,请参考以下文章

linux下docker容器存放磁盘空间迁移

数据库迁移系列从Oracle迁移到openGauss实战分享

Linux下安装oracle中执行./runInstaller 提示没有这个文件或目录是怎么回事?

linux怎么将mysql数据移动到挂载的硬盘上

linux怎么将mysql数据移动到挂载的硬盘上

Linux平台下使用rman进行oracle数据库迁移