Build a virtual ASM environment in Windows to create an Oracle 10 Gb Database

Source: Internet
Author: User

This article consists of four parts: 1. Create a virtual ASM disk, 2. Create a database on the virtual ASM disk, 3. asmcmd tool, and 4. Add a disk for the disk group.

Part 1: create a virtual ASM Disk(In this example, Oracle is installed on D: \ oracle \ product \ 10.2.0)

1. Use asmtool provided by Oracle to create an ASM virtual disk. The asmtool is in the D: \ oracle \ product \ 10.2.0 \ db_1 \ bin directory,

Run the following command in cmd:

Asmtool-create D: \ oracle \ asmdisk \ disk1 1024

Asmtool-create D: \ oracle \ asmdisk \ disk2 1024.

Asmtool-create D: \ oracle \ asmdisk \ disk3 1024

2. Configure CSS (cluster synchronization services)
CSS is mainly used to synchronize the ASM instance and its client, that is, the database instance. It can be completed by the localconfig command that comes with Oracle. The localconfig command is also located in the Directory D: \ oracle \ product \ 10.2.0 \ db_1 \ bin.
Run
Localconfig add

Output:
Step 1: creating new OCR Repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'zhangrp ', privgrp ''..
Operation successful.
Step 2: creating new CSS Service
Successfully created local CSS Service
Successfully added CSS to home

After the configuration is complete, the following entry appears in Windows Services:


-- Check the status of the CSS daemon.

D: Oracle10g> crsctl check cssd
CSS appears healthy
D: Oracle10g>

Note: If you want to delete the CSS service later, you only need to execute the following command in Windows command:

Localconfig Delete

3. Create the + ASM folder under D: \ oracle \ product \ 10.2.0 \ admin, and create three folders: bdump, cdump, and udump:

D: \ oracle \ product \ 10.2.0 \ admin \ + ASM \ bdump

D: \ oracle \ product \ 10.2.0 \ admin \ + ASM \ cump

D: \ oracle \ product \ 10.2.0 \ admin \ + ASM \ udump

4. Create the file init + ASM. ora in the D: \ oracle \ product \ 10.2.0 \ db_1 \ database \ folder.

D: \ oracle \ product \ 10.2.0 \ db_1 \ database \ init + ASM. ora

The file content is as follows:

*. _ Asm_allow_only_raw_disks = false
*. Asm_diskstring = 'd: \ oracle \ asmdisk \*'
*. User_dump_dest = 'd: \ oracle \ product \ 10.2.0 \ admin \ + ASM \ udump'
*. Core_dump_dest = 'd: \ oracle \ product \ 10.2.0 \ admin \ + ASM \ cdump'
*. Background_dump_dest = 'd: \ oracle \ product \ 10.2.0 \ admin \ + ASM \ bdump'
*. Instance_type = 'asm'
*. Large_pool_size = 12 m
*. Db_unique_name = '+ ASM'
*. Asm_power_limit = 1
*. Remote_login_passwordfile = 'shared'

4. Create a service for the ASM Virtual Disk instance,

Oradim-New-asmsid + ASM-startmode auto-srvcstart system-pfile 'd: \ oracle \ product \ 10.2.0 \ db_1 \ database \ init + ASM. ora

A service named oracleasmservice + ASM will be added to the Windows service.

Note: If you want to delete this ASM instance later, you only need to execute the following command in Windows command:

Oradim-delete-asmsid + ASM


5. Connect to the ASM instance. For OS authentication,

Note that you must set oracle_sid = just created the ASM instance
D: \> set oracle_sid = + ASM

Directly use sqlplus/As sysdba. If not, change to OS authentication or create a pwd File:

Orapwd file = D: \ oracle \ product \ 10.2.0 \ db_1 \ database \ PWD + ASM. ora Password = sys entries = 5

Restart the services of oracleasmservice + ASM,

D: \> sqlplus sys/sys as sysdba

Connected to an idle instance.
SQL> startup
ASM instance started

Total system global area 83886080 bytes
Fixed size 1295152 bytes
Variable Size 57425104 bytes
ASM cache 25165824 bytesORA-15110: No diskgroups mounted
SQL>

Note: Here is an error message for the ORA-15110, because it is the first time the ASM instance is started and diskgroup has not been created, it is normal to display the 15110 error, ignore this error, continue with the subsequent steps.

View the instance status:

SQL> select host_name, instance_name, version, status from V $ instance;
Host_name instance_name version status
---------------------------------------------------------------------------
PC-625040 + ASM 10.2.0.1.0 started

(The ASM instance will only be in the started status and cannot be open as the normal dB instance)

At this time, you can view the identified Disk:

SQL> Col path format A30;
SQL> select path, mount_status from V $ asm_disk order by disk_number;

