你们知道什么是standby安装么,这个非常高深的运用技术将由我来非常讲解,standby安装NB在哪呢,下面我来进入讲述standby安装的无限领域与Primary和standby安装oracle 10G。
standby安装步骤。
Primary设置
1)修改主库属性
我这里选用192.168.1.79作为primary。[oracle@centos79 ~]$ sqlplus /nolog SQL*Plus: Release 10.2.0.1.0 - Production on Fri Aug 14 13:45:14 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved.SQL> conn / as sysdbaConnected.SQL> alter database force logging;alter database force logging ERROR at line 1:ORA-12920: database is already in force logging mode之前改过了。SQL>
2)修改数据库为归档模式
SQL> archive log list)Database log mode) Archive Mode Automatic archival))) EnabledArchive destination)))USE_DB_RECOVERY_FILE_DESTOldest online log sequence) 3 Next log sequence to archive 5 Current log sequence))5 SQL>现在数据库已经运行在归档模式下。
3)创建密码文件
同一个Dataguard中所有数据库必须拥有独立的密码文件,并且保证sys用户拥有相同密码来保证redo的传输。[oracle@centos79 dbs]$ orapwd file='/usr/local/ora10/product/10.2.0/db_1/dbs/orapworcl.ora' password=system entries=10
4)standby配置oracle 10G
Su到root用户在/home下创建存放standby redo log目录SQL> shutdown immediateSQL> startup mountAlter database add standby logfile group 4('/home/oracle/oracle/dgredo/standby_redo4a.log','/home/oracle/oracle/dgredo/standby_redo4b.log') size 50M;
5)创建primary数据库初始化参数
通过修改创建的pfile,然后重新生成spfile,SQL> create pfile from spfile;File created.SQL>备份一份pfile.cp /usr/local/ora10/product/10.2.0/db_1/dbs/initorcl.ora /home/oracle/oracle/
6)设置主库参数文件
*.db_name='orcl'
*.DB_UNIQUE_NAME='primary'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='location=/usr/local/ora10/flash_recovery_area/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES)' DB_UNIQUE_NAME='primary'
*.log_archive_dest_2='SERVICE=orcl76 arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.remote_login_passwordfile='EXCLUSIVE'#standby角色参数
*.FAL_SERVER=orcl76
*.FAL_CLIENT=orcl79
DB_FILE_NAME_CONVERT=’oradata/orcl’,’oradata/orcl’
LOG_FILE_NAME_CONVERT=’oradata/orcl’,’oradata/orcl’
.standby_FILE_MANAGEMENT=AUTO
7)用pfile启动数据库
SQL> Shutdown immediate
SQL> startup pfile='/usr/local/ora10/product/10.2.0/db_1/dbs/initorcl.ora'
SQL> create spfile from pfile='/usr/local/ora10/product/10.2.0/db_1/dbs/initorcl.ora';
SQL> shutdown immediate
SQL> startup
8)修改listener.ora
[oracle@centos79 admin]$ cat listener.ora
# listener.ora Network Configuration File: /usr/local/ora10/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 = /usr/local/ora10/product/10.2.0/db_1)
(PROGRAM = extproc)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = centos79)(PORT = 1522))
LISTENER1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = centos79)(PORT = 1523))
9)修改tnsnames.ora文件
[oracle@centos79 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /usr/local/ora10/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = centos79)(PORT = 1522)
ORCL79 =
(DESCRIPTION =)
(ADDRESS = (PROTOCOL = TCP)(HOST = centos79)(PORT = 1522)
(ADDRESS = (PROTOCOL = TCP)(HOST = centos76)(PORT = 1522)
(CONNECT_DATA =)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
ORCL76 =
(DESCRIPTION =)
(ADDRESS = (PROTOCOL = TCP)(HOST = centos76)(PORT = 1521)
(ADDRESS = (PROTOCOL = TCP)(HOST = centos79)(PORT = 1521)
(CONNECT_DATA =)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
ORCL254 =
(DESCRIPTION =)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.254)(PORT = 1521)
(CONNECT_DATA =)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =)
(ADDRESS_LIST =)
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)
(CONNECT_DATA =)
(SID = PLSExtProc)
(PRESENTATION = RO)
[oracle@centos79 admin]$
确保tnsping两台机器都能 ping通
10)备份数据库
RMAN> backup full database format '/home/oracle/oracle/backup_%T_%s_%p.bak';
11)创建standby数据控制文件
SQL> alter database create standby controlfile as '/home/oracle/oracle/dgredo/standby.ctl';
Database altered.
SQL>
12)拷贝密码文件,数据文件,standby controlfile到备机
[oracle@centos79 orcl]$ scp /home/oracle/oracle/dgredo/standby.ctl root@192.168.1.76:/usr/local/ora10/oradata/orcl/
standby安装配置
1)创建对应目录
$ORACLE_BASE下oradata,admin,flash_recovery_area目录
2)拷贝文件,包括数据文件,standby controlfile,全库备份文件,参数文件,监听和服务文件
[root@centos79 dbs]# scp initorcl.ora orapworcl.ora oracle@192.168.1.76:/usr/local/ora10/product/10.2.0/db_1/dbs/
root@centos79 admin]# scp listener.ora sqlnet.ora tnsnames.ora oracle@192.168.1.76:/usr/local/ora10/product/10.2.0/db_1/network/admin/
3)创建控制文件
[oracle@centos76 orcl]$ mv standby.ctl /usr/local/ora10/oradata/orcl/control01.ctl
[oracle@centos76 orcl]$ cp control01.ctl /usr/local/ora10/oradata/orcl/control02.ctl
[oracle@centos76 orcl]$ cp control01.ctl /usr/local/ora10/oradata/orcl/control03.ctl
[oracle@centos76 orcl]$
4)配置listener,tnsname
Lintener.ora文件如下。[oracle@centos76 admin]$ cat listener.ora
# listener.ora Network Configuration File: /usr/local/ora10/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 = /usr/local/ora10/product/10.2.0/db_1)
(PROGRAM = extproc)
LISTENER =
(DESCRIPTION_LIST =)
(DESCRIPTION =)
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)
(ADDRESS = (PROTOCOL = TCP)(HOST = centos76)(PORT = 1521)
LISTENER1 =
(DESCRIPTION_LIST =)
(DESCRIPTION =)
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = centos76)(PORT = 1522)
TNSNAMES.ORA文件如下
[oracle@centos76 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /usr/local/ora10/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =(ADDRESS = (PROTOCOL = TCP)(HOST = centos79)(PORT = 1522))
ORCL79 =(DESCRIPTION =)
(ADDRESS = (PROTOCOL = TCP)(HOST = centos79)(PORT = 1521))
(CONNECT_DATA =)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
ORCL76 =
(DESCRIPTION =)
(ADDRESS = (PROTOCOL = TCP)(HOST = centos76)(PORT = 1521))
(CONNECT_DATA =)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
ORCL254 =
(DESCRIPTION =)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.254)(PORT = 1521))
(CONNECT_DATA =)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =)
(ADDRESS_LIST =)
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(CONNECT_DATA =)
(SID = PLSExtProc)
(PRESENTATION = RO)
5)设置备库参数文件
*.db_name='orcl'
*.DB_UNIQUE_NAME='standby'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='location=/usr/local/ora10/flash_recovery_area/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES)' DB_UNIQUE_NAME='standby'
*.log_archive_dest_2='SERVICE=orcl79 arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=parimary'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.remote_login_passwordfile='EXCLUSIVE'
#standby角色参数
*.FAL_SERVER=orcl79
*.FAL_CLIENT=orcl76
DB_FILE_NAME_CONVERT=’oradata/orcl’,’oradata/orcl’
LOG_FILE_NAME_CONVERT=’oradata/orcl’,’oradata/orcl’
*.standby_FILE_MANAGEMENT=AUTO
6)standby安装创建密码文件
[oracle@centos76 ~]$ orapwd file='/usr/local/ora10/product/10.2.0/db_1/dbs/orapworcl76.ora' password=system entries=20
7)在备库上建立spfile
$ sqlplus '/as sysdba'SQL> create spfile from pfile;
启动物理备库
SQL> startup nomount
SQL> alter database mount standby database;
备库做rman恢复
$ rman target /) (要求主备库rman备份文件的存放路径和文件名一致)
RMAN> restore database;
Starting restore at 18-AUG-09
Starting implicit crosscheck backup at 18-AUG-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 18-AUG-09
Starting implicit crosscheck copy at 18-AUG-09
using channel ORA_DISK_1
Crosschecked 4 objects
Finished implicit crosscheck copy at 18-AUG-09
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /usr/local/ora10/oradata/orcl/system01.dbf
restoring datafile 00002 to /usr/local/ora10/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /usr/local/ora10/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /usr/local/ora10/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/oracle/backup_20090818_11_1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/oracle/backup_20090818_11_1.bak tag=TAG20090818T165957
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 18-AUG-09
8)standby安装备库启动redo apply
SQL> alter database recover managed standby database disconnect from session;Database altered.SQL>
【编辑推荐】