目錄
ASM using ASMLib and Raw Devices
Introduction
Partition the Disks
ASMLib Installation
Raw Device Setup
ASM Creation
Database Creation
Switching from Raw Devices to ASMLib
Switching from ASMLib to Raw Devices
Performance Comparison
首頁 資料庫 mysql教程 ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Jun 07, 2016 pm 03:50 PM
and asm raw using

Home?Articles?10g? Here http://www.oracle-base.com/articles/10g/asm-using-asmlib-and-raw-devices.php ASM using ASMLib and Raw Devices Introduction Partition the Disks ASMLib Installation Raw Device Setup ASM Creation Database Creation Swit

Home ? Articles ? 10g ? Here
http://www.oracle-base.com/articles/10g/asm-using-asmlib-and-raw-devices.php

ASM using ASMLib and Raw Devices

  • Introduction
  • Partition the Disks
  • ASMLib Installation
  • Raw Device Setup
  • ASM Creation
  • Database Creation
  • Switching from Raw Devices to ASMLib
  • Switching from ASMLib to Raw Devices
  • Performance Comparison

Related articles.

  • Automatic Storage Management (ASM) in Oracle Database 10g
  • Using NFS with ASM
  • Automatic Storage Manager (ASM) Enhancements in Oracle Database 11g Release 1
  • UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6

Introduction

Automatic Storage Management (ASM) simplifies administration of Oracle related files by allowing the administrator to reference disk groups rather than individual disks and files, which ASM manages internally. On Linux, ASM is capable of referencing disks as raw devices or by using the ASMLib software. This article presents the setup details for using either raw devices or ASMLib, as well as the procedures for converting between both methods.

The article assumes the operating system installation is complete, along with an Oracle software installation. The ASM instance shares the Oracle home with the database instance. If you plan on running multiple database instances on the server the ASM instance should be installed in a separate Oracle home.

Note: When running Oracle 10g Release 2 on RHEL 4 you should consider reading this article: Using Block Devices for Oracle 10g Release 2 in RHEL 4

Partition the Disks

Both ASMLib and raw devices require the candidate disks to be partitioned before they can be accessed. In this example, three 10Gig VMware virtual disks are to be used for the ASM storage. The following text shows the "/dev/sdb" disk being partitioned.

# ls sd*
sda  sda1  sda2  sdb  sdc  sdd
# 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): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#
登入後複製
登入後複製

The remaining disks ("/dev/sdc" and "/dev/sdd") must be partitioned in the same way.

ASMLib Installation

This step is only necessary if you want to use ASMLib to access the ASM disks.

Determine your kernel version using the following command as the root user.

# uname -r
2.6.9-34.ELsmp
#
登入後複製
登入後複製

Download the ASMLib software from the OTN website, making sure you pick the version that matches your distribution, kernel and architecture. For this example I used CentOS 4.3, so the following packages were required.

  • oracleasm-support-2.0.1-1.i386.rpm
  • oracleasmlib-2.0.1-1.i386.rpm
  • oracleasm-2.6.9-34.ELsmp-2.0.1-1.i686.rpm

Install the packages as the root user.

# rpm -Uvh oracleasm-support-2.0.1-1.i386.rpm \
           oracleasmlib-2.0.1-1.i386.rpm \
           oracleasm-2.6.9-34.ELsmp-2.0.1-1.i686.rpm
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [ 33%]
   2:oracleasm-2.6.9-34.ELsm########################################### [ 67%]
   3:oracleasmlib           ########################################### [100%]
#
登入後複製
登入後複製

With the software installed, configure the ASM kernel module.

# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting <enter> without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface []: oracle
Default group to own the driver interface []: oinstall
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration:           [  OK  ]
Creating /dev/oracleasm mount point:                       [  OK  ]
Loading module "oracleasm":                                [  OK  ]
Mounting ASMlib driver filesystem:                         [  OK  ]
Scanning system for ASM disks:                             [  OK  ]
#</enter>
登入後複製
登入後複製

Once the kernel module is loaded, stamp (or label) the partitions created earlier as ASM disks.

# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk:                   [  OK  ]
#
登入後複製
登入後複製

If this were a RAC installation, the disks would only be stamped by one node. The other nodes would just scan for the disks.

# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:                             [  OK  ]
#
登入後複製
登入後複製

The stamped disks are listed as follows.

# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
#
登入後複製
登入後複製

The disks are now ready to be used by ASM.

Raw Device Setup

This step is only necessary if you want ASM to access the disks as raw devices.

Edit the "/etc/sysconfig/rawdevices" file, adding the following lines.

/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdc1
/dev/raw/raw3 /dev/sdd1
登入後複製
登入後複製

Restart the rawdevices service using the following command.

service rawdevices restart
登入後複製
登入後複製

Run the following commands and add them the "/etc/rc.local" file.

chown oracle:oinstall /dev/raw/raw1
chown oracle:oinstall /dev/raw/raw2
chown oracle:oinstall /dev/raw/raw3
chmod 600 /dev/raw/raw1
chmod 600 /dev/raw/raw2
chmod 600 /dev/raw/raw3
登入後複製
登入後複製

The ASM raw device disks are now configured.

ASM Creation

Creation of the ASM instance is the same, regardless of the use of ASMLib or raw devices. When using ASMLib, the candidate disks are listed using the stamp associated with them, while the raw devices are listed using their device name.

To configure an ASM instance, start the Database Configuration Assistant by issuing the "dbca" command as the oracle user. On the "Welcome" screen, click the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Select the "Configure Automatic Storage Management" option, then click the "Next" Button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

If the Oracle Cluster Syncronization Service (CSS) is not currently running, a warning screen will be displayed. Follow the instructions and click the "OK" button. Once you've returned to the previous screen, click the "Next" button again.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

The script gives the following output.

# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized

Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
        centos2
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
#
登入後複製
登入後複製

Enter a password for the ASM instance, then click the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

On the confirmation screen, click the "OK" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Wait while the ASM instance is created.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Once the ASM instance is created, you are presented with the "ASM Disk Groups" screen. Click the "Create New" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

On the "Create Disk Group" screen, enter Disk Group Name of "DATA" and select the required level of redundancy:

  • External - ASM does not mirror the files. This option should only be used if your disks are already protected by some form of redundancy, like RAID.
  • Normal - ASM performs two-way mirroring of all files.
  • High - ASM performs three-way mirroring of all files.

In this example, the "High" redundancy is used. Select all three candidate disks and click the "OK" button. The following image shows how the candidate disks are displayed when using ASMLib.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

When using raw devices, the candidate discs are listed using the devide names.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

On the "ASM Disk Groups" screen. Click the "Finish" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Click the "Yes" button to perform another operation.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

You are now ready to create a database instance using ASM.

Database Creation

Before continuing with the database creation, check the listener is up and the ASM instance has registered with it. Start the listener using the following command.

$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 29-APR-2006 14:35:46

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

Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener .log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos2.localdomain)(POR T=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                29-APR-2006 14:35:47
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listen er.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos2.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
$
登入後複製
登入後複製

The ASM instance is not registered, so we can force the registration by doing the following.

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Apr 29 14:37:06 2006

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

SQL> alter system register;

System altered.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Pr oduction
With the Partitioning, OLAP and Data Mining options
$
登入後複製
登入後複製

Checking the status of the listener shows that the ASM instance is now registered.

$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 29-APR-2006 14:37:32

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                29-APR-2006 14:35:47
Uptime                    0 days 0 hr. 1 min. 46 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listen er.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos2.localdomain)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully
$
登入後複製
登入後複製

Go back to the DBCA and create a custom database in the normal way, selecting the "Automatic Storage Management (ASM)" storage option.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Enter the ASM password if prompted, then click the "OK" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Select the "DATA" disk group, then clicking the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Accept the default "Oracle-Managed Files" database location by clicking the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Enable the "Flash Recovery Area" and Archiving, using the "+DATA" disk group for both.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Continue with the rest of the DBCA, selecting the required options along the way.

Switching from Raw Devices to ASMLib

Shutdown any databases using the ASM instance, but leave the ASM instance itself running. Connect to the running ASM instance.

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
登入後複製
登入後複製
登入後複製
登入後複製

Perform the ASMLib Installation, but stop prior to stamping the ASM disk. If you attempt to stamp the disks using the createdisk command it will fail.

Alter the ASM disk discovery string to exclude the raw devices used previously, then shutdown the ASM instance.

