在Linux上创建ASM存储分区
本文描述了在Linux 服务器上创建分区、建立oracle ASM存储和创建数据库实例的过程。
查看当前分区:
[root@erpdevdb ~]# fdisk -l
Disk /dev/sda: 1048.5 GB, 1048576000000 bytes
255 heads, 63 sectors/track, 127482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 2676 20972857+ 8e Linux LVM
/dev/sda3 2677 5287 20972857+ 8e Linux LVM
/dev/sda4 5288 127482 981531337+ 5 Extended
/dev/sda5 5288 7898 20972826 8e Linux LVM
/dev/sda6 7899 20400 100422283+ 8e Linux LVM
/dev/sda7 20401 32850 100004593+ 8e Linux LVM
/dev/sda8 32851 57750 200009218+ 8e Linux LVMDisk /dev/sdb: 1198.8 GB, 1198899855360 bytes
255 heads, 63 sectors/track, 145757 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sdb1 1 37349 300005811 83 Linux
/dev/sdb2 37350 74698 300005842+ 83 Linux
/dev/sdb3 74699 136946 500007060 83 Linux
在/dev/sda设备上创建一个新的分区:
[root@erpdevdb ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 127482.
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)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): p
Disk /dev/sda: 1048.5 GB, 1048576000000 bytes
255 heads, 63 sectors/track, 127482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 2676 20972857+ 8e Linux LVM
/dev/sda3 2677 5287 20972857+ 8e Linux LVM
/dev/sda4 5288 127482 981531337+ 5 Extended
/dev/sda5 5288 7898 20972826 8e Linux LVM
/dev/sda6 7899 20400 100422283+ 8e Linux LVM
/dev/sda7 20401 32850 100004593+ 8e Linux LVM
/dev/sda8 32851 57750 200009218+ 8e Linux LVMCommand (m for help): n
First cylinder (57751-127482, default 57751):
Using default value 57751
Last cylinder or +size or +sizeM or +sizeK (57751-127482, default 127482): +300000MCommand (m for help): p
Disk /dev/sda: 1048.5 GB, 1048576000000 bytes
255 heads, 63 sectors/track, 127482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 2676 20972857+ 8e Linux LVM
/dev/sda3 2677 5287 20972857+ 8e Linux LVM
/dev/sda4 5288 127482 981531337+ 5 Extended
/dev/sda5 5288 7898 20972826 8e Linux LVM
/dev/sda6 7899 20400 100422283+ 8e Linux LVM
/dev/sda7 20401 32850 100004593+ 8e Linux LVM
/dev/sda8 32851 57750 200009218+ 8e Linux LVM
/dev/sda9 57751 94224 292977373+ 83 LinuxCommand (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.
[root@erpdevdb ~]#
这时能看到新的分区:
[root@erpdevdb ~]# fdisk -l
Disk /dev/sda: 1048.5 GB, 1048576000000 bytes
255 heads, 63 sectors/track, 127482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 2676 20972857+ 8e Linux LVM
/dev/sda3 2677 5287 20972857+ 8e Linux LVM
/dev/sda4 5288 127482 981531337+ 5 Extended
/dev/sda5 5288 7898 20972826 8e Linux LVM
/dev/sda6 7899 20400 100422283+ 8e Linux LVM
/dev/sda7 20401 32850 100004593+ 8e Linux LVM
/dev/sda8 32851 57750 200009218+ 8e Linux LVM
/dev/sda9 57751 94224 292977373+ 83 Linux
/dev/sda10 94225 127482 267144853+ 83 LinuxDisk /dev/sdb: 1198.8 GB, 1198899855360 bytes
255 heads, 63 sectors/track, 145757 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sdb1 1 37349 300005811 83 Linux
/dev/sdb2 37350 74698 300005842+ 83 Linux
/dev/sdb3 74699 136946 500007060 83 Linux
/dev/sdb4 136947 145757 70774357+ 83 Linux
查看当前的ASM磁盘组:
[root@erpdevdb ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
这时创建新的ASM磁盘组会报错,正如前面创建分区保存时提示的,需要重启后才生效。
[root@erpdevdb ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sda9
Marking disk "VOL4" as an ASM disk: [FAILED]
关闭已有的oracle 实例和ASM实例:
[oracle@erpdevdb ~]$ export ORACLE_SID=devdb
[oracle@erpdevdb ~]$ sqlplus " / as sysdba"SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 25 12:52:48 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining optionsSQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options[oracle@erpdevdb ~]$ export ORACLE_SID=+ASM
[oracle@erpdevdb ~]$ sqlplus " / as sysdba"SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 25 12:57:24 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining optionsSQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
关闭listener :
[oracle@erpdevdb ~]$ lsnrctl
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 25-FEB-2010 12:58:32
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> stat
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 29-NOV-2009 13:13:31
Uptime 87 days 23 hr. 45 min. 5 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=erpdevdb.chinacnd.com)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully
LSNRCTL> exit
重启服务器:
[root@erpdevdb ~]# reboot
Broadcast message from root (pts/1) (Thu Feb 25 12:59:17 2010):
The system is going down for reboot NOW!
重启后启动Listerner:
[root@erpdevdb ~]# su - oracle
[oracle@erpdevdb ~]$ lsnrctl startLSNRCTL for Linux: Version 10.2.0.1.0 - Production on 25-FEB-2010 13:03:58
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /u01/app/oracle/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/app/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=erpdevdb.chinacnd.com)(PORT=1521)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 25-FEB-2010 13:03:58
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=erpdevdb.chinacnd.com)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@erpdevdb ~]$
启动Asm实例:
[oracle@erpdevdb ~]$ export ORACLE_SID=+ASM
[oracle@erpdevdb ~]$ sqlplus "/ as sysdba"SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 25 13:04:17 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ASM instance startedTotal System Global Area 130023424 bytes
Fixed Size 2019032 bytes
Variable Size 102838568 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
启动其他数据库实例:
[oracle@erpdevdb ~]$ export ORACLE_SID=devdb
[oracle@erpdevdb ~]$ sqlplus "/ as sysdba"SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 25 13:04:40 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.Total System Global Area 4294967296 bytes
Fixed Size 2026296 bytes
Variable Size 285213896 bytes
Database Buffers 3992977408 bytes
Redo Buffers 14749696 bytes
Database mounted.
Database opened.
SQL> exit
创建Asm设备:
[root@erpdevdb ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sda9
Marking disk "VOL4" as an ASM disk: [ OK ]
[root@erpdevdb ~]#
[root@erpdevdb ~]#
[root@erpdevdb ~]#
[root@erpdevdb ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
创建ASM磁盘组:
[root@erpdevdb ~]# su - oracle
[oracle@erpdevdb ~]$ export ORACLE_SID=+ASM
[oracle@erpdevdb ~]$ sqlplus "/ as sysdba"SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 25 13:52:44 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining optionsSQL>
SQL>
SQL> create diskgroup DGTEST external redundancy disk 'ORCL:VOL4';Diskgroup created.
SQL>
SQL> select name,group_number,disk_number,mode_status from v$asm_disk;NAME GROUP_NUMBER DISK_NUMBER MODE_ST
------------------------------ ------------ ----------- -------
VOL1 3 0 ONLINE
VOL2 1 0 ONLINE
VOL3 2 0 ONLINE
VOL4 4 0 ONLINESQL> select group_number,name,total_mb,free_mb from v$asm_diskgroup;
GROUP_NUMBER NAME TOTAL_MB FREE_MB
------------ ------------------------------ ---------- ----------
1 DGDEV 292974 151815
2 DGPAPER 488288 328379
3 DGSTUDY 292974 168839
4 DGTEST 286110 286058SQL> exit
然后通过dbca工具创建新的实例,在创建过程中存储选择这里新建的DGTEST磁盘组即可:

技术组织
最近评论
历史归档
广告位






