Oracle RAC series: Basic O & M for ASM

Source: Internet
Author: User

(ASM Automatic Storage Management) is a data file storage mechanism dedicated to Oracle database services. By managing data files through ASM, DBAs no longer have to worry about I/O performance issues, you do not need to know the file name. At the same time, ASM also provides integration from the file system to the volume manager.
I. Features of ASM
1) automatically adjust the I/O Load
ASM can automatically adjust the I/O load in all available disks, which not only avoids the difficulty of manual I/O adjustment, but also optimizes the performance, with ASM, you can increase the database size online without shutting down the database.
2) Band-based storage
ASM divides files into multiple Allocation Units, AU) for storage, and evenly allocates the AU of each file among all disks.
3) Online Automatic Load Balancing
When shared storage devices change, data in ASM is automatically and evenly distributed to existing storage devices. You can also adjust the load balancing speed of data.
4) automatically manage database files
In ASM storage management, Oracle data files are automatically managed by ASM. Any files created by ASM are automatically deleted once they are no longer needed. However, ASM does not manage binary files, trace files, warning logs, and password files.
5) data redundancy
ASM can achieve data redundancy through the disk group image without third-party tools.
6) support for various Oracle data files
The ASM storage supports Oracle data files, log files, control files, archived logs, and RMAN backup sets.

Ii. ASM architecture and background process

Figure 1 shows the physical structure of ASM.

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131229/1935402b9-0.png "/>

As shown in figure 1, the top layer is the ASM disk group, and the ASM instance and database instance can directly access these disk groups. Then the ASM file, each ASM file can only be contained in one disk group. However, A disk group can contain multiple ASM files belonging to multiple databases, and a single database can use buckets from multiple disk groups. The third part is the ASM disk, multiple ASM disk groups are used as ASM disk groups, but each ASM disk can only belong to one disk group. Then, the AU disk is the smallest continuous disk space allocated by the ASM disk group, the ASM disk is partitioned by AU. The size of each AU is 1 MB. The bottom layer of this structure is an Oracle data block. Because AU is the minimum contiguous disk space allocated by ASM, ASM cannot split an Oracle data block across allocation units.
To use ASM, you must first start an instance named "+ ASM" before starting the database instance. The ASM instance does not load the database, it is started to manage the disk group and protect the data in it. At the same time, the ASM instance can also pass information about the file layout to the database instance. In this way, the database instance can directly access the files stored in the disk group. Figure 2 shows the general architecture of ASM.
 

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131229/1935402464-1.png "/>

As shown in figure 2, the bridge between the ASM instance and the database instance is the ASMB process, which runs on each database instance and serves as a channel for information exchange between two instances. The ASMB process first obtains the connection string of the ASM instance managing the disk group through CSS using the disk group name, and then establishes a persistent connection to the ASM, so that information can be exchanged regularly between two instances through this connection, this is also a heartbeat monitoring mechanism.
In addition, another new process, RBAL, exists in the ASM instance, which is responsible for planning and coordinating the rebalancing activities of the disk group. In addition, the ASM instance has some background processes that are the same as those in the database instance, such as LGWR, SMON, PMON, DBWR, and CKPT.
If a database instance uses ASM for storage, there will be two more background processes, RBAL and ASMB. RBAL is responsible for opening all disks and data in the disk group, while ASMB is responsible for communicating with the process of the ASM instance.