SQL> ALTER SYSTEM SET asm_diskstring = 'ORCL:VOL*' SCOPE=SPFILE;

System altered.

SQL> SHUTDOWN IMMEDIATE;
ASM diskgroups dismounted
ASM instance shutdown
SQL>
登入後複製
登入後複製

If you are planning to remove the raw device mappings (Raw Device Setup), you could simply reset the ASM_DISKGROUP parameter.

SQL> ALTER SYSTEM RESET asm_diskstring SCOPE=SPFILE SID='*';

System altered.

SQL>
登入後複製
登入後複製

At this point the disks will not be used by ASM because they are not stamped. As mentioned previously, the createdisk command used to stamp new disks would fail, so we must issue the renamedisk command as the root user for each disk.

# /etc/init.d/oracleasm renamedisk /dev/sdb1 VOL1
Renaming disk "/dev/sdb1" to "VOL1":                       [  OK  ]
# /etc/init.d/oracleasm renamedisk /dev/sdc1 VOL2
Renaming disk "/dev/sdc1" to "VOL2":                       [  OK  ]
# /etc/init.d/oracleasm renamedisk /dev/sdd1 VOL3
Renaming disk "/dev/sdd1" to "VOL3":                       [  OK  ]
#
登入後複製
登入後複製

Notice, the stamp matches the discovery string set earlier. The ASM instance can now be started.

SQL> STARTUP
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
SQL>
登入後複製
登入後複製
登入後複製
登入後複製

The ASM instance is now using ASMLib, rather than raw devices. All dependent databases can now be started.

Switching from ASMLib to Raw Devices

Shutdown any databases using the ASM instance, but leave the ASM instance itself running. Connect to the running ASM instance.

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
登入後複製
登入後複製
登入後複製
登入後複製

Alter the ASM disk discovery string to match the raw devices you plan to set up, then shutdown the ASM instance.

SQL> ALTER SYSTEM SET asm_diskstring = '/dev/raw/raw*' SCOPE=SPFILE;

System altered.

SQL> SHUTDOWN IMMEDIATE;
ASM diskgroups dismounted
ASM instance shutdown
SQL>
登入後複製
登入後複製

Perform all the steps listed in the Raw Device Setup, then start the ASM instance.

SQL> STARTUP
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
SQL>
登入後複製
登入後複製
登入後複製
登入後複製

The ASM instance is now using the disks as raw devices, rather than as ASMLib disks. All dependent databases can now be started.

Performance Comparison

Some documents suggests using ASMLib with Oracle 10g Release 2 gives superior disk performance, while others say it only reduces the time searching for candidate disks, and hence ASM startup time. I decided to compare the performance of the two methods myself to see if I could tell the difference.

My first thought was to perform a simple insert/update/delete test, so I created the following user and schema for the test in a database using and ASM instance using ASMLib.

export ORACLE_SID=DB10G
sqlplus / as sysdba

CREATE TABLESPACE test_ts;

CREATE USER test_user IDENTIFIED BY test_user DEFAULT TABLESPACE test_ts QUOTA UNLIMITED ON test_ts;
GRANT CONNECT, CREATE TABLE TO test_user;

CONN test_user/test_user

CREATE TABLE test_tab (
  id    NUMBER,
  data  VARCHAR2(4000),
  CONSTRAINT test_tab_pk PRIMARY KEY (id)
);
登入後複製
登入後複製

Then, as the test user, I ran the following code several times and calculated an average time for each operation.

SET SERVEROUTPUT ON
DECLARE
  l_loops NUMBER := 1000;
  l_data  VARCHAR2(32767) := RPAD('X', 4000, 'X');
  l_start NUMBER;
BEGIN
  l_start := DBMS_UTILITY.get_time;

  FOR i IN 1 .. l_loops LOOP
    INSERT INTO test_tab (id, data) VALUES (i, l_data);
    COMMIT;
  END LOOP;

  DBMS_OUTPUT.put_line('Inserts (' || l_loops || '): ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs');

  l_start := DBMS_UTILITY.get_time;

  FOR i IN 1 .. l_loops LOOP
    UPDATE test_tab
    SET    data = l_data
    WHERE  id   = i;
    COMMIT;
  END LOOP;

  DBMS_OUTPUT.put_line('Updates (' || l_loops || '): ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs');

  l_start := DBMS_UTILITY.get_time;

  FOR i IN 1 .. l_loops LOOP
    DELETE FROM test_tab
    WHERE  id = i;
    COMMIT;
  END LOOP;

  DBMS_OUTPUT.put_line('Deletes (' || l_loops || '): ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs');

  EXECUTE IMMEDIATE 'TRUNCATE TABLE test_tab';
