【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/1886685,如需转载请自行联系原作者



相关文章
|
13天前
|
监控 Oracle 关系型数据库
Linux平台Oracle开机自启动设置
【11月更文挑战第8天】在 Linux 平台设置 Oracle 开机自启动有多种方法,本文以 CentOS 为例,介绍了两种常见方法:使用 `rc.local` 文件(较简单但不推荐用于生产环境)和使用 `systemd` 服务(推荐)。具体步骤包括编写启动脚本、赋予执行权限、配置 `rc.local` 或创建 `systemd` 服务单元文件,并设置开机自启动。通过 `systemd` 方式可以更好地与系统启动过程集成,更规范和可靠。
|
9天前
|
Oracle Cloud Native 关系型数据库
Oracle Linux 9.5 正式版发布 - Oracle 提供支持 RHEL 兼容发行版
Oracle Linux 9.5 正式版发布 - Oracle 提供支持 RHEL 兼容发行版
47 10
Oracle Linux 9.5 正式版发布 - Oracle 提供支持 RHEL 兼容发行版
|
14天前
|
Oracle Ubuntu 关系型数据库
Linux平台Oracle开机自启动设置
【11月更文挑战第7天】本文介绍了 Linux 系统中服务管理机制,并详细说明了如何在使用 systemd 和 System V 的系统上设置 Oracle 数据库的开机自启动。包括创建服务单元文件、编辑启动脚本、设置开机自启动和启动服务的具体步骤。最后建议重启系统验证设置是否成功。
|
1月前
|
存储 Oracle 关系型数据库
|
6月前
|
运维 Oracle 容灾
Oracle dataguard 容灾技术实战(笔记),教你一种更清晰的Linux运维架构
Oracle dataguard 容灾技术实战(笔记),教你一种更清晰的Linux运维架构
|
4月前
|
Oracle 关系型数据库 Linux
讲解linux下的Qt如何编译oracle的驱动库libqsqloci.so
通过这一连串的步骤,可以专业且有效地在Linux下为Qt编译Oracle驱动库 `libqsqloci.so`,使得Qt应用能够通过OCI与Oracle数据库进行交互。这些步骤适用于具备一定Linux和Qt经验的开发者,并且能够为需要使用Qt开发数据库应用的专业人士提供指导。
150 1
讲解linux下的Qt如何编译oracle的驱动库libqsqloci.so
|
5月前
|
SQL Oracle 关系型数据库
探索 Linux 命令 `db_archive`:Oracle 数据库归档日志的工具
探索 Linux 中的 `db_archive`,实际与 Oracle 数据库归档日志管理相关。在 Oracle 中,归档日志用于恢复,当在线重做日志满时自动归档。管理员可使用 SQL*Plus 查看归档模式,通过 `RMAN` 进行备份和恢复操作。管理归档日志需谨慎,避免数据丢失。了解归档管理对 Oracle 管理员至关重要,确保故障时能快速恢复数据库。
|
6月前
|
Oracle 关系型数据库 Linux
Oracle Linux: How To Disable NUMA At OS Level (Doc ID 2193586.1)
Oracle Linux: How To Disable NUMA At OS Level (Doc ID 2193586.1)
68 1
|
6月前
|
Oracle Java 关系型数据库
【服务器】python通过JDBC连接到位于Linux远程服务器上的Oracle数据库
【服务器】python通过JDBC连接到位于Linux远程服务器上的Oracle数据库
80 6
|
6月前
|
Oracle 关系型数据库 Linux
SuSE linux server 11通过SAP来安装oracle11g
SuSE linux server 11通过SAP来安装oracle11g
102 0
下一篇
无影云桌面