RAC_10g_Create_Manually_DB

download RAC_10g_Create_Manually_DB

of 4

Transcript of RAC_10g_Create_Manually_DB

  • 8/7/2019 RAC_10g_Create_Manually_DB

    1/4

    Create a 2 node RAC database manually

    Contributed by MartinWednesday, 20 February 2008Last Updated Wednesday, 20 February 2008

    Once again, dbca has failed me when I tried to create a second database - it did not detect my ASM instance(s). I had torevert to the good old scripted approach to create the second database but that was a welcome challenge. Actually, it'snot that difficult at all: a RAC database is just a single instance database which happens to run on multiple severs overshared storage. All you need is an extra redo log thread per additional instance and another undo tablespace (I knowthat this is oversimplified).

    The article assumes that you already have a clustered ASM installation up and running on Linux, so let's get going.

    Prepare the hosts

    My database is called RACDB, instances are RACDB1 and RACDB2. My hostnames are node1 and node2, it's aStandard Edition 2 node RAC install using ASM. My $ORACLE_BASE is /u01/app/oracle, $ORACLE_HOME thereforetranslates to /u01/app/oracle/product/10.2.0/db_1, I also have an $ASM_HOME in$ORACLE_BASE/product/10.2.0/asm_1 in addition to the Clusterware install.

    To allow for trace and dump file generation, go to $ORACLE_BASE and create the top level directory RACDB. Descendinto RACDB and create {a,b,c,u}dump, scripts, dpump and pfile directories. Repeat this for the second host as well.

    Initial init.ora

    Go to $ORACLE_HOME/dbs and create a simple init.ora file as follows:

    *.audit_file_dest='/u01/app/oracle/admin/RACDB/adump'*.background_dump_dest='/u01/app/oracle/admin/RACDB/bdump'

    *.cluster_database=false*.compatible='10.2.0.1.0'*.core_dump_dest='/u01/app/oracle/admin/RACDB/cdump'*.db_block_size=8192*.db_create_file_dest='+DATA'*.db_domain=''*.db_file_multiblock_read_count=16*.db_name='RACDB'*.db_recovery_file_dest='+DATA'*.db_recovery_file_dest_size=2G*.sga_target = 250M*.job_queue_processes=10*.log_checkpoints_to_alert=TRUE

    *.pga_aggregate_target=100M*.processes=500*.remote_listener='LISTENERS_RACDB'*.remote_login_passwordfile='exclusive'*.sessions=200*.undo_management='AUTO'*.undo_tablespace='UNDOTBS1'*.user_dump_dest='/u01/app/oracle/admin/RACDB/udump'RACDB1.instance_name = RACDB1

    Note the instance_name and db_name parameters. There is no reference to any RAC stuff here at all. Note also theabsence of "control_files". If you set it to a value, the create database statement will fail (Rember that ASM = OMF at

    large!)

    You also need to create a password file using orapw: orapw file=orapwRACDB1 password=sysRACDB.

    Network configuration

    the playground.de

    http://www.the-playground.de/joomla/ Powered by Joomla! Generated: 10 March, 2011, 20:43

  • 8/7/2019 RAC_10g_Create_Manually_DB

    2/4

    Now go to $ORACLE_HOME/network/admin and edit tnsnames.ora to add entries for your instances, the database andthe listeners. The listeners_racdb entry has to look like this:

    LISTENERS_RACDB = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))

    )

    I usually have an entry for the database on my server but don't bother with individual instances. Example:

    RACDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RACDB) (FAILOVER_MODE =

    (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5) ) ) )

    My application developers unfortunately don't make use of FCF/TAF or any more advance failover technology so this isok for my case.

    Start the instance and create the database

    Perform the finishing touches (add database instance to /etc/oratab and such), export the ORACLE_SID to RACDB1 andstart the instance:

    SQL> startup nomount

    Correct any errors until you don't have any more problems brining the instance to nomount state. Then run the createdatabase script, an example is given below:

    CREATE DATABASE RACDBMAXINSTANCES 8

    MAXLOGHISTORY 100MAXLOGFILES 64MAXLOGMEMBERS 3MAXDATAFILES 150DATAFILE SIZE 300M AUTOEXTEND ON NEXT 10240K MAXSIZE 1024M EXTENT MANAGEMENT LOCALSYSAUX DATAFILE SIZE 200M AUTOEXTEND ON NEXT 10240K MAXSIZE 800MDEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE SIZE 200M AUTOEXTEND ON NEXT 10M MAXSIZE 1000MEXTENT MANAGEMENT LOCALUNDO TABLESPACE UNDOTBS1 DATAFILE SIZE 200M AUTOEXTEND ON NEXT 10M MAXSIZE 1000MCHARACTER SET WE8ISO8859P1NATIONAL CHARACTER SET AL16UTF16LOGFILEGROUP 1 SIZE 50M,GROUP 2 SIZE 50M,GROUP 3 SIZE 50MUSER SYS IDENTIFIED BY "sysRACDB"USER SYSTEM IDENTIFIED BY "systemRACDB";

    the playground.de

    http://www.the-playground.de/joomla/ Powered by Joomla! Generated: 10 March, 2011, 20:43

  • 8/7/2019 RAC_10g_Create_Manually_DB

    3/4

    Note that I am using WE8ISO8859P1 character set - you might need something different. Any use of the "reuse" keywordwill cause the statement to fail.

    Once that command has finished, enter "show parameter control" to get the location of the control file and add this toyour init.ora file. If you don't, the database will not mount after the next bounce!

    The rest of the database creation is fairly standard - run at least catalog.sql, catproc.sql and catclust.sql. If you needJava or XMLDB consult the Oracle documentation on which scripts to run in addition.

    You should create a user tablespace and make it the database default tablespace to avoid objects "accidentally" storedin SYSTEM or SYSAUX.

    SQL> create tablespace users datafile 5m;

    Tablespace created

    SQL> Alter database default tablespace users;

    Database altered

    Turn single instance database to RACDB

    A few more steps are now necessary to convert your single instance to a RAC database. Edit initRACDB1.ora and addthe cluster parameters:

    *.cluster_database_instances=2*.cluster_database=trueRACDB1.instance_number=1RACDB2.instance_number=2RACDB2.thread=2RACDB1.thread=1

    *.undo_management='AUTO'RACDB1.undo_tablespace='UNDOTBS1'RACDB2.undo_tablespace='UNDOTBS2'RACDB1.instance_name = RACDB1RACDB1.instance_name = RACDB2

    This concludes the init.ora moification. In our case we have both information about the local and remote node in it, whichmakes it easy to copy the file across to node2 (and rename it to initRACDB2.ora). Now create the second undotablespace:

    SQL> Create undo tablespace undotbs2 datafile size 200M;

    Tablespace created

    Create the second instance's redo log thread:

    SQL> alter database add logfile thread 2 2 group 4 size 50M, 3 group 5 size 50M, 4 group 6 size 50M;

    Database altered

    Issue a "shutdown immediate" now, then start the instance. It should come up ok, you'll find additional information in thealert.log about RAC specifics. The important bit is the message stating that the database is mounted in shared mode(CLUSTER_DATABASE=TRUE).

    Now activate the 2nd redo log thread:

    SQL> alter database enable public thread 2;

    the playground.de

    http://www.the-playground.de/joomla/ Powered by Joomla! Generated: 10 March, 2011, 20:43

  • 8/7/2019 RAC_10g_Create_Manually_DB

    4/4

    Make sure you copy tnsnames.ora, initRACDB1.ora (as initRACDB2.ora), the password file over to the second node.Add RACDB2 to /etc/oratab as well. Then rename all *RACDB1* files to *RACDB2* if you haven't done so already.Finally start your second instance - and voila! You have a proper RAC database up and running now. Checkv$active_instances to make sure both appear in that view.

    Finishing touches

    I don't recmmend running RAC with pfiles, that never has been a good idea. Rather, I'd create the spfile in ASM:

    SQL> create spfile='+data/RACDB/spfileRACDB.ora' from pfile;

    Shut down both instances next and register the database and its instances with Clusterware as oracle:

    $> srvctl add databaese -d RACDB -o $ORACLE_HOME$> srvctl add instance -d RACDB -i RACDB1 -n node1$> srvctl add instance -d RACDB -i RACDB2 -n node2

    Check crs_stat to see if that worked and start the database:

    $> srvctl start database -d RACDB

    DONE!

    the playground.de

    http://www.the-playground.de/joomla/ Powered by Joomla! Generated: 10 March, 2011, 20:43