END;
/
登入後複製
登入後複製

The code is purposely inefficient, using a single statement and a commit within a loop for each operation. Remember, the ASM instance is using high redundancy, so each physical write operation is effectively done 3 times.

Once the tests on ASMLib were complete, I switched to using raw devices and repeated the tests. The average results for 1000 of each operation are listed below.

Operation       ASMLib (hsecs)  Raw Devices (hsecs)
==============  ==============  ===================
Inserts (1000)             468                  852
Updates (1000)             956                 1287
Deletes (1000)            1281                 1995
登入後複製
登入後複製

You can instantly see that the ASMLib results are better than those of the raw devices, but the testing is suspect for the following reasons:

  • For each single run of the script, only 1000 operations of each type were performed. That equates to about 4M of data in the table when it is full. When you consider the use of the buffer cache, this is a pitiful amount of data. I originally intended to perform many more operations, but my disk was grinding so badly I thought better of it.
  • The tests were performed using VMware virtual disks, so really all this work was being done on a single SATA disk. I can't be sure if these results aren't just an artifact of the setup.
  • Although the average results look convincing, the raw data was so eratic I'm not convinced these results mean anything.

For these reasons, I decided not to continue to persue the performance tests, much to the delight of my hard drive. If I get access to a more realistic setup I will attempt some large scale tests and report the outcome.

For more information see:

  • Installing ASMLib
  • Migrating Raw Devices to ASMLib
  • Automatic Storage Management (ASM) in Oracle Database 10g
  • Oracle Database 10g Release 2 (10.2.0.1) RAC Installation On Linux (CentOS 4) Using VMware Server
  • Configuring I/O for Raw Partitions

Hope this helps. Regards Tim...

Back to the Top.

  • Introduction
  • Partition the Disks
  • ASMLib Installation
  • Raw Device Setup
  • ASM Creation
  • Database Creation
  • Switching from Raw Devices to ASMLib
  • Switching from ASMLib to Raw Devices
  • Performance Comparison

Related articles.

  • Automatic Storage Management (ASM) in Oracle Database 10g
  • Using NFS with ASM
  • Automatic Storage Manager (ASM) Enhancements in Oracle Database 11g Release 1
  • UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6

Introduction

Automatic Storage Management (ASM) simplifies administration of Oracle related files by allowing the administrator to reference disk groups rather than individual disks and files, which ASM manages internally. On Linux, ASM is capable of referencing disks as raw devices or by using the ASMLib software. This article presents the setup details for using either raw devices or ASMLib, as well as the procedures for converting between both methods.

The article assumes the operating system installation is complete, along with an Oracle software installation. The ASM instance shares the Oracle home with the database instance. If you plan on running multiple database instances on the server the ASM instance should be installed in a separate Oracle home.

Note: When running Oracle 10g Release 2 on RHEL 4 you should consider reading this article: Using Block Devices for Oracle 10g Release 2 in RHEL 4

Partition the Disks

Both ASMLib and raw devices require the candidate disks to be partitioned before they can be accessed. In this example, three 10Gig VMware virtual disks are to be used for the ASM storage. The following text shows the "/dev/sdb" disk being partitioned.

# ls sd*
sda  sda1  sda2  sdb  sdc  sdd
# 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): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#
登入後複製
登入後複製

The remaining disks ("/dev/sdc" and "/dev/sdd") must be partitioned in the same way.

ASMLib Installation

This step is only necessary if you want to use ASMLib to access the ASM disks.

Determine your kernel version using the following command as the root user.

# uname -r
2.6.9-34.ELsmp
#
登入後複製
登入後複製

