概述
1环境列表
名称 | 主机1 | 主机2 |
主机名 | orcl | orcldg |
ip | 192.168.204.210 | 192.168.204.211 |
2分别配置主机环境
2.1配置主机名
临时生效 hostname name
永久生效vi /etc/sysconfig/network
2.2配置/etc/hosts 文件
添加 192.168.204.210 orcl 192.168. 204.211 orcldg |
2.3配关闭防火墙,设置静态IP等(service network restart)
chkconfig iptable off
vi /etc/selinux/config
sestatus
3主机1与主机2都安装oracle11.2.0.4数据库软件(略)
参考http://blog.csdn.net/sunziyue/article/details/49100593
4主机1利用DBCA工具创建实例orcl,主机2暂时不用配置实例(如果是windows,恢复前需要oradim -NEW -SID orcldg 创建新实例)。
4.1主机1 oracle用户环境变量vi /home/oracle/.bash_profile
PATH=$PATH:$HOME/bin export PATH export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export ORACLE_SID=orcl export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64 |
4.2主机2 oracle用户环境变量vi /home/oracle/.bash_profile
PATH=$PATH:$HOME/bin export PATH export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export ORACLE_SID=orcldg export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64 |
5准备工作
配置主机1,主机2上数据库静态监听,网络服务名,使互相可以tnsping
涉及命令netca,netmgr, tnsping
主机1
listener.ora
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) ) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = orcl)(PORT = 1521)) ) ADR_BASE_LISTENER = /u01/app/oracle |
tnsnames.ora
ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = orcl)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) ORCLDG = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =orcldg)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcldg) ) ) |
主机2中listener.ora与tnsnames.ora同理配置
5搭建DG—按以下顺序操作
5.1主库操作
设置归档:alter database archivelog; 设置强制记录日志:alter database force logging; oracle用户创建归档路径:mkdir -p /u01/app/oracle/archivelog oracle用户创建备份路径:mkdir -p /u01/app/oracle/databack 更改归档路径:alter system set log_archive_dest_1='location=/u01/app/oracle/archivelog'; 主库创建参数文件,口令文件,dg控制文件拷贝到备库相同路径 create pfile from spfile; --如果不创建,直接拷贝/u01/app/oracle/product/11.2.0/db_1/dbs/下的orapworcl文件 orapwdfile='/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl' password=123456 force=y alter database create standby controlfile as '/u01/app/oracle/databack/standby.ctl'; 从主库所在服务器远程拷贝到备机:(拷贝之前备机有必要先创建路径文件) scp initorcl.ora orcldg: /u01/app/oracle/product/11.2.0/db_1/dbs/ |
5.2备库操作
创建必要文件路径: [oracle@orcldg ~]$ mkdir -p /u01/app/oracle/admin/orcldg/adump [oracle@orcldg ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/orcldg [oracle@orcldg ~]$ mkdir -p /u01/app/oracle/archivelog [oracle@orcldg ~]$ mkdir -p /u01/app/oracle/databack [oracle@orcldg ~]$ mkdir -p /u01/app/oracle/oradata/orcldg/ 修改备库参数文件(主库参数文件的重命名得到) vi initorcldg 修改参数以及添加以下参数 下列参数为primary 角色相关 *.db_unique_name='orcldg' *.log_archive_config='dg_config=(orcl,orcldg)' *.log_archive_dest_1='location=/u01/app/oracle/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcldg' *.log_archive_dest_2='service=orcl lgwr sync affirm valid_for=(online_logfiles,primary_role) db_unique_name=orcl' *.log_archive_dest_state_1=enable *.log_archive_dest_state_2=enable *.log_archive_max_processes=10 以下参数为主库转为standby 角色时需要配置相关的参数 *.db_file_name_convert='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/orcldg' *.log_file_name_convert='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/orcldg' *.fal_server=orcl *.fal_client=orcldg *.standby_file_management=auto |
最后参数文件为:
orcldg.__db_cache_size=306184192 orcldg.__java_pool_size=4194304 orcldg.__large_pool_size=8388608 orcldg.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment orcldg.__pga_aggregate_target=314572800 orcldg.__sga_target=469762048 orcldg.__shared_io_pool_size=0 orcldg.__shared_pool_size=138412032 orcldg.__streams_pool_size=4194304 *.audit_file_dest='/u01/app/oracle/admin/orcldg/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/orcldg/control01.ctl','/u01/app/oracle/fast_recovery_area/orcldg/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='orcl' *.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' *.db_recovery_file_dest_size=1239416832 *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.log_archive_format='%t_%s_%r.dbf' *.memory_target=783286272 *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.undo_tablespace='UNDOTBS1' *.db_unique_name='orcldg' *.log_archive_config='dg_config=(orcl,orcldg)' *.log_archive_dest_1='location=/u01/app/oracle/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcldg' *.log_archive_dest_2='service=orcl lgwr sync affirm valid_for=(online_logfiles,primary_role) db_unique_name=orcl' *.log_archive_dest_state_1=enable *.log_archive_dest_state_2=enable *.log_archive_max_processes=10 *.db_file_name_convert='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/orcldg' *.log_file_name_convert='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/orcldg' *.fal_server=orcl *.fal_client=orcldg *.standby_file_management=auto |
启动数据库到nomout: startup nomout pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcldg.ora'
创建spfile:create spfile from pfile
利用spfile文件再次启动数据库到nomout: shutdown immediate 与 startup nomout
备库操作暂时结束
5.3再次主库操作
动态参数: alter system set log_archive_config='dg_config=(orcl, orcldg)'; alter system set log_archive_dest_1='location=/u01/app/oracle/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcl'; alter system set log_archive_dest_2='service=orcldg lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcldg'; alter system set log_archive_dest_state_1=enable; alter system set log_archive_dest_state_2=enable; alter system set log_archive_max_processes=10; alter system set fal_server=orcldg; alter system set fal_client=orcl; alter system set standby_file_management=auto; 静态重启生效参数: alter system set db_unique_name='orcl' scope=spfile; alter system set db_file_name_convert='/u01/app/oracle/oradata/orcldg','/u01/app/oracle/oradata/orcl' scope=spfile; alter system set log_file_name_convert='/u01/app/oracle/oradata/orcldg','/u01/app/oracle/oradata/orcl' scope=spfile; 可以不重启开始备份主库: rman target / backup database format '/u01/app/oracle/databack/%U'; 拷贝到备库相同目录下 scp 备份文件 orcldg:/u01/app/oracle/ |
5.4主库执行以下命令完成dg搭建:
rman target / auxiliary sys/XXXX@orcldg
duplicate target database for standby;
5.5完成后,dg已经搭建完毕,但是只支持最大性能模式,如果要支持最大保护模式需要创建standby logfile,备库执行
alterdatabase add standby logfile group 4('/u01/app/oracle/oradata/orcldg/redo_04.log') size 50m;
alterdatabase add standby logfile group 5('/u01/app/oracle/oradata/orcldg/redo_05.log') size 50m;
alterdatabase add standby logfile group 6('/u01/app/oracle/oradata/orcldg/redo_06.log') size 50m;
alterdatabase add standby logfile group 7 ('/u01/app/oracle/oradata/orcldg/redo_07.log')size 50m;
为了以后主备库切换,而支持最大保护模式,所以主库最好也创建
alterdatabase add standby logfile group 4('/u01/app/oracle/oradata/orcl/redo_04.log') size 50m;
alterdatabase add standby logfile group 5('/u01/app/oracle/oradata/orcl/redo_05.log') size 50m;
alterdatabase add standby logfile group 6('/u01/app/oracle/oradata/orcl/redo_06.log') size 50m;
alterdatabase add standby logfile group 7('/u01/app/oracle/oradata/orcl/redo_07.log') size 50m;
到此搭建完成。
最后
以上就是标致枫叶为你收集整理的Centos6.5 64+oracle11.2.0.4+rman 搭建物理DG的全部内容,希望文章能够帮你解决Centos6.5 64+oracle11.2.0.4+rman 搭建物理DG所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复