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

简介:

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

 

1.1  BLOG文档结构图

wpsC00A.tmp 

 

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  磁盘现状

wpsC00B.tmp 

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

 

1.3.2  分区并创建物理卷

[root@rhel6_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

 

[root@rhel6_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

[root@rhel6_lhr ~]#

[root@rhel6_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.

[root@rhel6_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.

[root@rhel6_lhr ~]#

[root@rhel6_lhr ~]#

[root@rhel6_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).

[root@rhel6_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

[root@rhel6_lhr ~]#

 

[root@rhel6_lhr ~]# pvcreate /dev/sda4

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

[root@rhel6_lhr ~]# l /dev/sda4

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

[root@rhel6_lhr ~]# reboot

 

Broadcast message from root@rhel6_lhr

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

 

The system is going down for reboot NOW!

[root@rhel6_lhr ~]#

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

[root@rhel6_lhr ~]#

[root@rhel6_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

[root@rhel6_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

[root@rhel6_lhr ~]# pvcreate /dev/sda4

  Physical volume "/dev/sda4" successfully created

[root@rhel6_lhr ~]#

[root@rhel6_lhr ~]# pvs

  PV         VG     Fmt  Attr PSize  PFree

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

[root@rhel6_lhr ~]# pvs

  PV         VG     Fmt  Attr PSize  PFree

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

[root@rhel6_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  创建卷组

[root@rhel6_lhr ~]# vgcreate vg_orasoft /dev/sda4

  Volume group "vg_orasoft" successfully created

[root@rhel6_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

  

[root@rhel6_lhr ~]# vgs

  VG         #PV #LV #SN Attr   VSize  VFree

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

[root@rhel6_lhr ~]# pvs

  PV         VG         Fmt  Attr PSize  PFree

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

[root@rhel6_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  创建逻辑卷

[root@rhel6_lhr ~]#

[root@rhel6_lhr ~]#  lvcreate -n lv_ora_soft_u01 -L 35G vg_orasoft

  Logical volume "lv_ora_soft_u01" created

[root@rhel6_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

  

[root@rhel6_lhr ~]# lvs

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

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

[root@rhel6_lhr ~]#

[root@rhel6_lhr ~]# vgs

  VG         #PV #LV #SN Attr   VSize  VFree

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

[root@rhel6_lhr ~]# pvs

  PV         VG         Fmt  Attr PSize  PFree

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

[root@rhel6_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的所有进程

 

[root@rhel6_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

[root@rhel6_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.

[root@rhel6_lhr ~]# ps -ef|grep ora  

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

[root@rhel6_lhr ~]# ps -ef|grep d.bin

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

 


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


     本文转自lhrbest 51CTO博客,原文链接:

http://blog.51cto.com/lhrbest/1886686

,如需转载请自行联系原作者



 

相关文章
|
5天前
|
NoSQL Linux 测试技术
Redis的安装(Linux版)
Redis的安装(Linux版)
56 1
|
15天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
77 0
|
15天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
35 0
|
15天前
|
NoSQL Linux Redis
linux 下和win下安装redis 并添加开机自启 图文详解
linux 下和win下安装redis 并添加开机自启 图文详解
17 0
|
15天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
50 0
|
22天前
|
Linux
关于Linux目录访问函数总结
关于Linux目录访问函数总结
13 1
|
1天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
32 2
|
1天前
|
Linux 开发工具 Android开发
Docker系列(1)安装Linux系统编译Android源码
Docker系列(1)安装Linux系统编译Android源码
3 0
|
1天前
|
Ubuntu Linux 开发工具
WSL2(3)安装Linux headers完美解决方案
WSL2(3)安装Linux headers完美解决方案
3 0
|
2天前
|
Linux 开发工具 C语言
Linux 安装 gcc 编译运行 C程序
Linux 安装 gcc 编译运行 C程序
15 0