Download the ASMLib software from the OTN website, making sure you pick the version that matches your distribution, kernel and architecture. For this example I used CentOS 4.3, so the following packages were required.

  • oracleasm-support-2.0.1-1.i386.rpm
  • oracleasmlib-2.0.1-1.i386.rpm
  • oracleasm-2.6.9-34.ELsmp-2.0.1-1.i686.rpm

Install the packages as the root user.

# rpm -Uvh oracleasm-support-2.0.1-1.i386.rpm \
           oracleasmlib-2.0.1-1.i386.rpm \
           oracleasm-2.6.9-34.ELsmp-2.0.1-1.i686.rpm
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [ 33%]
   2:oracleasm-2.6.9-34.ELsm########################################### [ 67%]
   3:oracleasmlib           ########################################### [100%]
#
登入後複製
登入後複製

With the software installed, configure the ASM kernel module.

# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting <enter> without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface []: oracle
Default group to own the driver interface []: oinstall
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration:           [  OK  ]
Creating /dev/oracleasm mount point:                       [  OK  ]
Loading module "oracleasm":                                [  OK  ]
Mounting ASMlib driver filesystem:                         [  OK  ]
Scanning system for ASM disks:                             [  OK  ]
#</enter>
登入後複製
登入後複製

Once the kernel module is loaded, stamp (or label) the partitions created earlier as ASM disks.

# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk:                   [  OK  ]
#
登入後複製
登入後複製

If this were a RAC installation, the disks would only be stamped by one node. The other nodes would just scan for the disks.

# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:                             [  OK  ]
#
登入後複製
登入後複製

The stamped disks are listed as follows.

# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
#
登入後複製
登入後複製

The disks are now ready to be used by ASM.

Raw Device Setup

This step is only necessary if you want ASM to access the disks as raw devices.

Edit the "/etc/sysconfig/rawdevices" file, adding the following lines.

/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdc1
/dev/raw/raw3 /dev/sdd1
登入後複製
登入後複製

Restart the rawdevices service using the following command.

service rawdevices restart
登入後複製
登入後複製

Run the following commands and add them the "/etc/rc.local" file.

chown oracle:oinstall /dev/raw/raw1
chown oracle:oinstall /dev/raw/raw2
chown oracle:oinstall /dev/raw/raw3
chmod 600 /dev/raw/raw1
chmod 600 /dev/raw/raw2
chmod 600 /dev/raw/raw3
登入後複製
登入後複製

The ASM raw device disks are now configured.

ASM Creation

Creation of the ASM instance is the same, regardless of the use of ASMLib or raw devices. When using ASMLib, the candidate disks are listed using the stamp associated with them, while the raw devices are listed using their device name.

To configure an ASM instance, start the Database Configuration Assistant by issuing the "dbca" command as the oracle user. On the "Welcome" screen, click the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Select the "Configure Automatic Storage Management" option, then click the "Next" Button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

If the Oracle Cluster Syncronization Service (CSS) is not currently running, a warning screen will be displayed. Follow the instructions and click the "OK" button. Once you've returned to the previous screen, click the "Next" button again.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

The script gives the following output.

# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized

Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
        centos2
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
#
登入後複製
登入後複製

Enter a password for the ASM instance, then click the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

On the confirmation screen, click the "OK" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Wait while the ASM instance is created.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Once the ASM instance is created, you are presented with the "ASM Disk Groups" screen. Click the "Create New" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

On the "Create Disk Group" screen, enter Disk Group Name of "DATA" and select the required level of redundancy:

  • External - ASM does not mirror the files. This option should only be used if your disks are already protected by some form of redundancy, like RAID.
  • Normal - ASM performs two-way mirroring of all files.
  • High - ASM performs three-way mirroring of all files.

In this example, the "High" redundancy is used. Select all three candidate disks and click the "OK" button. The following image shows how the candidate disks are displayed when using ASMLib.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

When using raw devices, the candidate discs are listed using the devide names.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

On the "ASM Disk Groups" screen. Click the "Finish" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Click the "Yes" button to perform another operation.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

You are now ready to create a database instance using ASM.

Database Creation

Before continuing with the database creation, check the listener is up and the ASM instance has registered with it. Start the listener using the following command.

