1.primary db(listener.ora)
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME=ge01pri)
(SID_NAME=ge01)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
)
)
2.primary(tnsname.ora)
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
GE01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ge01)
)
)
ge01pri =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.65.160)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ge01pri)
)
)
ge01standby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.65.170)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =ge01standby)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
3.primary(init.ora)
ge01.__db_cache_size=83886080
ge01.__java_pool_size=4194304
ge01.__large_pool_size=4194304
ge01.__shared_pool_size=71303168
ge01.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/adump'
*.background_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/product/10.2.0/oradata/ge01/control01.ctl','/u01/app/oracle/product/10.2.0/oradata/ge01/control02.ctl','/u01/app/oracle/product/10.2.0/oradata/ge01/control03.ctl'
*.core_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ge01'
*.db_recovery_file_dest='/u01/app/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ge01XDB)'
*.job_queue_processes=10
*.DB_UNIQUE_NAME='ge01pri'
*.log_archive_config='DG_CONFIG=(ge01pri,ge01standby)'
*.log_archive_dest_1='LOCATION=/u01/arch1/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ge01pri'
*.log_archive_dest_2='SERVICE=ge01standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ge01standby'
*.log_archive_dest_state_1=ENABLE
*.log_archive_dest_state_2=ENABLE
*.FAL_SERVER=ge01pri
*.FAL_CLIENT=ge01standby
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/udump'
*.STANDBY_FILE_MANAGEMENT=AUTO
4.standby (listener.ora)
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME=ge01standby)
(SID_NAME=ge01)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.65.170)(PORT = 1521))
)
)
5. standby(tnsname.ora)
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
GE01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ge01)
)
)
ge01pri =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.65.160)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =ge01pri)
)
)
ge01standby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.65.170)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =ge01standby)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
6.standby(init.ora)
ge01.__db_cache_size=83886080
ge01.__java_pool_size=4194304
ge01.__large_pool_size=4194304
ge01.__shared_pool_size=71303168
ge01.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/adump'
*.background_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/product/10.2.0/oradata/ge01/standby.ctl'
*.core_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ge01'
*.db_recovery_file_dest='/u01/app/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ge01XDB)'
*.job_queue_processes=10
*.DB_UNIQUE_NAME='ge01standby'
*.log_archive_config='DG_CONFIG=(ge01pri,ge01standby)'
*.log_archive_dest_1='LOCATION=/u01/arch1/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ge01standby'
*.log_archive_dest_2='SERVICE=ge01pri LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ge01pri'
*.log_archive_dest_state_1=ENABLE
*.log_archive_dest_state_2=ENABLE
*.FAL_SERVER=ge01standby
*.FAL_CLIENT=ge01pri
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/ge01/udump'
*.STANDBY_FILE_MANAGEMENT=AUTO
7.验证是否成功
sql>sqlplus sys/oracle@ge01pri as sysdba;
sql>sqlplus sys/oracle@ge01standby as sysdba;
---------------------------------------------------------------------------------------------------------------------------------------------
Oracle中DB_NAME,SID,DB_DOMAIN,SERVICE_NAME等之间的区别
Db_name:对一个数据库(Oracle database)的唯一标识。这种表示对于单个数据库是足够的,但是随着由多个数据库构成的分布式数据库的普及,这种命令数据库的方法给数据库的管理造成一定的负担,因为各个数据库的名字可能一样,造成管理上的混乱。为了解决这种情况,引入了Db_domain参数,这样在数据库的标识是由Db_name和Db_domain两个参数共同决定的,避免了因为数据库重名而造成管理上的混乱。这类似于互连网上的机器名的管理。我们将Db_name和Db_domain两个参数用’.’连接起来,表示一个数据库,并将该数据库的名称称为Global_name,即它扩展了Db_name。Db_name参数只能由字母、数字、’_’、’#’、’$’组成,而且最多8个字符。
Db_domain:定义一个数据库所在的域,该域的命名同互联网的’域’没有任何关系,只是数据库管理员为了更好的管理分布式数据库而根据实际情况决定的。当然为了管理方便,可以将其等于互联网的域。
Global_name:对一个数据库(Oracle database)的唯一标识,oracle建议用此种方法命令数据库。该值是在创建数据库是决定的,缺省值为Db_name. Db_domain。在以后对参数文件中Db_name与Db_domain参数的任何修改不影响Global_name的值,如果要修改Global_name,只能用ALTER DATABASE RENAME GLOBAL_NAME TO <db_name.db_domain>命令进行修改,然后修改相应参数。
Service_name:该参数是oracle8i新引进的。在8i以前,我们用SID来表示标识数据库的一个实例,但是在Oracle的并行环境中,一个数据库对应多个实例,这样就需要多个网络服务名,设置繁琐。为了方便并行环境中的设置,引进了Service_name参数,该参数对应一个数据库,而不是一个实例,而且该参数有许多其它的好处。该参数的缺省值为Db_name. Db_domain,即等于Global_name。一个数据库可以对应多个Service_name,以便实现更灵活的配置。该参数与SID没有直接关系,即不必Service name 必须与SID一样。
Instance_name:数据库实例名。用于和操作系统之间的联系,用于对外部连接时使用。在操作系统中要取得与数据库之间的交互,必须使用数据库实例名。例如,要和某一个数据库server连接,就必须知道其数据库实例名,只知道数据库名是没有用的,与数据库名不同,在数据安装或创建数据库之后,实例名可以被修改。数据库名与实例名之间的关系一般是一一对应关系,有一个数据库名就有一个实例名,如果在一个服务器中创建两个数据库,则有两个数据库名,两个数据库实例名,用两个标识确定一个数据库,用户和实例相连接。 但在8i、9i的并行服务器结构中,数据库与实例之间不存在一一对应关系,而是一对多关系,(一个数据库对应多个实例,同一时间内用户只一个实例相联系,当某一实例出现故障,其它实例自动服务,以保证数据库安全运行。)
Oracle_SID:操作系统环境变量。在实际中,对于数据库实例名的描述有时使用实例名(instance_name)参数,有时使用ORACLE_SID参数。这两个都是数据库实例名,它们有什么区别呢?(经常弄混)
(ORACLE_SID)
OS<---------------->; ORACLE 数据库 <--------(Instance_name(实例名))
上例表示实例名instance_name、ORACLE_SID与数据库及操作系统之间的关系,虽然这里列出的两个参数都是数据库实例名,但instance_name参数是ORACLE数据库的参数,此参数可以在参数文件中查询到,而ORACLE_SID参数则是操作系统环境变量。
操作系统环境变量ORACLE_SID用于和操作系统交互。也就是说,在操作系统中要想得到实例名,就必须使用ORACLE_SID。此参数与ORACLE_BASE、ORACLE_HOME等用法相同。在数据库安装之后,ORACLE_SID被用于定义数据库参数文件的名称。如:
$ORACLE_BASE/admin/DB_NAME/pfile/init$ORACLE_SID.ora。
---------------------------------------------------------------------------------------------------------------------------------------------
用RMAN进行DATAGUARD
1. 在主库中对整个数据库进行一个备份
RMAN>run{
allocate channel dev1 type disk;
backup
format '/u01/orabak/ge01_%d%s'
database;
release channel dev1;
};
2.scp /u01/orabak/ge01_12da [email protected]:/u01/orabak/;
3.在备库上进行恢复
SQL> startup nomount;
RMAN>connect target sys/oracle@gestandby;
RMAN>restore database;
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;