oracle表空间文件更换服务器,Linux服务器磁盘扩展和Oracle表空间文件迁移操作记录...

本文详细介绍了在Linux环境下,如何通过创建新的分区并挂载到现有系统,以解决Oracle数据库表空间因大量数据写入而快速增长的问题。通过fdisk命令创建新的扩展分区,并格式化后挂载到指定目录,最后更新fstab文件实现开机自动挂载,以扩充数据库存储空间。
摘要由CSDN通过智能技术生成

因为数据表每天有上百万的数据写入表,加上建立索引,导致表空间不停增长,表空间被设置为自动增长,因此dbf文件在不断增大,硬盘

1、环境介绍

服务器硬件:Dell R710

服务器OS:红帽子Linux RHEL4.8

数据库:Oracle 10g

2、出现的问题

因为数据表每天有上百万的数据写入表,加上建立索引,导致表空间不停增长,表空间被设置为自动增长,因此dbf文件在不断增大,硬盘空间在每天约400M的速度减少。数据库虽有自清理的脚本,清理3个月前的数据,但实际增加的数据太多,清理释放的空间不能满足需求了。

3、处理过程

解决思路是,该服务器的硬盘有预留空间,未完全划分的约有100G,可以建立新的分区,将已经存满的分区的数据库文件移动,来避免挂载点使用率达到100%,同时可以扩充表空间。

3.1 建立分区

以root账号登陆,查看目前使用情况:

[root@ccsvr ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda1 7.1G 3.2G 3.6G 48% /

/dev/sda3 44G 9.6G 32G 24% /AFC/Data

/dev/sda5 15G 3.9G 9.9G 29% /AFC/Log

/dev/sda2 63G 54G 5.8G 91% /AFC_DB

/dev/sdb1 56G 39G 15G 73% /AFC_DB2

none 4.0G 0 4.0G 0% /dev/shm

/dev/sda6 4.9G 3.3G 1.4G 72% /oracle

/dev/sdb2 56G 52G 529M 100% /AFC_DB3

其中 /dev/sdb2已经快接近用完了。

查看下分区情况:

[root@ccsvr ~]# fdisk -l

Disk /dev/sda: 146.1 GB, 146163105792 bytes

255 heads, 63 sectors/track, 17769 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 936 7518388+ 83 Linux

/dev/sda2 937 9222 66557295 83 Linux

/dev/sda3 9223 14959 46082452+ 83 Linux

/dev/sda4 14960 17769 22571325 5 Extended

/dev/sda5 14960 16871 15358108+ 83 Linux

/dev/sda6 16872 17508 5116671 83 Linux

/dev/sda7 17509 17769 2096451 82 Linux swap

Disk /dev/sdb: 299.4 GB, 299439751168 bytes

255 heads, 63 sectors/track, 36404 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 7296 58605088+ 83 Linux

/dev/sdb2 7297 14592 58605120 83 Linux

/dev/sdb3 14593 32829 146488702+ 5 Extended

/dev/sdb5 14593 21888 58605088+ 83 Linux

可以看到有两块硬盘,sda为第一块SCSI硬盘,sdb为第二块SCSI硬盘,其实服务器时四块硬盘,做的raid1。

其中,第一块硬盘,dell的标配146G,安装的操作系统,oracle数据库,已经分完了,三个主分区,三个扩展分区,/dev/sda2 (/AFC_DB)是开始建立的数据库文件存放目录。

第二块硬盘,是后来增加的300G,/dev/sdb1(/AFC_DB2),/dev/sdb2(/AFC_DB3)是两个主分区,作用也是来放数据库文件的,后面还有一个扩展分区/dev/sdb5,这个应该

也是后来加这块硬盘的人创建的,但是没有挂载上。

我的工作就是把/dev/sdb5挂载上,把硬盘还有的空间(32829~21888)的柱面建立成第二个扩展分区,/dev/sdb6。

[root@ccsvr ~]# fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 299.4 GB, 299439751168 bytes

255 heads, 63 sectors/track, 36404 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 7296 58605088+ 83 Linux

/dev/sdb2 7297 14592 58605120 83 Linux

/dev/sdb3 14593 32829 146488702+ 5 Extended

/dev/sdb5 14593 21888 58605088+ 83 Linux

/dev/sdb6 21889 32829 87883551 83 Linux

注:对第二块硬盘进行分区操作,p:查看分区情况;

Command (m for help): n

Command action

l logical (5 or over)

p primary partition (1-4)

l

First cylinder (21889-32829, default 21889):

Using default value 21889

Last cylinder or +size or +sizeM or +sizeK (21889-32829, default 32829):

Using default value 32829

注:n:创建新的分区,

接下来选择分区类型:l:逻辑分区,p主分区

l logical (5 or over),指创建逻辑分区,分区编号要大于5,因为已经存在db5了

p primary partition (1-4),指创建主分区,编号1—4,,linux规定主分区只能有四个。

我这里输入的l,创建逻辑分区。

First cylinder (21889-32829, default 21889):

Using default value 21889

注:这个就是填写分区的start柱面,这里直接打回车,使用默认值;

Last cylinder or +size or +sizeM or +sizeK (21889-32829, default 32829):

Using default value 32829

注:这里填写分区的end柱面,或者填写+??M,K的方式,linux会自动算出柱面号。我这里要把剩余的硬盘空间全都分到这个分区,所以使用默认值。

Command (m for help): p

Disk /dev/sdb: 299.4 GB, 299439751168 bytes

255 heads, 63 sectors/track, 36404 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 7296 58605088+ 83 Linux

/dev/sdb2 7297 14592 58605120 83 Linux

/dev/sdb3 14593 32829 146488702+ 5 Extended

/dev/sdb5 14593 21888 58605088+ 83 Linux

/dev/sdb6 21889 32829 87883551 83 Linux

再次查看下分区情况,发现/dev/sdb6/已经创建好了。

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.

Syncing disks.

执行W命令,写入分区表。

注意:以上操作中如果有误,可以随时撤销,但执行写入后,就不能更改了。

发现,写入后系统提示错误,资源正忙,新的分区表重启后有效。

于是,重启机器,注意重启前,关闭生产程序进程,和oracle数据:

$xxx/bin/xxx_stop

[root@ccsvr ~]# su - oracle

[oracle@ccsvr ~]$ sqlplus / as sysdba;

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

重启后,对/dev/sdb5,/dev/db6格式化:

[root@ccsvr /]# mkfs -t ext3 /dev/sdb6

mke2fs 1.35 (28-Feb-2004)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

10993664 inodes, 21970887 blocks

1098544 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=25165824

671 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

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

4096000, 7962624, 11239424, 20480000

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

然后,创建需要挂载的目录,将分区挂载:

[root@ccsvr /]# mkdir AFC_DB5

[root@ccsvr /]# mkdir AFC_DB6

[root@ccsvr /]# ll

total 216

drwxr-xr-x 6 afc aas 4096 Dec 2 2013 AAS

drwxrwxr-x 13 afc aas 4096 Dec 27 00:32 AFC

drwxr-xr-x 5 oracle oinstall 4096 Apr 14 2014 AFC_DB

drwxr-xr-x 6 oracle oinstall 4096 Apr 14 2014 AFC_DB2

drwxr-xr-x 4 oracle oinstall 4096 Apr 14 2014 AFC_DB3

drwxr-xr-x 2 root root 4096 May 17 21:18 AFC_DB5

drwxr-xr-x 2 root root 4096 May 17 21:18 AFC_DB6

这里有一步失误,目录AFC_DB5和AFC_DB6是用来存放oracle数据文件的,最好用oracle账号创建,

我已经用root账号创建了,就给它最高权限算了。

[root@ccsvr /]# chmod 777 AFC_DB5

[root@ccsvr /]# chmod 777 AFC_DB6

然后,进行挂载:

[root@ccsvr /]# mount /dev/sdb5 /AFC_DB5

[root@ccsvr /]# mount /dev/sdb6 /AFC_DB6

修改fstab文件,使开机启动时自动挂载,

这是原fstab文件:

[root@ccsvr /]# more /etc/fstab

# This file is edited by fstab-sync - see 'man fstab-sync' for details 本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉 本文系统来源:php中文网

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值