$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 29-APR-2006 14:35:46

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

Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener .log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos2.localdomain)(POR T=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                29-APR-2006 14:35:47
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listen er.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos2.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
$
登入後複製
登入後複製

The ASM instance is not registered, so we can force the registration by doing the following.

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Apr 29 14:37:06 2006

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

SQL> alter system register;

System altered.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Pr oduction
With the Partitioning, OLAP and Data Mining options
$
登入後複製
登入後複製

Checking the status of the listener shows that the ASM instance is now registered.

$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 29-APR-2006 14:37:32

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                29-APR-2006 14:35:47
Uptime                    0 days 0 hr. 1 min. 46 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listen er.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos2.localdomain)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully
$
登入後複製
登入後複製

Go back to the DBCA and create a custom database in the normal way, selecting the "Automatic Storage Management (ASM)" storage option.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Enter the ASM password if prompted, then click the "OK" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Select the "DATA" disk group, then clicking the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Accept the default "Oracle-Managed Files" database location by clicking the "Next" button.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Enable the "Flash Recovery Area" and Archiving, using the "+DATA" disk group for both.

ASM using ASMLib and Raw Devices (for oracle 10g)【不错的

Continue with the rest of the DBCA, selecting the required options along the way.

Switching from Raw Devices to ASMLib

Shutdown any databases using the ASM instance, but leave the ASM instance itself running. Connect to the running ASM instance.

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
登入後複製
登入後複製
登入後複製
登入後複製

Perform the ASMLib Installation, but stop prior to stamping the ASM disk. If you attempt to stamp the disks using the createdisk command it will fail.

Alter the ASM disk discovery string to exclude the raw devices used previously, then shutdown the ASM instance.

SQL> ALTER SYSTEM SET asm_diskstring = 'ORCL:VOL*' SCOPE=SPFILE;

System altered.

SQL> SHUTDOWN IMMEDIATE;
ASM diskgroups dismounted
ASM instance shutdown
SQL>
登入後複製
登入後複製

If you are planning to remove the raw device mappings (Raw Device Setup), you could simply reset the ASM_DISKGROUP parameter.

SQL> ALTER SYSTEM RESET asm_diskstring SCOPE=SPFILE SID='*';

System altered.

SQL>
登入後複製
登入後複製

At this point the disks will not be used by ASM because they are not stamped. As mentioned previously, the createdisk command used to stamp new disks would fail, so we must issue the renamedisk command as the root user for each disk.

# /etc/init.d/oracleasm renamedisk /dev/sdb1 VOL1
Renaming disk "/dev/sdb1" to "VOL1":                       [  OK  ]
# /etc/init.d/oracleasm renamedisk /dev/sdc1 VOL2
Renaming disk "/dev/sdc1" to "VOL2":                       [  OK  ]
# /etc/init.d/oracleasm renamedisk /dev/sdd1 VOL3
Renaming disk "/dev/sdd1" to "VOL3":                       [  OK  ]
#
登入後複製
登入後複製

Notice, the stamp matches the discovery string set earlier. The ASM instance can now be started.

SQL> STARTUP
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
SQL>
登入後複製
登入後複製
登入後複製
登入後複製

The ASM instance is now using ASMLib, rather than raw devices. All dependent databases can now be started.

Switching from ASMLib to Raw Devices

Shutdown any databases using the ASM instance, but leave the ASM instance itself running. Connect to the running ASM instance.

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
登入後複製
登入後複製
登入後複製
登入後複製

Alter the ASM disk discovery string to match the raw devices you plan to set up, then shutdown the ASM instance.

SQL> ALTER SYSTEM SET asm_diskstring = '/dev/raw/raw*' SCOPE=SPFILE;

System altered.

SQL> SHUTDOWN IMMEDIATE;
ASM diskgroups dismounted
ASM instance shutdown
SQL>
登入後複製
登入後複製

Perform all the steps listed in the Raw Device Setup, then start the ASM instance.

SQL> STARTUP
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
SQL>
登入後複製
登入後複製
登入後複製
登入後複製

The ASM instance is now using the disks as raw devices, rather than as ASMLib disks. All dependent databases can now be started.

Performance Comparison

Some documents suggests using ASMLib with Oracle 10g Release 2 gives superior disk performance, while others say it only reduces the time searching for candidate disks, and hence ASM startup time. I decided to compare the performance of the two methods myself to see if I could tell the difference.