Path mount_s
-------------------------------------
D: \ oracle \ asmdisk \ disk1 closed
D: \ oracle \ asmdisk \ disk2 closed
D: \ oracle \ asmdisk \ disk3 closed

6. Create an ASM disk group and create two disk groups.

A. Create a disk group consisting of two M disks and adopt 2-way redundancy.

SQL> Create diskgroup DG1
2 normal Redundancy
3 failgroup dg1_0000 disk 'd: \ oracle \ asmdisk \ disk1'
4 failgroup dg1_0001 disk 'd: \ oracle \ asmdisk \ disk2 ';

B, -- flash_data, a disk used for flash, consists of 1 m disks and adopts external redundancy.

SQL> Create diskgroup dg2
2 external Redundancy
3 disk 'd: \ oracle \ asmdisk \ disk3 ';

(Here I only use one disk, and I should also use multiple disks)

You can also use dbca to create

1,


2. The screenshot here is not available in "select Member disks" because it is finished. Before it is done, D: \ oracle \ asmdisk \ disk1 should be listed normally, disk2, disk3

Select disk1, disk2, the group name is DG1, and redundancy creates a group for normal.

Select disk3, the group name is dg2, and redundancy creates a group for external.

Check the status after the disk group is created:

SQL> select path, mount_status from V $ asm_disk order by disk_number;
Path mount_s
-------------------------------------
D: \ oracle \ asmdisk \ disk1 cached
D: \ oracle \ asmdisk \ disk3 cached
D: \ oracle \ asmdisk \ disk2 cached

7. -- restart the ASM instance

SQL> shatdown immediate
SQL> startup
ASM instance started
Total system global area 83886080 bytes
Fixed size 1295152 bytes
Variable Size 57425104 bytes
ASM cache 25165824 bytes
ASM diskgroups mounted
SQL>
The "ORA-15110: No diskgroups mounted" error message is gone.
-- Generate spfile
SQL> Create spfile from pfile;
File Created.

8, -- configure listener. ora and tnsnames. ora to connect to your ASM instance through tools such as PL/SQL developer.

Add

(Sid_desc =
(Global_dbname = + asmdb)
(ORACLE_HOME = D: \ oracle \ product \ 10.2.0 \ db_1)
(Sid_name = + ASM)
)

Add

ASM =
(Description =
(Address = (Protocol = TCP) (host = NBK-DAL-625040.ap.bt.com) (Port = 1521 ))
(CONNECT_DATA =
(Server = dedicated)
(SERVICE_NAME = + asmdb)
)
)

In this way, tools such as toad and PL/SQL developer can also access the ASM instance through TNS.

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

Part 2: Create a database on the ASM Disk

After the ASM disk is created, use dbca to create a database. The following lists the locations that are different from those that are used to create a conventional database.

1. Select a custom database

2. The SID is written as asmdb and no EM is created. When selecting the storage type:

3. Select the disk group to be installed:

4. Specify the disk group DG1 of the database file

5. Specify the disk group for flash recovery: dg2

6. To save space, do not install the following components.

7. Set the SGA size to an appropriate value of 300 m, PGA 40 m, and undo file of 100 m. Adjust the size according to your needs.

Then finish.

After creation

C: \> set oracle_sid = asmdb

Note that it is different from the starting ASM instance.
Connect to the DB instance, c: \> sqlplus sys/sys as sysdba

Start the database, SQL> startup

The subsequent operations are the same as normal databases. Note that the ASM instance must be started when the database instance is started.

An error ORA-06553: PLS-213: Package standard not accessible was encountered during creation

Solution:

1. SQL> alter package standard compile;

2. SQL> alter package dbms_standard compile;

3, @ oracle_base \ ORACLE_HOME \ RDBMS \ admin \ utlrp. SQL

Step 3 will take a long time,

You can select count (*) from OBJ $ where status in (4, 5, 6); view, the number should keep getting smaller.

Part 3: asmcmd.

Asmcmd also needs to connect to the ASM instance

1. Set the ORACLE_HOME environment variable. If the Registry has one, set it as well.

C: \> set ORACLE_HOME = D: \ oracle \ product \ 10.2.0 \ db_1

2. Set the oralce_sid environment variable. If the oracle_sid of the registry is not an ASM instance

C: \> asmcmd
ORA-12560: TNS: protocol adapter error (DBD error: ociserverattach)
C: \> set oracle_sid = + ASM

3. Operate asmcmd

C: \> asmcm
Asmcmd>

Help to view help. Provided commands and Unix Commands

Asmcmd> pwd
+

Asmcmd> ls
DG1/
Dg2/

Asmcmd> Cd asmdb

