1、在vmware下配置ORACLE的RAC+DG我用虚拟机装了rac+ a Single Instance Physical Standby已经配置成功了。并能进行自动的切换.我在这里就先贴一个,其实这个帖子我在这个联接很久就发布.但是还有好多朋友没有发现(http:/ . p;extra=&page=6)一、系统的准备工作1对系统IP地址的规划oraclerac2 dbs$ cat /etc/hosts# Do not remove the following line, or various programs# that require network functionality will
2、fail.127.0.0.1 localhosts192.168.20.152rac2 -RAC2主库192.168.20.151rac1 -RAC1主库10.10.10.2 rac2-priv10.10.10.1 rac1-priv192.168.20.139pri-rac -DATAGUARD的备用库2安装配置好ORACLE9I RAC的数据库和数据库软件能正常的启动和关闭数据库 INST_ID INSTANCE_NUMBER INSTANCE_NAME HOST_NAME STATUS- - - - - 2 2 devdb2 rac2 OPEN 1 1 devdb1 rac1 OPENS
3、QL l1* select inst_id,instance_number,instance_name,host_name,status from gv$instanceSQL /COMP_IDCOMP_NAME VERSION STATUS- - - -CATALOGOracle9i Catalog Views 9.2.0.4.0VALIDCATPROCOracle9i Packages and Types 9.2.0.4.0VALIDOWM Oracle Workspace Manager 9.2.0.1.0VALIDJAVAVM JServer JAVA Virtual Machine
4、9.2.0.4.0VALIDXML Oracle XDK for Java 9.2.0.6.0VALIDCATJAVAOracle9i Java Packages 9.2.0.4.0VALIDORDIM Oracle interMedia 9.2.0.4.0VALIDSDO Spatial 9.2.0.4.0LOADEDCONTEXTOracle Text 9.2.0.4.0VALIDXDB Oracle XML Database 9.2.0.4.0VALIDWK Oracle Ultra Search 9.2.0.4.0VALIDCOMP_IDCOMP_NAME VERSION STATUS
5、- - - -ODM Oracle Data Mining 9.2.0.1.0LOADEDAPS OLAP Analytic Workspace 9.2.0.4.0LOADEDXOQ Oracle OLAP API 9.2.0.4.0LOADEDAMD OLAP Catalog 9.2.0.4.0VALIDRAC Oracle9i Real Application Clusters9.2.0.4.0VALID16 rows selected.SQL l1* select comp_id,comp_name,version,status from dba_registry3安装配置好备用库上的数
6、据库软件和配置好数据库的环境变量这些文件RAC1和RAC2上的环境变量oraclerac2 dbs$ cat /home/oracle/.bash_profile# .bash_profile# Get the aliases and functionsif -f /.bashrc ; then . /.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHPATH=$PATH:$HOME/bin #ORACLE_BASE 可以定位到盘阵上/data export ORACL
7、E_BASE=/home/oracle/product export ORACLE_HOME=/home/oracle/product/9.2.0.4 export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin export ORACLE_OWNER=oracle export ORACLE_SID=devdb2 export ORACLE_TERM=xterm export LD_ASSUME_KERNEL=2.4.19 export THREADS_FLAG=native export LD_LIBRARY_PATH=
8、$LD_LIBRARY_PATH:$ORACLE_HOME/lib export NLS_LANG=American_america.zhs16gbk # export NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data #export DISPLAY=:0 #export LANG=en_US #export GDM_LANG= en_US #export LC= en_US #export PATH export DBCA_RAW_CONFIG=/ho
9、me/oracle/DBCA_RAW_CONFIG.txtunset USERNAMEPRI-RAC备用库的环境变量oraclepri-rac devdb$ cat /home/oracle/.bash_profile# .bash_profile# Get the aliases and functionsif -f /.bashrc ; then . /.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHPATH=$PATH:$HOME/bin #ORACLE_BAS
10、E 可以定位到盘阵上/data export ORACLE_BASE=/home/oracle/product export ORACLE_HOME=/home/oracle/product/9.2.0.4 export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin export ORACLE_OWNER=oracle export ORACLE_SID=devdb export ORACLE_TERM=xterm export LD_ASSUME_KERNEL=2.4.19 export THREADS_FLAG=nat
11、ive export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib export NLS_LANG=American_america.zhs16gbk # export NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data #export DISPLAY=:0 #export LANG=en_US #export GDM_LANG= en_US #export LC= en_US #export PATH
12、 export DBCA_RAW_CONFIG=/home/oracle/DBCA_RAW_CONFIG.txtunset USERNAME4安装配置RAC1,RAC2,PRI-RAC主机网络listener.ora文件和tnsnames.ora文件在RAC1和RAC2上的listener.ora和tnsnames.ora文件这个是RAC2的listener.ora文件内容oraclerac2 admin$ cat listener.ora# LISTENER.ORA.RAC2 Network Configuration File: /home/oracle/product/9.2.0.4/n
13、etwork/admin/listener.ora.rac2# Generated by Oracle configuration tools.LISTENER =(DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521) ) )SID_LIST_LISTENER =(SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /home/oracle/product/9.2.0.4
14、) (PROGRAM = extproc) ) (SID_DESC = (ORACLE_HOME = /home/oracle/product/9.2.0.4) (SID_NAME = devdb2) )这个是RAC1上的listener.ora文件内容oraclerac1 admin$ cat listener.ora # LISTENER.ORA.RAC1 Network Configuration File: /home/oracle/product/9.2.0.4/network/admin/listener.ora.rac1# Generated by Oracle configur
15、ation tools.LISTENER =(DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521) ) )SID_LIST_LISTENER =(SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /home/oracle/product/9.2.0.4) (PROGRAM = extproc) ) (SID_DESC = (ORACLE_HOME = /home/ora
16、cle/product/9.2.0.4) (SID_NAME = devdb1) )这个是RAC2的 tnsnames.ora文件内容oraclerac2 admin$ cat tnsnames.ora# TNSNAMES.ORA Network Configuration File: /home/oracle/product/9.2.0.4/network/admin/tnsnames.ora# Generated by Oracle configuration tools.LISTENER_DEVDB1 =(ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(P
17、ORT = 1521)INST1_HTTP =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521) ) (CONNECT_DATA = (SERVER = SHARED) (SERVICE_NAME = MODOSE) (PRESENTATION = http:/HRService) )DEVDB2 =(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521) (CONNECT_DATA = (SERV
18、ICE_NAME = devdb) (INSTANCE_NAME = devdb2) )DEVDB1 =(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = devdb) (INSTANCE_NAME = devdb1) )DEVDB =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521) (ADDRESS = (PROTOCOL =
19、 TCP)(HOST = rac2)(PORT = 1521) (LOAD_BALANCE = yes) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = devdb) )LISTENERS_DEVDB =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521) (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521)LISTENER_DEVDB2 =(ADDRESS = (PROTOCOL = TCP)
20、(HOST = rac2)(PORT = 1521)STANDBY =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.139)(PORT = 1521) ) (CONNECT_DATA = (SERVICE_NAME = devdb) )这个两个TNS是我们主要使用的DEVDB是做为主库的。Standby是作为备用库的TNS这个是RAC1上的TNSNAMES.ORA文件的内容oraclerac1 admin$ cat tnsnames.ora# TNSNAMES.ORA Network C
21、onfiguration File: /home/oracle/product/9.2.0.4/network/admin/tnsnames.ora# Generated by Oracle configuration tools.LISTENER_DEVDB1 =(ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521)INST1_HTTP =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521) ) (CONNECT_DATA =
22、 (SERVER = SHARED) (SERVICE_NAME = MODOSE) (PRESENTATION = http:/HRService) )DEVDB2 =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521) ) (CONNECT_DATA = (SERVICE_NAME = devdb) (INSTANCE_NAME = devdb2) )DEVDB1 =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = T
23、CP)(HOST = rac1)(PORT = 1521) ) (CONNECT_DATA = (SERVICE_NAME = devdb) (INSTANCE_NAME = devdb1) )STANDBY =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.139)(PORT = 1521) ) (CONNECT_DATA = (SERVICE_NAME = devdb) )DEVDB =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCO
24、L = TCP)(HOST = rac1)(PORT = 1521) (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521) (LOAD_BALANCE = yes) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = devdb) )LISTENERS_DEVDB =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521) (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)
25、(PORT = 1521)LISTENER_DEVDB2 =(ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521)以上在配置好要进行相应的测试,也测试能否连同各个数据库这个pri-rac备用库的listener.ora和tnsnames.ora文件内容oraclepri-rac admin$ cat listener.ora# LISTENER.ORA Network Configuration File: /home/oracle/product/9.2.0.4/network/admin/listener.ora# Generated b
26、y Oracle configuration tools.LISTENER =(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.139)(PORT = 1521)SID_LIST_LISTENER =(SID_LIST = (SID_DESC = (GLOBAL_DBNAME = devdb) (ORACLE_HOME = /home/oracle/product/9.2.0.4) (SID_NAME = devdb) )以下是tnsname.ora文件内容oraclepri-rac admin$ cat tnsnames
27、.ora# TNSNAMES.ORA Network Configuration File: /home/oracle/product/9.2.0.4/network/admin/tnsnames.ora# Generated by Oracle configuration tools.INST1_HTTP =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.139)(PORT = 1521) ) (CONNECT_DATA = (SERVER = SHARED) (SERVICE_NAME
28、 = MODOSE) (PRESENTATION = http:/HRService) )STANDBY =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.139)(PORT = 1521) ) (CONNECT_DATA = (SERVICE_NAME = devdb) )DEVDB =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.151)(PORT = 1521) (ADDRES
29、S = (PROTOCOL = TCP)(HOST = 192.168.20.152)(PORT = 1521) (LOAD_BALANCE = yes) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = devdb) )以上在配置好要进行相应的测试,也测试能否连同各个数据库5安装和配置pri-rac上的参数文件initdevdb.ora文件安装和配置pri-rac上的参数文件initdevdb.ora文件,并配置好相应的密码文件和dataguard的相关参数。其实initdevdb.ora文件可以从RAC1或者RAC2的机器上COP
30、Y过来,然后再把带有RAC的项目去掉$sqlpluc /nologSQLconn / as sysdbaSQLcreate pfile from spfile;scp $ORACLE_HOME/dbs/initdevdb1.ora pri-ra:$ORACLE_HOME/dbs再修改相应的的参数,以下是pri-rac上的initdevdb.ora文件内容:oraclepri-rac dbs$ cat initdevdb.ora*.aq_tm_processes=1*.background_dump_dest=/home/oracle/product/admin/devdb/bdump*.com
31、patible=9.2.0.0.0*.control_files=/home/oracle/product/oradata/devdb/control01.ctl,/home/oracle/product/oradata/devdb/control02.ctl,/home/oracle/product/oradata/devdb/control03.ctl*.core_dump_dest=/home/oracle/product/admin/devdb/cdump*.db_block_size=8192*.db_cache_size=33554432*.db_domain=*.db_file_
32、multiblock_read_count=16*.db_name=devdb*.dispatchers=(PROTOCOL=TCP) (SERVICE=devdbXDB)*.fast_start_mttr_target=300*.hash_join_enabled=TRUE*.instance_name=devdb*.java_pool_size=20971520*.job_queue_processes=10*.large_pool_size=33554432*.open_cursors=300*.pga_aggregate_target=25165824*.processes=150*.
33、query_rewrite_enabled=FALSE*.remote_login_passwordfile=EXCLUSIVE*.shared_pool_size=33554432*.sort_area_size=524288*.star_transformation_enabled=FALSE*.timed_statistics=TRUE*.undo_management=AUTO*.undo_retention=10800*.undo_tablespace=UNDOTBS1*.user_dump_dest=/home/oracle/product/admin/devdb/udump# D
34、ATA GURAD备用库的参数配置#*.aq_tm_processes=1#*.compatible=9.2.0.0.0*.log_archive_start=true*.log_archive_dest_1=LOCATION=/home/oracle/archive/primary-本地归档的归档日志位置*.log_archive_dest_2=service=devdb mandatory reopen=60 -传输到备用库上的归档日志位置*.log_archive_format=%t_%s.dbf*.db_file_name_convert=/home/oracle/product/or
35、adata/devdb/,/home/oracle/product/oradata/devdb/*.log_file_name_convert=/home/oracle/product/oradata/devdb/,/home/oracle/product/oradata/devdb/*.utl_file_dir=/home/oracle*.standby_archive_dest=/home/oracle/archive/primary -备用库上的归档日志目录*.standby_file_management=AUTO*.fal_server=devdb*.fal_client=stand
36、by在这里一定要注意db_file_name_convert,log_file_name_convert参数的值配置,在RMAN恢复他的时候,要采用,如且一定要保证配置的正确。同时也要创建好相应的目录$ORACLE_BASE/admin/devdb/bdump cdump这些相应的目录,如果感觉难创建可以直接从RAC1或者RAC2上COPY过来,然后修改下alter_devdb.log文件,就OK了。6配置NFS在PRI-RAC上配置修改pri-rac备库机器上的/etc/exports文件oraclepri-rac dbs$ cat /etc/exports/home/oracle/prod
37、uct/backup *(async,rw)添加此行。启动portmap service portmap start启动NFS service NFS startrootpri-rac # service nfs restart关闭 NFS mountd:失败关闭 NFS 守护进程:失败关闭 NFS quotas:失败关闭 NFS 服务: 失败启动 NFS 服务: 确定关掉 NFS 配额:确定启动 NFS 守护进程:确定启动 NFS mountd:确定在RAC1和RAC2的机器上分别挂载上此目录rootrac2 bin# mount -t nfs -o rw,noac,hard,timeo=6
38、00,wsize=32768,rsize=32768,vers=3,proto=tcp192.168.20.139:/home/oracle/product/backup /home/oracle/product/backuprootrac2 bin# df -hFilesystem 容量已用 可用 已用% 挂载点/dev/sda1 13G5.5G6.7G45% /none 345M 0345M 0% /dev/shm192.168.20.139:/home/oracle/product/backup 13G7.5G4.8G61% /home/oracle/product/backup上面此目
39、录要在RAC1和RAC2上分别挂载上。到此准备工作已经完成。下面要开始备份RAC库,以及他的控制文件和日志文件二、为physical standby库备份RAC数据库在做好以上这些准备后,我们就可以开始备份RAC数据库了。全库备份RAC数据库以及控制文件run allocate channel c1 device type disk format /home/oracle/product/backup/full_%U_%I.dbf connect sys/stu01devdb1;allocate channel c2 device type disk format /home/oracle/p
40、roduct/backup/full_%U_%I.dbf connect sys/stu01devdb2;backup database plus archivelog delete all input;backup current controlfile for standby;release channel c1;RMAN run 2 allocate channel c1 device type disk format /home/oracle/product/backup/full_%U_%I.dbf connectsys/stu01devdb1;3 allocate channel c2 device type disk format /home/oracle/product/backup/full_%U_%I.dbf connectsys/stu01devdb2;4 backup database ;5 re