My first thought was to perform a simple insert/update/delete test, so I created the following user and schema for the test in a database using and ASM instance using ASMLib.

export ORACLE_SID=DB10G
sqlplus / as sysdba

CREATE TABLESPACE test_ts;

CREATE USER test_user IDENTIFIED BY test_user DEFAULT TABLESPACE test_ts QUOTA UNLIMITED ON test_ts;
GRANT CONNECT, CREATE TABLE TO test_user;

CONN test_user/test_user

CREATE TABLE test_tab (
  id    NUMBER,
  data  VARCHAR2(4000),
  CONSTRAINT test_tab_pk PRIMARY KEY (id)
);
登入後複製
登入後複製

Then, as the test user, I ran the following code several times and calculated an average time for each operation.

SET SERVEROUTPUT ON
DECLARE
  l_loops NUMBER := 1000;
  l_data  VARCHAR2(32767) := RPAD('X', 4000, 'X');
  l_start NUMBER;
BEGIN
  l_start := DBMS_UTILITY.get_time;

  FOR i IN 1 .. l_loops LOOP
    INSERT INTO test_tab (id, data) VALUES (i, l_data);
    COMMIT;
  END LOOP;

  DBMS_OUTPUT.put_line('Inserts (' || l_loops || '): ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs');

  l_start := DBMS_UTILITY.get_time;

  FOR i IN 1 .. l_loops LOOP
    UPDATE test_tab
    SET    data = l_data
    WHERE  id   = i;
    COMMIT;
  END LOOP;

  DBMS_OUTPUT.put_line('Updates (' || l_loops || '): ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs');

  l_start := DBMS_UTILITY.get_time;

  FOR i IN 1 .. l_loops LOOP
    DELETE FROM test_tab
    WHERE  id = i;
    COMMIT;
  END LOOP;

  DBMS_OUTPUT.put_line('Deletes (' || l_loops || '): ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs');

  EXECUTE IMMEDIATE 'TRUNCATE TABLE test_tab';
END;
/
登入後複製
登入後複製

The code is purposely inefficient, using a single statement and a commit within a loop for each operation. Remember, the ASM instance is using high redundancy, so each physical write operation is effectively done 3 times.

Once the tests on ASMLib were complete, I switched to using raw devices and repeated the tests. The average results for 1000 of each operation are listed below.

Operation       ASMLib (hsecs)  Raw Devices (hsecs)
==============  ==============  ===================
Inserts (1000)             468                  852
Updates (1000)             956                 1287
Deletes (1000)            1281                 1995
登入後複製
登入後複製

You can instantly see that the ASMLib results are better than those of the raw devices, but the testing is suspect for the following reasons:

  • For each single run of the script, only 1000 operations of each type were performed. That equates to about 4M of data in the table when it is full. When you consider the use of the buffer cache, this is a pitiful amount of data. I originally intended to perform many more operations, but my disk was grinding so badly I thought better of it.
  • The tests were performed using VMware virtual disks, so really all this work was being done on a single SATA disk. I can't be sure if these results aren't just an artifact of the setup.
  • Although the average results look convincing, the raw data was so eratic I'm not convinced these results mean anything.

For these reasons, I decided not to continue to persue the performance tests, much to the delight of my hard drive. If I get access to a more realistic setup I will attempt some large scale tests and report the outcome.

For more information see:

  • Installing ASMLib
  • Migrating Raw Devices to ASMLib
  • Automatic Storage Management (ASM) in Oracle Database 10g
  • Oracle Database 10g Release 2 (10.2.0.1) RAC Installation On Linux (CentOS 4) Using VMware Server
  • Configuring I/O for Raw Partitions

Hope this helps. Regards Tim...

Back to the Top.

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1670
14
CakePHP 教程
1428
52
Laravel 教程
1329
25
PHP教程
1274
29
C# 教程
1256
24
chkdsk無法供raw驅動器使用怎麼辦 chkdsk無法供raw驅動器使用怎麼辦 Mar 06, 2023 pm 03:27 PM

chkdsk無法供raw驅動器使用的解決方法:1、右鍵底部任務欄Win圖標,在彈出的選單列中點擊“運行”選項;2、在命令列視窗輸入“chkdsk /?”,然後點擊回車鍵確定;3、等待chkdsk工具成功運作即可。