Asmcmd> ls-l
Type redund striped time sys name
Y controlfile/
Y datafile/
Y onlinelog/
Y parameterfile/
Y tempfile/
N control01.ctl => + DG1/asmdb/controlfile/current.256.772306553
N control02.ctl => + DG1/asmdb/controlfile/current.257.772306557
N control03.ctl => + DG1/asmdb/controlfile/current.258.772306561
N redo01.log => + DG1/asmdb/onlinelog/group_1.259.772306567
N redo02.log => + DG1/asmdb/onlinelog/group_2.260.772306579
N redo03.log => + DG1/asmdb/onlinelog/group_3.261.772306591
N spfileasmdb. ora => + DG1/asmdb/parameterfile/spfile.267.772307483

The preceding figure shows the structure of the database file. The following figure shows the data file.

Asmcmd> Cd datafile
Asmcmd> ls-l
Type redund striped time sys name
Datafile mirror coarse Jan 11 21:00:00 y sysaux.264.772306671
Datafile mirror coarse Jan 11 21:00:00 y system.262.772306615
Datafile mirror coarse Jan 11 21:00:00 y undotbs1.263.772306657
Datafile mirror coarse Jan 11 21:00:00 y users.266.772306717

The CSS (cluster synchronization services) service configured in the first part provides services for ASM instances (+ ASM) and asmdb database instances.

Synchronizes database information to the disk managed by ASM.

Asmcmd> lsct
Db_name status software_version compatible_version instance_name
+ ASM connected 10.2.0.1.0 10.2.0.0.0 + ASM
Asmdb connected 10.2.0.1.0 10.2.0.1.0 asmdb

Asmcmd> Find + cont *
+ DG1/asmdb/controlfile/
+ DG1/asmdb/control01.ctl
+ DG1/asmdb/control02.ctl
+ DG1/asmdb/control03.ctl

Mkalias can create an alias for a file, which is a file name that we are familiar with in the file system. For example, system.262.772306615 does not look as familiar as system01.dbf. After modification, you can point the data file to alias.

Asmcmd> mkalias system.262.772306615 system01.dbf

SQL> startup Mount

Modify Database

SQL> alter database rename File '+ DG1/asmdb/datafile/system.262.772306615' to '+ DG1/asmdb/datafile/system01.dbf ';

SQL> alter database open;

SQL> select file_name from dba_data_files;
File_name
-------------------------------------------
+ DG1/asmdb/datafile/system01.dbf
+ DG1/asmdb/datafile/undotbs1.263.772306657
+ DG1/asmdb/datafile/sysaux.264.772306671
+ DG1/asmdb/datafile/users.266.772306717

Part 4: Add disks to a disk group

1. Create two ASM Disks

D: \> asmtool-create D: \ oracle \ asmdisk \ disk4 200

D: \> asmtool-create D: \ oracle \ asmdisk \ disk5 200

2. Connect to the ASM instance,

SQL> Col path format A30;
SQL> Col name format A20
SQL> Col failgroup format A20;
SQL> select group_number, mount_status, name, failgroup, path from V $ asm_disk;

Group_number mount_s name failgroup path
--------------------------------------------------------------------------------------
0 closed D: \ oracle \ asmdisk \ disk4
0 closed D: \ oracle \ asmdisk \ disk5
1 cached dg00000000 dg00000000 D: \ oracle \ asmdisk \ disk1
1 cached dg00000001 dg00000001 D: \ oracle \ asmdisk \ disk2
2 cached dg2_0000 dg2_0000 D: \ oracle \ asmdisk \ disk3

We can see that the two new disks have been identified.

3. Add disk disk4 to dg1_0000
SQL> alter diskgroup DG1 add failgroup dg1_0000 disk 'd: \ oracle \ asmdisk \ disk4 ';
Diskgroup altered.

SQL> alter diskgroup DG1 add failgroup dg1_0001 disk 'd: \ oracle \ asmdisk \ disk5
Diskgroup altered.

SQL> select group_number, mount_status, name, failgroup, path from V $ asm_disk;

Group_number mount_s name failgroup path
-----------------------------------------------------------------------------------
1 cached dg00000000 dg00000000 D: \ oracle \ asmdisk \ disk1
1 cached dg00000001 dg00000001 D: \ oracle \ asmdisk \ disk2
2 cached dg2_0000 dg2_0000 D: \ oracle \ asmdisk \ disk3
1 cached dg00000002 dg00000000 D: \ oracle \ asmdisk \ disk4
1 cached dg00000003 dg00000001 D: \ oracle \ asmdisk \ disk5

In this way, the capacity of the disk group DG1 is increased.

More details: http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_1006.htm#SQLRF01113

This article is based on Thomas Zhang's article in itpub and warehouse's OCP.

Http://tomszrp.itpub.net/post/11835/487501

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.