Iii. Managing ASM instances
When Using ASM as data storage, ASM instance management is very important. Oracle provides a wide range of management functions. To manage ASM instances, you must have SYSDBA permissions, you can use a new role (SYSASM) in Oracle 11g to manage the ASM instance only.
1. Create an ASM instance
There are two methods to create an ASM instance. The first method is to create an ASM instance using dbca. You only need to run Database Configuration AssistantDBCA) and create an ASM instance as prompted, I will not talk about it here. The second method is to create an ASM instance using the command line method. The following is a brief introduction.
1) Create an ASM Disk
You can use RAID-divided Luns, partitions, and bare devices to create an ASM disk. However, when using Luns, partitions, or bare devices, note that you should change the owner and group to an Oracle user and the corresponding group. This is described in the previous section, another simple method is to use ASMLib provided by Oracle to create an ASM disk. This method is described below.
Before creating an ASM instance, ensure that the ASMlib package has been installed on the node and check whether the ASMLib has been automatically loaded:
[Root @ node1 ~] # Lsmod | grep oracleasm
Oracleasm 46356 1
Then, use oracleasm provided by ASMlib to convert the partition into an ASM disk. For example:
[Root @ node1 ~] #/Etc/init. d/oracleasm createdisk ASMDISK1/dev/sdc5
Marking disk "/dev/sdc5" as an ASM disk [OK]
[Root @ node1 ~] #/Etc/init. d/oracleasm createdisk ASMDISK2/dev/sdc6
Marking disk "/dev/sdc6" as an ASM disk [OK]
[Root @ node1 ~] #/Etc/init. d/oracleasm createdisk ASMDISK3/dev/sdc7
Marking disk "/dev/sdc7" as an ASM disk [OK]
[Root @ node1 ~] #/Etc/init. d/oracleasm createdisk ASMDISK4/dev/sdc8
Marking disk "/dev/sdc8" as an ASM disk [OK]
[Root @ node1 ~] #/Etc/init. d/oracleasm createdisk ASMdisk5/dev/sdc9
Marking disk "/dev/sdc9" as an ASM disk [OK]
After creating an ASM disk, you can check whether the disk device has been generated in the/dev/oracleasm/disks/directory of the system. The command is as follows:
[Root @ node1 ~] # Ll/dev/oracleasm/disks/ASMDISK *
Brw-rw ---- 1 oracle oinstall 8, 21 Sep 10 23:40/dev/oracleasm/disks/ASMDISK1
Brw-rw ---- 1 oracle oinstall 8, 22 Sep 10 23:40/dev/oracleasm/disks/ASMDISK2
Brw-rw ---- 1 oracle oinstall 8, 23 Sep 10 23:36/dev/oracleasm/disks/ASMDISK3
Brw-rw ---- 1 oracle oinstall 8, 24 Sep 10/dev/oracleasm/disks/ASMDISK4
Brw-rw ---- 1 oracle oinstall 8, 25 Sep 10/dev/oracleasm/disks/ASMDISK5
You can also view the information as follows:
[Root @ node1 ~] # Service oracleasm listdisks
ASMDISK1
ASMDISK2
ASMDISK3
ASMDISK4
ASMDISK5
To delete an ASM disk, run the following command:
[Root @ node1 ~] #/Etc/init. d/oracleasm deletedisk ASMDISK5
Removing ASM disk "ASMdisk5" [OK]
In the RAC environment, pay attention to whether another node can find the corresponding ASM disk. Execute the following command to let another node obtain this change.
[Root @ node2 ~] #/Etc/init. d/oracleasm scandisks
At this point, the ASM disk has been created.
2) initialization parameters
To start an ASM instance, you only need the following parameters. These parameters can be used to automatically allocate and manage the memory of the ASM instance.
The following describes the initialization parameters of the ASM instance:
Instance_type = asm
Cluster_database = true
DB_UNIQUE_NAME = + ASM
ASM_POWER_LIMIT = 1
Large_pool_size = 60 M
Asm_diskgroups = 'Flash _ disk', 'arch _ disk', 'Data _ disk'
Asm_diskstring = '/dev/oracleasm/disks /*'
The meaning of each parameter is as follows:
 Instance_type: Specifies the instance type. for ASM instances, set it to ASM.
 Cluster_database: Specifies whether the cluster is a database cluster. true indicates that the cluster is an ASM cluster.
Mongodb_unique_name: Specifies the name of the ASM instance. The default value is + ASM.
 ASM_POWER_LIMIT, used to control the load balancing speed of data in ASM
 Large_pool_size: set the size of the large pool. Because the allocation unit ing of the ASM file is allocated from large_pool, large_pool_size must be at least 8 MB. The larger the size, the better.
 Asm_diskgroups: Specifies the ASM disk groups available when the instance is started. The ASM instance will automatically mount these disk groups at startup.
 Asm_diskstring, used to restrict the disk devices that can be used to create a disk group for an ASM instance. If this value is NULL, all disks visible to the ASM instance can become optional disks for creating a disk group.
3) create a password file
[Oracle @ node1 ~] $ Su-oracle
[Oracle @ node1 ~] $ Cd $ ORACLE_HOME/dbs
[Oracle @ node1 ~] $ Orapwd file = orapw + ASM password = oracle
4) create a directory structure
[Oracle @ node 1 ~] $ Su-oracle
[Oracle @ node1 ~] $ Cd $ ORACLE_HOME/dbs
[Oracle @ node1 ~] $ Mkdir-p $ ORALCE_BASE/admin/+ ASM/udump
[Oracle @ node1 ~] $ Mkdir-p $ ORALCE_BASE/admin/+ ASM/bdump
[Oracle @ node1 ~] $ Mkdir-p $ ORALCE_BASE/admin/+ ASM/adump
[Oracle @ node1 ~] $ Mkdir-p $ ORALCE_BASE/admin/+ ASM/cdump
2. Start the ASM instance
The CSS process is required for the ASM instance in both the RAC environment and the Single Instance environment. In the RAC environment, CSS has been run after CRS is started, but in the Single Instance environment, run the script as the root user to initialize the CSS service. Otherwise, the following error will be reported when starting the ASM instance:
ORA-29701: unable to connect to Cluster Manager
The initialization script is executed as follows:
[Root @ node1 ~] # $ ORACLE_HOME/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

