Linux下通过RAW建库

时间:2022-03-18 02:08:20

Linux rh4 通过raw设备建库

OS环境: RedHat EL4

DB 环境: Oracle 10.2.0


1、添加磁盘,建立逻辑卷

[root@RH4 ~]# fdisk -l

Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20482843+  83  Linux
/dev/sda2            2551        5100    20482875   83  Linux
/dev/sda3            5101        7012    15358140   83  Linux
/dev/sda4            7013       10443    27559507+   5  Extended
/dev/sda5            7013        7273     2096451   82  Linux swap
/dev/sda6            7274       10443    25462993+  83  Linux

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@RH4 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@RH4 ~]# partprobe
Warning: Unable to open /dev/hdc read-write (Read-only file system).  /dev/hdc has been opened read-only.
[root@RH4 ~]# fdisk -l

Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20482843+  83  Linux
/dev/sda2            2551        5100    20482875   83  Linux
/dev/sda3            5101        7012    15358140   83  Linux
/dev/sda4            7013       10443    27559507+   5  Extended
/dev/sda5            7013        7273     2096451   82  Linux swap
/dev/sda6            7274       10443    25462993+  83  Linux

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   8e  Linux LVM
[root@RH4 ~]#

[root@RH4 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

[root@RH4 ~]# vgcreate oravg /dev/sdb1
  Volume group "oravg" successfully created
[root@RH4 ~]#

[root@RH4 ~]# lvcreate -L 500m -n lv_system oravg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "lv_system" created
[root@RH4 ~]# lvcreate -L 300m -n lv_sysaux oravg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "lv_sysaux" created
[root@RH4 ~]# lvcreate -L 300m -n lv_rtbs1 oravg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "lv_rtbs1" created
[root@RH4 ~]# lvcreate -L 300m -n lv_users oravg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "lv_users" created
[root@RH4 ~]# lvcreate -L 300m -n lv_temp oravg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "lv_temp" created
[root@RH4 ~]# lvcreate -L 50m -n lv_redo01a oravg
  /dev/cdrom: open failed: Read-only file system
  Rounding up size to full physical extent 52.00 MB
  Logical volume "lv_redo01a" created
[root@RH4 ~]# lvcreate -L 50m -n lv_redo02a oravg
  /dev/cdrom: open failed: Read-only file system
  Rounding up size to full physical extent 52.00 MB
  Logical volume "lv_redo02a" created
[root@RH4 ~]# lvcreate -L 50m -n lv_redo03a oravg
  /dev/cdrom: open failed: Read-only file system
  Rounding up size to full physical extent 52.00 MB
  Logical volume "lv_redo03a" created
[root@RH4 ~]# lvcreate -L 10m -n lv_control01 oravg
  /dev/cdrom: open failed: Read-only file system
  Rounding up size to full physical extent 12.00 MB
  Logical volume "lv_control01" created
[root@RH4 ~]# lvcreate -L 10m -n lv_control02 oravg
  /dev/cdrom: open failed: Read-only file system
  Rounding up size to full physical extent 12.00 MB
  Logical volume "lv_control02" created

[root@RH4 permissions.d]# lvcreate -L 10m -n lv_spfile oravg
  /dev/cdrom: open failed: Read-only file system
  Rounding up size to full physical extent 12.00 MB
  Logical volume "lv_spfile" created
[root@RH4 ~]#

[root@RH4 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/oravg/lv_system
  VG Name                oravg
  LV UUID                1PTn8Z-Y1vp-HSxA-hLEU-JAen-hwTT-71AZAq
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                500.00 MB
  Current LE             125
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_sysaux
  VG Name                oravg
  LV UUID                ciP665-v2yE-vHl3-BwFd-X0LF-pDzJ-Las4Gy
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                300.00 MB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:1
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_rtbs1
  VG Name                oravg
  LV UUID                sjJTxZ-prGD-2m03-2SDI-nra3-okGP-PEKmCT
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                300.00 MB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:2
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_users
  VG Name                oravg
  LV UUID                v373lm-Gr2U-uR7x-TxeK-uf0w-poyg-0BLcr0
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                300.00 MB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:3
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_temp
  VG Name                oravg
  LV UUID                mOov32-uqIQ-xsTH-WNPG-Bx0F-3N6N-vgsVxl
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                300.00 MB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:4
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_redo01a
  VG Name                oravg
  LV UUID                bfsTFX-W4j7-UOOM-cNgw-mSbU-SFsT-qBiOib
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                52.00 MB
  Current LE             13
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:5
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_redo02a
  VG Name                oravg
  LV UUID                BtGin3-bwch-YsGr-ck2B-PPW4-15FK-3K0HHK
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                52.00 MB
  Current LE             13
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:6
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_redo03a
  VG Name                oravg
  LV UUID                TPqFsW-KhsC-wwAt-i1wQ-pBtB-b1zJ-h9flQM
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                52.00 MB
  Current LE             13
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:7
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_control01
  VG Name                oravg
  LV UUID                wTKTcN-QOM1-6Sk3-zds0-1h83-XXyf-f2m0kf
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                12.00 MB
  Current LE             3
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:8
  
  --- Logical volume ---
  LV Name                /dev/oravg/lv_control02
  VG Name                oravg
  LV UUID                c3gNpr-ME8t-lAlB-yIS3-raWW-GFEP-DcCfYC
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                12.00 MB
  Current LE             3
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:9
   --- Logical volume ---
  LV Name                /dev/oravg/lv_spfile
  VG Name                oravg
  LV UUID                PyUD4V-mGEA-W9OK-4Viz-xVSw-gNDF-o5RK29
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                12.00 MB
  Current LE             3
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:10


2、配置raw设备
  
[root@RH4 ~]#

[root@RH4 ~]# cd /dev/mapper/
[root@RH4 mapper]# ls -l
total 0
crw-------  1 root root  10, 63 Apr 21 05:04 control
brw-rw----  1 root disk 253,  8 Apr 21 05:12 oravg-lv_control01
brw-rw----  1 root disk 253,  9 Apr 21 05:12 oravg-lv_control02
brw-rw----  1 root disk 253,  5 Apr 21 05:11 oravg-lv_redo01a
brw-rw----  1 root disk 253,  6 Apr 21 05:11 oravg-lv_redo02a
brw-rw----  1 root disk 253,  7 Apr 21 05:11 oravg-lv_redo03a
brw-rw----  1 root disk 253,  2 Apr 21 05:10 oravg-lv_rtbs1
brw-rw----  1 root disk 253,  1 Apr 21 05:09 oravg-lv_sysaux
brw-rw----  1 root disk 253,  0 Apr 21 05:09 oravg-lv_system
brw-rw----  1 root disk 253,  4 Apr 21 05:10 oravg-lv_temp
brw-rw----  1 root disk 253,  3 Apr 21 05:10 oravg-lv_users
brw-rw----  1 root disk 253, 10 Apr 21 05:30 oravg-lv_spfile

[root@RH4 mapper]# vi /etc/sysconfig/rawdevices

# This file and interface are deprecated.
# Applications needing raw device access should open regular
# block devices with O_DIRECT.
# raw device bindings
# format:  <rawdev> <major> <minor>
#          <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
#          /dev/raw/raw2 8 5

/dev/raw/raw1      /dev/mapper/oravg-lv_system
/dev/raw/raw2      /dev/mapper/oravg-lv_sysaux
/dev/raw/raw3      /dev/mapper/oravg-lv_rtbs1
/dev/raw/raw4      /dev/mapper/oravg-lv_users
/dev/raw/raw5      /dev/mapper/oravg-lv_redo01a
/dev/raw/raw6      /dev/mapper/oravg-lv_redo02a
/dev/raw/raw7      /dev/mapper/oravg-lv_redo03a
/dev/raw/raw8      /dev/mapper/oravg-lv_control01
/dev/raw/raw9      /dev/mapper/oravg-lv_control02
/dev/raw/raw10     /dev/mapper/oravg-lv_temp
/dev/raw/raw11     /dev/mapper/oravg-lv_spfile

[root@RH4 mapper]# !ser
service rawdevices restart
Assigning devices:
           /dev/raw/raw1  -->   /dev/mapper/oravg-lv_system
/dev/raw/raw1:  bound to major 253, minor 0
           /dev/raw/raw2  -->   /dev/mapper/oravg-lv_sysaux
/dev/raw/raw2:  bound to major 253, minor 1
           /dev/raw/raw3  -->   /dev/mapper/oravg-lv_rtbs1
/dev/raw/raw3:  bound to major 253, minor 2
           /dev/raw/raw4  -->   /dev/mapper/oravg-lv_users
/dev/raw/raw4:  bound to major 253, minor 3
           /dev/raw/raw5  -->   /dev/mapper/oravg-lv_redo01a
/dev/raw/raw5:  bound to major 253, minor 5
           /dev/raw/raw6  -->   /dev/mapper/oravg-lv_redo02a
/dev/raw/raw6:  bound to major 253, minor 6
           /dev/raw/raw7  -->   /dev/mapper/oravg-lv_redo03a
/dev/raw/raw7:  bound to major 253, minor 7
           /dev/raw/raw8  -->   /dev/mapper/oravg-lv_control01
/dev/raw/raw8:  bound to major 253, minor 8
           /dev/raw/raw9  -->   /dev/mapper/oravg-lv_control02
/dev/raw/raw9:  bound to major 253, minor 9
 /dev/raw/raw10  -->   /dev/mapper/oravg-lv_temp
/dev/raw/raw10: bound to major 253, minor 4
/dev/raw/raw11  -->   /dev/mapper/oravg-lv_spfile
/dev/raw/raw11: bound to major 253, minor 10

done

[root@RH4 mapper]# ls -l /dev/raw/
total 0
crw-rw----  1 root disk 162, 1 Apr 21 05:20 raw1
crw-rw----  1 root disk 162, 10 Apr 21 05:26 raw10
crw-rw----  1 root disk 162, 11 Apr 21 05:33 raw11
crw-rw----  1 root disk 162, 2 Apr 21 05:20 raw2
crw-rw----  1 root disk 162, 3 Apr 21 05:20 raw3
crw-rw----  1 root disk 162, 4 Apr 21 05:20 raw4
crw-rw----  1 root disk 162, 5 Apr 21 05:20 raw5
crw-rw----  1 root disk 162, 6 Apr 21 05:20 raw6
crw-rw----  1 root disk 162, 7 Apr 21 05:20 raw7
crw-rw----  1 root disk 162, 8 Apr 21 05:20 raw8
crw-rw----  1 root disk 162, 9 Apr 21 05:20 raw9
[root@RH4 mapper]# cd /etc/udev/permissions.d/

[root@RH4 permissions.d]# vi 50-udev.permissions

# raw devices
ram*:root:disk:0660
raw/*:oracle:oinstall:0660
~

[root@RH4 permissions.d]# service rawdevices restart
Assigning devices:
           /dev/raw/raw1  -->   /dev/mapper/oravg-lv_system
/dev/raw/raw1:  bound to major 253, minor 0
           /dev/raw/raw2  -->   /dev/mapper/oravg-lv_sysaux
/dev/raw/raw2:  bound to major 253, minor 1
           /dev/raw/raw3  -->   /dev/mapper/oravg-lv_rtbs1
/dev/raw/raw3:  bound to major 253, minor 2
           /dev/raw/raw4  -->   /dev/mapper/oravg-lv_users
/dev/raw/raw4:  bound to major 253, minor 3
           /dev/raw/raw5  -->   /dev/mapper/oravg-lv_redo01a
/dev/raw/raw5:  bound to major 253, minor 5
           /dev/raw/raw6  -->   /dev/mapper/oravg-lv_redo02a
/dev/raw/raw6:  bound to major 253, minor 6
           /dev/raw/raw7  -->   /dev/mapper/oravg-lv_redo03a
/dev/raw/raw7:  bound to major 253, minor 7
           /dev/raw/raw8  -->   /dev/mapper/oravg-lv_control01
/dev/raw/raw8:  bound to major 253, minor 8
           /dev/raw/raw9  -->   /dev/mapper/oravg-lv_control02
/dev/raw/raw9:  bound to major 253, minor 9
 /dev/raw/raw10  -->   /dev/mapper/oravg-lv_temp
/dev/raw/raw10: bound to major 253, minor 4
/dev/raw/raw11  -->   /dev/mapper/oravg-lv_spfile
/dev/raw/raw11: bound to major 253, minor 10
done
[root@RH4 permissions.d]# ls -l /dev/raw
total 0
crw-rw----  1 oracle oinstall 162, 1 Apr 21 05:22 raw1
crw-rw----  1 oracle oinstall 162, 10 Apr 21 05:26 raw10
crw-rw----  1 oracle oinstall 162, 11 Apr 21 05:33 raw11
crw-rw----  1 oracle oinstall 162, 2 Apr 21 05:22 raw2
crw-rw----  1 oracle oinstall 162, 3 Apr 21 05:22 raw3
crw-rw----  1 oracle oinstall 162, 4 Apr 21 05:22 raw4
crw-rw----  1 oracle oinstall 162, 5 Apr 21 05:22 raw5
crw-rw----  1 oracle oinstall 162, 6 Apr 21 05:22 raw6
crw-rw----  1 oracle oinstall 162, 7 Apr 21 05:22 raw7
crw-rw----  1 oracle oinstall 162, 8 Apr 21 05:22 raw8
crw-rw----  1 oracle oinstall 162, 9 Apr 21 05:22 raw9

3、建立数据文件的符号链接

[root@RH4 permissions.d]#

[root@RH4 permissions.d]# ln -s /dev/raw/raw1 /disk1/oradata/test/system01.dbf
[root@RH4 permissions.d]# ln -s /dev/raw/raw2 /disk1/oradata/test/sysaux01.dbf
[root@RH4 permissions.d]# ln -s /dev/raw/raw3 /disk1/oradata/test/rtbs01.dbf
[root@RH4 permissions.d]# ln -s /dev/raw/raw4 /disk1/oradata/test/users01.dbf

[root@RH4 permissions.d]# ln -s /dev/raw/raw5   /disk1/oradata/test/redo01a.log
[root@RH4 permissions.d]# ln -s /dev/raw/raw6   /disk1/oradata/test/redo02a.log
[root@RH4 permissions.d]# ln -s /dev/raw/raw7   /disk1/oradata/test/redo03a.log
[root@RH4 permissions.d]# ln -s /dev/raw/raw8   /disk1/oradata/test/control01.ctl
[root@RH4 permissions.d]# ln -s /dev/raw/raw9   /disk1/oradata/test/control02.ctl
[root@RH4 permissions.d]# ln -s /dev/raw/raw10   /disk1/oradata/test/temp01.dbf

[root@RH4 permissions.d]# ln -s /dev/raw/raw11  /u01/app/oracle/product/10.2.0/db_1/dbs/spfiletest.ora
[root@RH4 permissions.d]#

4、建立数据库文件的存放目录

[root@RH4 ~]# ls -ld /disk1/oradata/test
drwxr-xr-x  2 root root 4096 Apr 21 05:43 /disk1/oradata/test
[root@RH4 ~]# ls -ld /disk1/oradata/
drwxr-xr-x  6 oracle oinstall 4096 Apr 21 05:23 /disk1/oradata/
[root@RH4 ~]# chown -R oracle:oinstall /disk1/oradata/test
[root@RH4 ~]# ls -ld /disk1/oradata/test
drwxr-xr-x  2 oracle oinstall 4096 Apr 21 05:43 /disk1/oradata/test
[root@RH4 ~]#

5、在oracle home 下建立raw 配置文件

[oracle@RH4 ~]$ cat dbca.conf
spfile  /u01/app/oracle/product/10.2.0/db_1/dbs/spfiletest.ora
system  /disk1/oradata/test/system01.dbf
sysaux  /disk1/oradata/test/sysaux01.dbf
undotbs1    /disk1/oradata/test/rtbs01.dbf
example   /disk1/oradata/test/users01.dbf
redo1_1   /disk1/oradata/test/redo01a.log
redo1_2   /disk1/oradata/test/redo02a.log
redo1_3   /disk1/oradata/test/redo03a.log
control01 /disk1/oradata/test/control01.ctl
contorl02  /disk1/oradata/test/control02.ctl
temp       /disk1/oradata/test/temp01.dbf

6、通过dbca 建库,选择raw 设备,然后选择raw的配置文件(dbca.conf)

------其中提示缺少:

‘redo1_1,redo1_2 ,redo文件必须以此命名',并需要undotbs1、users、example表空间,controlfile 文件命名contorl1、control2,spfile必须用绝对路径,不能用变量

----按照提示再增加raw 设备


[root@RH4 ~]# lvcreate -L 300m -n lv_example oravg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "lv_example" created
[root@RH4 ~]#

[root@RH4 ~]# vi /etc/sysconfig/rawdevices

/dev/raw/raw12     /dev/mapper/oravg-lv_example
~

[root@RH4 ~]# ln -s /dev/raw/raw12 /disk1/oradata/test/example01.dbf

[root@RH4 ~]# vi /etc/sysconfig/rawdevices

/dev/raw/raw13     /dev/mapper/oravg-lv_control03

[root@RH4 ~]# ln -s /dev/raw/raw13 /disk1/oradata/test/control03.ctl

[oracle@RH4 ~]$ cat dbca.conf
spfile  /u01/app/oracle/product/10.2.0/db_1/dbs/spfiletest.ora
system  /disk1/oradata/test/system01.dbf
sysaux  /disk1/oradata/test/sysaux01.dbf
undotbs1    /disk1/oradata/test/rtbs01.dbf
users   /disk1/oradata/test/users01.dbf
redo1_1   /disk1/oradata/test/redo01a.log
redo1_2   /disk1/oradata/test/redo02a.log
redo1_3   /disk1/oradata/test/redo03a.log
control1 /disk1/oradata/test/control01.ctl
contorl2  /disk1/oradata/test/control02.ctl
contorl3  /disk1/oradata/test/control03.ctl
temp       /disk1/oradata/test/temp01.dbf
example   /disk1/oradata/test/example01.dbf


----------经过以上修改后,dbca 建库成功


验证:

[oracle@RH4 ~]$ export ORACLE_SID=test
[oracle@RH4 ~]$ !sql
sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Apr 21 06:33:24 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

06:33:24 SQL> select name from v$datafile;

NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/disk1/oradata/test/system01.dbf
/disk1/oradata/test/rtbs01.dbf
/disk1/oradata/test/sysaux01.dbf
/disk1/oradata/test/users01.dbf
/disk1/oradata/test/example01.dbf

06:33:33 SQL> col file_name for a50
06:33:44 SQL> select file_id,file_name,tablespace_name from dba_data_files;

   FILE_ID FILE_NAME                                          TABLESPACE_NAME
---------- -------------------------------------------------- ------------------------------
         4 /disk1/oradata/test/users01.dbf                    USERS
         3 /disk1/oradata/test/sysaux01.dbf                   SYSAUX
         2 /disk1/oradata/test/rtbs01.dbf                     UNDOTBS1
         1 /disk1/oradata/test/system01.dbf                   SYSTEM
         5 /disk1/oradata/test/example01.dbf                  EXAMPLE

06:34:03 SQL> select file_id,file_name,tablespace_name,bytes/1024/1024  from dba_data_files;

   FILE_ID FILE_NAME                                          TABLESPACE_NAME                BYTES/1024/1024
---------- -------------------------------------------------- ------------------------------ ---------------
         4 /disk1/oradata/test/users01.dbf                    USERS                                        5
         3 /disk1/oradata/test/sysaux01.dbf                   SYSAUX                                     230
         2 /disk1/oradata/test/rtbs01.dbf                     UNDOTBS1                                    25
         1 /disk1/oradata/test/system01.dbf                   SYSTEM                                     480
         5 /disk1/oradata/test/example01.dbf                  EXAMPLE                                    100

06:34:19 SQL> alter database datafile 4 resize 100m;

Database altered.

06:35:00 SQL> select file_id,file_name,tablespace_name,bytes/1024/1024  from dba_data_files;

   FILE_ID FILE_NAME                                          TABLESPACE_NAME                BYTES/1024/1024
---------- -------------------------------------------------- ------------------------------ ---------------
         4 /disk1/oradata/test/users01.dbf                    USERS                                      100
         3 /disk1/oradata/test/sysaux01.dbf                   SYSAUX                                     230
         2 /disk1/oradata/test/rtbs01.dbf                     UNDOTBS1                                    25
         1 /disk1/oradata/test/system01.dbf                   SYSTEM                                     480
         5 /disk1/oradata/test/example01.dbf                  EXAMPLE                                    100

06:35:24 SQL> col member for a50
06:35:38 SQL> select group#,member from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         3 /disk1/oradata/test/redo03a.log
         2 /disk1/oradata/test/redo02a.log
         1 /disk1/oradata/test/redo01a.log

06:35:49 SQL> select name from v$controlfile;

NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/disk1/oradata/test/control01.ctl
/disk1/oradata/test/control02.ctl

06:36:04 SQL>

06:36:04 SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/10.2.0
                                                 /db_1/dbs/spfiletest.ora
06:36:35 SQL>


06:36:35 SQL> select file_id,file_name,tablespace_name,bytes/1024/1024  from dba_temp_files;

   FILE_ID FILE_NAME                                          TABLESPACE_NAME                BYTES/1024/1024
---------- -------------------------------------------------- ------------------------------ ---------------
         1 /disk1/oradata/test/temp01.dbf                     TEMP                                        20


------新增加表空间

[root@RH4 ~]# lvcreate -L 300m -n lv_temp2 oravg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "lv_temp2" created

[root@RH4 ~]# vi /etc/sysconfig/rawdevices

/dev/raw/raw14     /dev/mapper/oravg-lv_temp2

[root@RH4 ~]# raw /dev/raw/raw14     /dev/mapper/oravg-lv_temp2
/dev/raw/raw14: bound to major 253, minor 13
[root@RH4 ~]# ln -s /dev/raw/raw14 /disk1/oradata/test/temp02.dbf
[root@RH4 ~]# su - oracle
[oracle@RH4 ~]$ vi dbca.conf
temp2   /disk1/oradata/test/temp02.dbf

06:37:24 SQL> create temporary tablespace temp2
06:41:50   2    tempfile '/disk1/oradata/test/temp02.dbf' size 100m;

Tablespace created.

06:42:14 SQL> select file_id,file_name,tablespace_name,bytes/1024/1024  from dba_temp_files;

   FILE_ID FILE_NAME                                          TABLESPACE_NAME                BYTES/1024/1024
---------- -------------------------------------------------- ------------------------------ ---------------
         1 /disk1/oradata/test/temp01.dbf                     TEMP                                        20
         2 /disk1/oradata/test/temp02.dbf                     TEMP2                                      100

06:42:24 SQL>

 

 

本文出自 “天涯客的blog” 博客,请务必保留此出处http://tiany.blog.51cto.com/513694/842340