linux raw是什麼格式 linux raw是什麼格式 Mar 14, 2023 am 09:33 AM

linux raw是原始資料格式,在linux中表示“裸設備”,也稱為裸分割區、原始分割區;linux raw是一種沒有經過格式化,不被Unix/Linux通過檔案系統來讀取的特殊字元裝置;裸設備可以綁定一個分割區,也可以綁定一個磁碟。

raw格式和jpg格式有什麼差別 raw格式和jpg格式有什麼差別 Aug 10, 2023 pm 03:31 PM

raw格式和jpg格式區別有:1、JPEG是一種被廣泛使用的有損壓縮格式,而RAW格式是一種無損的圖像格式;2、JPEG格式的圖像檔案小巧,而RAW格式的檔案較大;3、JPEG格式的影像只能進行有限的後製處理,而RAW格式的影像保留了更多的細節和色彩訊息,使您能夠在後期處理中做出更多的調整。

raw照片是什麼意思 raw照片是什麼意思 Jan 12, 2021 am 11:05 AM

raw照片是指未經處理、也未經壓縮的照片格式;因為raw的原意就是“未經加工”,可以理解為“RAW影像就是CMOS或CCD影像感應器將捕捉到的光源訊號轉換為數位訊號的原始數據」。

raw是什麼格式 raw是什麼格式 Feb 01, 2023 pm 01:43 PM

RAW是未經處理、也未經壓縮的格式,可以把RAW概念化為「原始影像編碼資料」或更形象的稱為「數位底片」。 RAW格式檔案是一種記錄了數位相機感測器的原始訊息,同時記錄了由相機拍攝所產生的一些元資料(Metadata,如ISO的設定、快門速度、光圈值、白平衡等)的檔案。

高精準度低成本遊戲3D人臉重建方案,騰訊AI Lab ICCV 2023論文解讀 高精準度低成本遊戲3D人臉重建方案,騰訊AI Lab ICCV 2023論文解讀 Oct 27, 2023 pm 12:13 PM

3D人臉重建是一項廣泛應用於遊戲影視製作、數位人、AR/VR、人臉辨識和編輯等領域的關鍵技術,目標是從單張或多張影像中獲取高品質的3D人臉模型。借助攝影棚中的複雜拍攝系統,當前業界成熟方案已可得到媲美真人的毛孔級精度的重建效果[2],但其製作成本高、週期長,一般僅用於S級影視或遊戲項目。近年來,基於低成本人臉重建技術的互動玩法(如遊戲角色捏臉玩法、AR/VR虛擬形像生成等)受到市場歡迎。使用者只需輸入日常可取得的圖片,如手機拍攝的單張或多張圖片,即可快速取得3D模型。但現有方法成像品質不可控,重建

SQL語句中的AND運算子和OR運算子怎麼用 SQL語句中的AND運算子和OR運算子怎麼用 May 28, 2023 pm 04:34 PM

SQLAND&OR運算子AND和OR運算子用於基於一個以上的條件來篩選記錄。 AND和OR可在WHERE子語句中把兩個或多個條件結合起來。如果第一個條件和第二個條件都成立,則AND運算子顯示一筆記錄。如果第一個條件和第二個條件中只要有一個成立,則OR運算子顯示一筆記錄。 "Persons"表:LastNameFirstNameAddressCityAdamsJohnOxfordStreetLondonBushGeorgeFifthAvenueNewYorkCarter

Java ASM使用logback日誌等級動態切換方法 Java ASM使用logback日誌等級動態切換方法 May 09, 2023 pm 01:25 PM

背景一切都有因果,所有事情,都有事件驅動。本方案的日誌等級切換是由這樣的背景下產生的:單一生產環境上,有幾百近千個微服務日誌等級切換不重啟服務,要求即時生效果由業務開發人員去修改程式碼或增加相關依賴配置等涉及面廣,推動進度慢後期動態即時過濾垃圾日誌,減少io和磁碟空間成本logback簡介在跟敵人發起戰爭之前,只有先發解敵方的情況,才能做到百戰百勝。要對logback的日誌等級做動態切換,首先至少對logback做個初步的了解、和看看它有沒有提供現成的實作方案。下面簡單介紹一下logback跟這

See all articles