Cleaning up Network socket directories
Setting up Network socket directories
Adding to inittab
Startup will be queued to init within 30 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
Cluster Synchronization Services is active on these nodes.
Node1
Cluster Synchronization Services is active on all the nodes.
Oracle CSS service is installed and running under init (1 M)
Then start the ASM instance:
[Oracle @ node1 ~] $ Export ORACLE_SID = + ASM
[Oracle @ node1 ~] $ Sqlplus/as sysdba
SQL> startup
ASM instance started
Total System Global Area 134217728 bytes
Fixed Size 1218124 bytes
Variable Size 107833780 bytes
ASM Cache 25165824 bytes
ORA-15110: no diskgroups mounted
Because the first time the ASM instance is started, the ASM disk group is not created. Therefore, it is normal to display the 15110 error.
3. Manage the ASM disk group
The ASM disk group is a group of disks managed in a unified manner as logical units. In the ASM instance, you can create and add new disk groups and modify existing disk groups, you can add or delete a disk or delete an existing disk group.
1) Add a disk group
SQL> create diskgroup FLASH_DISK external redundancy disk '/dev/oracleasm/disks/ASMDISK1 'name flashdisk;
Diskgroup created.
SQL> create diskgroup ARCH_DISK external redundancy disk '/dev/oracleasm/disks/ASMDISK2 'name archdisk1;
Diskgroup created.
SQL> create diskgroup DATA_DISK normal redundancy disk '/dev/oracleasm/disks/ASMDISK4 'name datadisk1,'/dev/oracleasm/disks/ASMDISK5 'name datadisk2;
Diskgroup created.
2) view the disk group status
SQL> select name, state from v $ asm_diskgroup;
NAME STATE
---------------------------------
FLASH_DISK MOUNTED
ARCH_DISK MOUNTED
DATA_DISK MOUNTED
3) uninstall the FLASH_DISK disk.
SQL> alter diskgroup FLASH_DISK dismount;
Diskgroup altered.
SQL> select name, state from v $ asm_diskgroup;
NAME STATE
--------------------------------------
FLASH_DISK DISMOUNTED
ARCH_DISK MOUNTED
DATA_DISK MOUNTED
4) mount the FLASH_DISK disk.
SQL> alter diskgroup FLASH_DISK mount;
Diskgroup altered.
SQL> select name, state from v $ asm_diskgroup;
NAME STATE
-----------------------------------------
FLASH_DISK MOUNTED
ARCH_DISK MOUNTED
DATA_DISK MOUNTED
5) Check the correspondence between the disk name and the bare device.
SQL> select name, path from v $ asm_disk_stat;
NAME PATH
---------------------------------------------------------
/Dev/oracleasm/disks/ASMDISK3
DATADISK2/dev/oracleasm/disks/ASMDISK5
DATADISK1/dev/oracleasm/disks/ASMDISK4
ARCHDISK1/dev/oracleasm/disks/ASMDISK2
FLASHDISK/dev/oracleasm/disks/ASMDISK1
6) view the available size of each disk group
SQL> select name, allocation_unit_size, total_mb from v $ asm_diskgroup;
NAME ALLOCATION_UNIT_SIZE TOTAL_MB
------------------------------------------------------------
FLASH_DISK 1048576 3815
ARCH_DISK 1048576 3815
DATA_DISK 1048576 954
7) Add a disk to the disk group
SQL> ALTER DISKGROUP ARCH_DISK ADD DISK '/dev/oracleasm/disks/ASMDISK3 'name ARCHDISK2;
Diskgroup altered.
View the available size of each disk group
SQL> select name, allocation_unit_size, total_mb from v $ asm_diskgroup;
NAME ALLOCATION_UNIT_SIZE TOTAL_MB
------------------------------------------------------------
FLASH_DISK 1048576 3815
ARCH_DISK 1048576 4292
DATA_DISK 1048576 954
SQL> select name, path from v $ asm_disk_stat;
NAME PATH
-----------------------------------------------------------
DATADISK2/dev/oracleasm/disks/ASMDISK5
DATADISK1/dev/oracleasm/disks/ASMDISK4
ARCHDISK2/dev/oracleasm/disks/ASMDISK3
ARCHDISK1/dev/oracleasm/disks/ASMDISK2
FLASHDISK/dev/oracleasm/disks/ASMDISK1
It can be seen that the size of the disk group ARCH_DISK has changed, indicating that the disk is successfully added.
8) delete a disk from the disk group:
SQL> ALTER DISKGROUP ARCH_DISK DROP DISK ARCHDISK2;
Diskgroup altered.
9) delete a disk group:
SQL> drop diskgroup FLASH_DISK;
Diskgroup dropped.
When a database uses an ASM disk, the disk cannot be detached or deleted. If the ASM instance goes down, the database instance that uses the ASM instance will also go down. In the RAC environment, before deleting a disk group, the ASM instance of other nodes must unmount the disk group to be deleted.
4. Close the ASM instance
The command to close the ASM instance is the same as the command to shut down the database instance, but the ASM instance can be shut down normally only when no database instance is connected to the ASM instance, if at least one database instance is connected to it, the following error is prompted:
ORA-15097: cannot shutdown asm instance with connected RDBMS instance
In this case, if you force the shutdown abort command on the ASM instance, the ASM instance will be closed and any database instance connected to it will be automatically closed. The following error is reported:
ORA-15064: communication failure with ASM instance
After the ASM instance is forcibly disabled, it is required to be restored at the next startup.
5. ASMCMD command
Oracle 10 Gb provides the ASMCMD command to manage data stored in the ASM disk. The following describes how to use the ASMCMD command.
When using the ASMCMD command, you must start the ASM instance and specify ORACLE_HOME and ORACLE_SID. For example:
[Oracle @ node-rac1 ~] $ Export ORACLE_SID = + ASM1
[Oracle @ node-rac1 ~] $ Asmcmd
ASMCMD>
You can also use "asmcmd-p" and add the "-p" parameter to display the current path.
The following are some available commands provided by ASMCMD. The new commands in oracle 11g include cp, md_backup, and md_restore.
ASMCMD>?
Commands:
--------
Help

