ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 虚拟机上单个linux 搭建standby

虚拟机上单个linux 搭建standby

原创 Linux操作系统 作者:Nalternative 时间:2011-07-05 15:43:49 0 删除 编辑

[root@oracle standby]# mkdir /standby
[root@oracle standby]# mkdir /standby/bdump
[root@oracle standby]# mkdir /standby/udump
[root@oracle standby]# mkdir /standby/archive
[root@oracle standby]# mkdir /standby/oradata/standby
[root@oracle standby]# chown -R oracle:oinstall /standby
--1、enable force logging
SQL> alter database force logging;

Database altered.

--2、create a password file
$ orapwd file=orapwstandby password=zja entries=30

--3、configure a standby redo log

SQL> alter database add standby logfile group 4('/standby/oradata/standby/standby02.log') size 20M;
SQL> alter database add standby logfile group 5('/standby/oradata/standby/standby01.log') size 20M;
SQL> alter database add standby logfile group 6('/standby/oradata/standby/standby03.log') size 20M;

--4、Set Primary Database Initialization Parameters

create pfile from spfile

*.db_unique_name='orcl'
*.log_archive_dest_1='location=/oracle/flash_recovery_area/ORCL/archivelog/
  valid_for=(all_logfiles,all_roles) db_unique_name=orcl'
*.log_archive_dest_2='SERVICE=standby
  valid_for=(online_logfiles,primary_role) db_unique_name=standby'
*.standby_file_management=AUTO
*.log_archive_config='dg_config=(orcl,standby)'
*.fal_server=standby
*.fal_client=orcl


shutdown immediate

create spfile from pfile='/oracle/10g/dbs/initorcl.ora';
startup

--建立备用数据库
create pfile='/oracle/10g/dbs/initstandby.ora' from spfile;

--修改备用参数文件
sed -e 's/oracle/standby/g' -e 's/orcl/standby/g'  initstandby.ora >initstandby.ora.2

*.service_names='standby'
*.instance_name='standby'
*.log_archive_dest_1='location=/standby/flash_recovery_area/standby/archivelog/
  valid_for=(all_logfiles,all_roles) db_unique_name=standby'
*.log_archive_dest_2='SERVICE=orcl
  valid_for=(online_logfiles,primary_role) db_unique_name=orcl'
*.db_file_name_convert='/oracle/oradata/orcl/','/standby/oradata/standby/'
*.log_file_name_convert='/oracle/oradata/orcl/','/standby/oradata/standby/'
*.log_archive_config='dg_config=(orcl,standby)'

*.standby_archive_dest='/standby/flash_recovery_area/standby/archivelog/'


--建立服务器参数文件

create spfile='/oracle/10g/dbs/spfilestandby.ora' from pfile='/oracle/10g/dbs/initstandby.ora';

SQL>  startup force nomount
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size             104859216 bytes
Database Buffers          176160768 bytes
Redo Buffers                2973696 bytes

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
standby

--建立备份
[root@oracle /]# mkdir /backup
[root@oracle /]# chown -R oracle:oinstall /backup
[root@oracle /]# su - oracle
[oracle@oracle ~]$ cd /backup
[oracle@oracle backup]$ rman target  sys/***@orcl   nocatalog

Recovery Manager: Release 10.2.0.1.0 - Production on Sat Jul 2 10:09:49 2011
....................
..........

 


RMAN> backup database plus archivelog format='/backup/%d_%s.bak';


Starting backup at 02-JUL-11
....................
..........


RMAN> backup current controlfile for standby format='/backup/%d_%s.bak';

Starting backup at 02-JUL-11
....................
..........


---配置监听、域名服务器

 

 

shutdown immediate
startup mount

alter database create standby controlfile as '/standby/oradata/standby/control01.ctl';
alter database create standby controlfile as '/standby/oradata/standby/control02.ctl';
alter database create standby controlfile as '/standby/oradata/standby/control03.ctl';
alter database open

 

---复制数据库
[oracle@oracle ~]$ export ORACLE_SID=standby
[oracle@oracle ~]$  rman target sys/zja@orcl auxiliary sys/zja


xhost local:oracle non-network local connections being added to access control list

 

RMAN> duplicate target database for standby dorecover; 

 

--主库执行:
SQL> alter system switch logfile;

System altered.
--备库执行:
SQL> select name from v$archived_log;


SQL> conn sys/zja@standby as sysdba
Connected.
SQL> conn sys/zja@orcl as sysdba
Connected.
SQL> alter system switch logfile;

System altered.

SQL> conn sys/zja@standby as sysdba
Connected.
SQL> select name from v$archived_log;

NAME
--------------------------------------------------------------------------------
/standby/flash_recovery_area/standby/archivelog/1_18_751041176.dbf
/standby/flash_recovery_area/standby/archivelog/1_19_751041176.dbf
/standby/flash_recovery_area/standby/archivelog/1_20_751041176.dbf
/standby/flash_recovery_area/standby/archivelog/1_21_751041176.dbf
/standby/flash_recovery_area/standby/archivelog/1_22_751041176.dbf

--测试

create user edu identified by jyedu;

conn edu/jyedu@orcl
conn edu/jyedu@standby

conn jason/marcus@orcl
conn jason/marcus@standby

--启动redo应用
alter database recover managed standby database disconnect from session;

select max(sequence#) from v$archived_log;

 

--文件显示末尾行

netca

netmgr


问题:
1----------
ORA-01103: database name 'ORCL' in control file is not 'STANDBY'

修改 dbname,dbname 需一致,但实例名可以不一致.

2-----------
$ORACLE_HOME/dbs
下面存放密码文件 orapw 可以用来共享

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25323853/viewspace-701382/,如需转载,请注明出处,否则将追究法律责任。

上一篇: oracle 安装步骤
下一篇: oracle clusterware
请登录后发表评论 登录
全部评论

注册时间:2011-02-09

  • 博文量
    123
  • 访问量
    174542