首页 > 范文大全 > 正文

在大型ERP系统中Oracle表空间规划

开篇:润墨网以专业的文秘视角,为您筛选了一篇在大型ERP系统中Oracle表空间规划范文,如需获取更多写作素材,在线客服老师一对一协助。欢迎您的阅读与分享!

摘要:在大型erp系统中,如果数据库为oracle,应对表空间作一个有效的规划,以免系统在运行之时,出现数据库不协调及运行效率低的问题;建立一些大的数据表空间,包括数据表空间、索引表空间、回滚表空间和临时表空间,同时根据Erp系统的访问量,确定要建立多少个回滚段。同时,表空间应该尽量建立在不同的物理磁盘上,以减少用户之间的I/O竞争。

关键词:Erp;Oracle ;表空间规划

中图分类号:TP3文献标识码:A 文章编号:1009-3044(2008)16-21182-04

In Large-scale ERP System Oracle Table Space Plan

LI Jing-yu1,ZHANG Xiao2

(1. Xinwen mining industry group central hospital,Xintai 271233, China;2. Xinwen mining industry group information center, Xintai 271233, China)

Abstract:In large-scale ERP system, if the database is Oracle, we should make an effective plan, in order to avoid the database’s uncoordinating or lower operating efficiency during the course of working. Establish some big data sheet spaces including the data sheet space, the index table space, returns rolls table space and temporary data space. Simultaneously according to the visiting quantity of ERP system, determine how many returns rolls section to be established. At the same time, dataspace is supposed to be established as far as possible on different physical disk to reduse the I/O competition between users.

Key words:Erp; Oracle; Effective plan of data space

1 引言

在大型的ERP系统中,如果数据库为oracle,应对表空间作一个有效的规划,以免系统在运行之时,出现数据库不协调及运行效率低的问题。因为Oracle安装之后,会自动生成一些表空间及回滚段,对于一套大型的Erp系统来讲,Oracle自身的设置肯定是不能满足的,所以要对逻辑结构和物理结构作一个有效的对应规划。

2 应用环境

操作系统:Windowns2000 Server

数据库系统:Oracle8.1.7(安装目录:C:\Oracle)

硬盘:5块SCSI硬盘(分C、D、E、F、G五个盘符)

应用系统:大型ERP系统(集团级物流系统)

3 规划方案

建立一些大的数据表空间,包括数据表空间、索引表空间、回滚表空间和临时表空间,同时根据Erp系统的访问量,确定要建立多少个回滚段。同时,表空间应该尽量建立在不同的物理磁盘上,以减少用户之间的I/O竞争。根据应用系统对Oracle数据存放及访问的流量,制定以下规划方案:

* C盘:操作系统windows 2000、Oralce系统。

* D盘:用户表空间1(6G、自动扩展)回滚表空间1(2G、自动扩展)

* E盘:用户表空间2(6G、自动扩展)回滚表空间2(2G、自动扩展)

* F盘:索引表空间1(2G、自动扩展) 临时表空间1(0.5G、不自动扩展)

* G盘:索引表空间2(2G、自动扩展)临时表空间2(0.5G、不自动扩展)

注:Erp系统为B/S结构,安装另一台应用服务器

4 实现过程

4.1 查看系统有哪些回滚段、存放在哪些表空间上

C:\>sqlplus internal/oracle

SQL>col owner format a10

SQL>col segment_name format a20

SQL>col tablespace_name format a20

SQL>select owner,segment_name,tablespace_name,

Sum(bytes)/1024/1024 M

from dba_segments where

segment_type=’rollback’ group by

owner,segment_name,tablespace_name;

相应回滚段列表被检索出来

OWNERSEGMENT_NAME TABLESPACE_NAME M

---------- -------------------- -------------------- ----------

SYSRBS0 RBS 4

SYSRBS1 RBS 4

SYSRBS2 RBS 4

SYSRBS3 RBS 4

SYSRBS4 RBS 4

SYSRBS5 RBS 4

SYSRBS6 RBS 4

SYSSYSTEM SYSTEM.390625

已选择8行。

4.2查看回滚段的状态

SQL>select segment_id,segment_name,

tablespace_name,owner,filed_id,status

from dba_rollback_segs;

如下列表:

SEGMENT_ID SEGMENT_NA TABLESPACE OWNER FILE_ID STATUS

---------- ---------- ---------- ---------- ---------- ----------

########## SYSTEM SYSTEM SYS########## ONLINE

########## RBS0 RBSPUBLIC ########## ONLINE

########## RBS1 RBSPUBLIC ########## ONLINE

########## RBS2 RBSPUBLIC ########## ONLINE