Cd
Cp
Du
Find
Ls
Lsct
Lsdg
Mkalias
Mkdir
Pwd
Rm
Rmalias

Md_backup
Md_restore

Lsdsk
Remap
1) Switch Directories
ASMCMD> cd + DATA_DISK/RACDB
2) List Directory Information
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
Spfileracdb. ora
3) view disk space information
Run the "du DATAFILE" command of ASMCMD to view disk space information, as shown in figure 3.

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131229/1935402K3-2.png "/>

4) display the connection between ASM and database instances
Run the "lsct" command of ASMCMD to display the connection between the ASM and the database instance, as shown in figure 4.

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131229/1935406452-3.png "/>

5) create a directory
ASMCMD> mkdir test
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
Spfileracdb. ora
Test/
6) Copy Disk Files
Copy the ASM Disk File spfileracdb. or to the test directory:
ASMCMD> cp spfileracdb. ora test
Source + DATA_DISK/RACDB/spfileracdb. ora
Target + DATA_DISK/RACDB/test/spfileracdb. ora
Copying file (s )...
File, + DATA_DISK/racdb/test/spfileracdb. ora, copy committed.
ASMCMD> cd test
ASMCMD> ls
Spfileracdb. ora
Copy the UNDOTBS1.258.728340289 file of the ASM disk to a directory in the operating system:
ASMCMD> cp UNDOTBS1.258.728340289 UNDOTBS1.dbf
Source + DATA_DISK/RACDB/DATAFILE/UNDOTBS1.258.728340289
Target UNDOTBS1.dbf
Copying file (s )...
Copying file (s )...
Copying file (s )...
Copying file (s )...
Copying file (s )...
Copying file (s )...
File,/u01/oracle/product/11.0.6/rac_db/dbs/UNDOTBS1.dbf, copy committed.
7) back up the metadata of ASM
ASMCMD> md_backup-B/u01/oracle/datadisk. bak-g data_disk
Disk group to be backed up: DATA_DISK
In this way, the metadata of ASM is backed up to the file system. You can view the organization information of metadata by viewing the datadisk. bak file.
8) set an alias for the ASM Disk File
Run the command 5 to set the alias for the ASM disk file.

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131229/193540L02-4.png "/>

9) Search for files in the disk group
ASMCMD> find + DATA_DISK sys *
+ DATA_DISK/RACDB/DATAFILE/SYSAUX.257.728340287
+ DATA_DISK/RACDB/DATAFILE/SYSAUX. dbf
+ DATA_DISK/RACDB/DATAFILE/SYSTEM.256.728340285
+ DATA_DISK/RACDB/DATAFILE/SYSTEM. dbf
10) delete files in the disk group
ASMCMD> rm-rf test

 

This article from the "Technical Achievement dream" blog, please be sure to keep this source http://ixdba.blog.51cto.com/2895551/970801

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.