########## RBS3 RBSPUBLIC ########## ONLINE

########## RBS4 RBSPUBLIC ########## ONLINE

########## RBS5 RBSPUBLIC ########## ONLINE

########## RBS6 RBSPUBLIC ########## ONLINE

已选择8行。

4.3 由此可以看出,Oracle系统自身的回滚空间是很小的,需要修改以扩大。

4.3.1 现在作如下修改,使原有回滚段下线:

alter rollback segment rbs0 offline;

alter rollback segment rbs1 offline;

alter rollback segment rbs2 offline;

alter rollback segment rbs3 offline;

alter rollback segment rbs4 offline;

alter rollback segment rbs5 offline;

alter rollback segment rbs6 offline;

4.3.2 删除原有回滚段,以便重新建立:

drop rollback segment rbs0;

drop rollback segment rbs1;

drop rollback segment rbs2;

drop rollback segment rbs3;

drop rollback segment rbs4;

drop rollback segment rbs5;

drop rollback segment rbs6;

4.3.3建立数据表空间(在各个硬盘上预先手工建好Oradata目录);

4.3.3.1 创建用户表空间1

create tablespace user1 logging datafile

‘d:\oradata\user1_1.ora’size 1024M,

‘d:\oradata\user1_2.ora’size 1024M,

‘d:\oradata\user1_3.ora’size 1024M,

‘d:\oradata\user1_4.ora’size 1024M,

‘d:\oradata\user1_5.ora’size 1024M,

‘d:\oradata\user1_6.ora’size 1024M

autoexntend on next 5M maxsize unlimited

default storage(initial 128k next 2M pctincrease 0);

4.3.3.2 创建回滚表空间1

create tablespace roll1 logging datafile

‘d:\oradata\roll1_1.ora’size 1024M,

‘d:\oradata\roll1_2.ora’size 1024M

autoextend on next 5M maxsize unlimited

default storage(initial 40M next 5M pctincrease 0);

4.3.3.3 创建用户表空间2

create tablespace user2 logging datafile

‘e:\oradata\user2_1.ora’szie 1024M,

‘e:\oradata\user2_2.ora’szie 1024M,

‘e:\oradata\user2_2.ora’szie 1024M,

‘e:\oradata\user2_2.ora’szie 1024M,

‘e:\oradata\user2_2.ora’szie 1024M,

‘e:\oradata\user2_2.ora’szie 1024M

autoextend on next 5M maxsize unlimited

default storage(initial 128k next 2M pctincrease 0);

4.3.3.4 创建回滚表空间2

create tablespace roll2 logging datafile

‘e:\oradata\roll2_1.ora’size 1024M,

‘e:\oradata\roll2_2.ora’size 1024M

autoextend on next 5M maxsize unlimited

default storage(initial 40M next 5M pctincrease 0);

4.3.3.5 创建索引表空间1

create tablespace index1 logging datafile

‘f:\oradata\oradb\index1_1.ora’ size 512M,

‘f:\oradata\oradb\index1_2.ora’ size 512M,

‘f:\oradata\oradb\index1_3.ora’ size 512M,

‘f:\oradata\oradb\index1_4.ora’ size 512M

autoextend on next 5M maxsize unlimited

default storage(initial 128K next 5M pctincrease 0);

4.3.3.6 创建临时表空间1

create tablespace temp1 logging datafile

‘f:\oradata\oradb\temp1_1.ora’ size 512M

default storage(initial 10M next 3M pctincrease 0)

temporary;

4.3.3.7 创建索引表空间2

create tablespace index1 logging datafile

‘g:\oradata\oradb\index2_1.ora’ size 512M,

‘g:\oradata\oradb\index2_2.ora’ size 512M,

‘g:\oradata\oradb\index2_3.ora’ size 512M,

‘g:\oradata\oradb\index2_4.ora’ size 512M

autoextend on next 5M maxsize unlimited

default storage(initial 128K next 5M pctincrease 0);

4.3.3.8 创建临时表空间2

create tablespace temp2 logging datafile

‘g:\oradata\oradb\temp2_1.ora’ size 512M

default storage(initial 10M next 3M pctincrease 0)

temporary;

4.3.3.9 在两个回滚表空间中,分别创建回滚段,并使其上线

create public rollback segment rbs0 tablespace roll1;

create public rollback segment rbs1 tablespace roll1;

……

create public rollback segment rbs6 tablespace roll2;

create public rollback segment rbs7 tablespace roll2;

……

alter rollback segment rbs0 online;

alter rollback segment rbs1 online;

……

alter rollback segment rbs6 online;

alter rollback segment rbs7 online;

……

4.3.4 根据相应I/O访问量,相应把数据表分到不同表空间,平衡对每个硬盘的读写,有两种方法:

4.3.4.1 把某个用户全部表设置为默认表空间和临时表空间

alter user wzgl default tablespace user1;

alter user wzgl temporary tablespace temp1;

4.3.4.2 把某个表移动相应的表空间

Alter table wzglrkd move tablespace user2;

4.4 创建和使用分区的表

在ORACLE里如果遇到特别大的表,如物资管理中定单表,每天都有大量的记录,我们可以使用分区的表来改变其应用程序的性能。

以system身份登陆数据库,查看 v$option视图,如果其中Partition为TRUE,则支持分区功能;否则不支持。Partition有基于范围、哈希、综和三种类型。我们用的比较多的是按范围分区的表。

我们以一个2007年物资定单做例子讲述分区表的创建和使用:

4.4.1 以system 身份创建独立的表空间(大小可以根据数据量的多少而定)

create tablespace wzdd_200703 datafile‘e:\oradata\wzdd_3.ora ‘ size 50M default storage (initial 100k next 100k minextents 1 maxextents unlimited pctincrease 1);

create tablespace wzdd_200703 datafile ‘e:\oradata\wzdd_2.ora ‘ size 50M default storage (initial 100k next 100k minextents 1 maxextents unlimited pctincrease 1);

create tablespace wzdd_200701 datafile ‘e:\oradata\wzdd_1.ora ‘ size 50M default storage (initial 100k next 100k minextents 1 maxextents unlimited pctincrease 1);

4.4.2 用EXPORT工具把旧数据备份在wzgl.dmp中

把原来的wzdd表改名

alter table wzdd rename to wzddold;

以wzgl用户身份创建分区的表

create table wzdd(

id number(16) primary key,

wzdmvarchar2(30),

ddbhvarchar2(20),

cjxx varchar2(256),

……

dddate date,

……

)

partition by range (dddate)

(partition wzdd_200701 values less than (to_date('2001-01-01','yyyy-mm-dd'))

tablespace wzdd_200701

storage(initial 100k next 100k minextents 1 maxextents unlimited pctincrease 0),

partition wzdd_200702 values less than (to_date('2001-04-01','yyyy-mm-dd'))

tablespace wzdd_200702

storage(initial 100k next 100k minextents 1 maxextents unlimited pctincrease 0),

partition wzdd_200703 values less than (to_date('2001-07-01','yyyy-mm-dd'))

tablespace wzdd_200703

storage(initial 100k next 100k minextents 1 maxextents unlimited pctincrease 0)

)

);

(说明:这里是每个季度做一个分区,当然也可以每个月做一个分区)

4.4.3 IMPORT导入数据,参数ignore=y

4.4.3.1 分区表的扩容

到了2007 年下半年,建立新的表空间:

Create tablespace wzdd_200704 datafile ‘e:\oradata\wzdd_4.ora’ size 50M default storage (initial 100k next 100k minextents 1 maxextents unlimited pctincrease 1);

为表添加新分区和表空间:

alter table wzdd add partition wzdd_200704

values less than (to_date('2007-10-01','yyyy-mm-dd')

tablespace wzdd_200704

storage(initial 100k next 100k minextents 1 maxextents unlimited pctincrease 0);

4.4.3.2 删除不必要的分区

(1)如果不再需要2000年订单信息,将2000年的数据备份,将2000年的分区删除。

alter table wzdd drop partion wzdd_200001;

alter table wzdd drop partion wzdd_200002;

alter table wzdd drop partion wzdd_200003;

alter table wzdd drop partion wzdd_200004;

(2)删除物理文件。

Dele:/oradata/oradata/test/ wzdd_200001.dbf

Dele:/oradata/oradata/test/ wzdd_200002.dbf

Dele:/oradata/oradata/test/ wzdd_200003.dbf

Dele:/oradata/oradata/test/ wzdd_200004.dbf

5 总结

经过表空间规划,这套Erp系统已经运行三年,速度效率依然很高,由此可见有效的进行数据库管理,是应用系统高可靠运行保障。

参考文献:

[1] 吴京慧,杜宾,杨波. Oracle数据库管理及应用开发教程[M].清华大学出版社,2007.

[2] 张蒲生,Oracle9i数据库应用技术[M].中国水利水电出版社,2004.

[3] 赵伯山.Oracle9i中文版实用培训教程[M].清华大学出版社,2002.

[4] 谭先锋,一个基于.NET架构的信用信息交换支撑平台[J].电脑知识与技术,2007,17:1185-1186.

注:本文中所涉及到的图表、注解、公式等内容请以PDF格式阅读原文。