「收藏」Oracle 数据库安装

网友投稿 616 2022-08-28

「收藏」Oracle 数据库安装

「收藏」Oracle 数据库安装

01

安装环境

备注:orcl1是一套oracle RAC 集群中的一台服务器

02

安装前配置

1、IP地址配置

主库:192.168.2.15

备库:192.168.2.180

2、Oracle安装要求

主库:安装oracle 软件,并创建oracle 数据库

备库:仅安装oracle软件

3、安装位置

主库:/u01/app/oracle/product/11.2.0.4/db_1

备库:/u01/app/oracle/product/11.2.0.4/dbhome_1

数据库实例规划

主库:

实例名:orcl1数据库名orcl 数据库唯一名:orcl_rac

备库:

实例名:orcl数据库名 orcl 数据库唯一名:orcl_dg

Oracle Dataguard 要求主库和备库的数据库名字一样,即db_name要一样,

使用db_unique_name名字区分

03

安装过程

主库为归档模式

主库:

Select log_mode from v$database;

2、启用强制日志模式(mount 状态下修改)

主库:

SQL>select force_logging from v$database;FORCE_------NOSQL> shutdown immediate;数据库已经关闭。已经卸载数据库。ORACLE 例程已经关闭。SQL>startup mount;ORACLE 例程已经启动。Total System Global Area 1119043584 bytesFixed Size 2280496 bytesVariable Size 738198480 bytesDatabase Buffers 369098752 bytesRedo Buffers 9465856 bytes数据库装载完毕。SQL>alter database force logging;数据库已更改。SQL> alter database open;数据库已更改。SQL>select force_logging from v$database;FORCE_------YES

Force_logging 为YES 代表数据库是强制日志模式。

3、配置standby 日志文件

主库:

增加standby 日志组(正常比online 日志多一组)alter database add standby logfile thread 1 group 5 '+DATA/orcl/onlinelog/group5_01.log' size 50M;alter database add standby logfile thread 1 group 6 '+DATA/orcl/onlinelog/group6_01.log' size 50M;alter database add standby logfile thread 1 group 7 '+DATA/orcl/onlinelog/group7_01.log' size 50M;alter database add standby logfile thread 2 group 8 '+DATA/orcl/onlinelog/group8_01.log' size 50M;alter database add standby logfile thread 2 group 9 '+DATA/orcl/onlinelog/group9_01.log' size 50M;alter database add standby logfile thread 2 group 10 '+DATA/orcl/onlinelog/group10_01.log' size 50M;--查询standby log 命令SELECT bytes,GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;--删除standby 的命令alter database drop standby logfile group 4;

4、配置监听(主库和备库)

使用netca配置监听。

下图是监听配置后的结果,监听正常。

主库:RAC 不用单独配置监听

备库:配置DG的时候,备份的数据库还无法open,所有要配置静态监听/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora

SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = orcl_dg)(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_1)(SID_NAME = orcl)))LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.180)(PORT = 1521)))(DESCRIPTION =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))))ADR_BASE_LISTENER = /u01/app/oracle/product/11.2.0.4/dbhome_1

启动监听:lsnrctl start

5、配置tnsnames文件(主库和备库)

ORCL_PRI 为主库的连接信息,orcl_std为备库的连接信息/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/tnsnames.ora

主库:

ORCL_PRI =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.15)(PORT = 1521))(CONNECT_DATA =(SERVICE_NAME = orcl_rac)))ORCL_STD =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.180)(PORT = 1521))(CONNECT_DATA =(SERVICE_NAME = orcl_dg)))

备库:

ORCL_PRI =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.15)(PORT = 1521))(CONNECT_DATA =(SERVICE_NAME = orcl_rac)))ORCL_STD =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.180)(PORT = 1521))(CONNECT_DATA =(SERVICE_NAME = orcl_dg)))

6、tnsping (主库和备库)

确认主库和备库是否联通

主备库:tnsping ORCL_PRI

tnsping ORCL_STD

7、创建pfile并修改。

主库:

创建pfile ,修改pfile,生成spfile,并以spfile 启动数据库

alter system set DB_UNIQUE_NAME=orcl_rac scope=spfile sid='*';alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl_rac,orcl_dg)' scope=both sid='*';alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl_rac' scope=both sid='*';alter system set LOG_ARCHIVE_DEST_2='SERVICE=orcl_std ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl_dg' scope=both sid='*';#standbyalter system set FAL_SERVER=orcl_std scope=both sid='*';alter system set fal_client=orcl1 scope=both sid='orcl1';alter system set fal_client=orcl2 scope=both sid='orcl2';alter system set DB_FILE_NAME_CONVERT='/data/oradata/','+DATA/orcl/datafile/','/data/oradata/', '+DATA/orcl/tempfile/' scope=spfile sid='*';alter system set LOG_FILE_NAME_CONVERT='/data/oradata/','+DATA/orcl/onlinelog/' scope=spfile sid='*';alter system set STANDBY_FILE_MANAGEMENT=AUTO scope=both sid='*';

备库:

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'*.audit_trail='db'*.compatible='11.2.0.4.0'*.control_files='/data/oradata/control01.ctl','/data/oradata/control02.ctl'*.db_create_file_dest='/u01/app/oracle/oradata'*.db_name='orcl'*.diagnostic_dest='/u01/app/oracle'*.db_recovery_file_dest='/data/oradata/fast_recovery_area'*.db_recovery_file_dest_size=462107443200*.undo_tablespace='UNDOTBS1'*.open_cursors=300*.pga_aggregate_target=200M*.processes=1500*.sessinotallow=1655*.sga_target=420M*.db_unique_name='orcl_dg'*.log_archive_cnotallow='DG_CONFIG=(orcl_dg,orcl_rac)'*.log_archive_dest_1='locatinotallow=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=orcl_dg'*.log_archive_dest_2='SERVICE=orcl_pri ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl_pri'*.log_file_name_cnotallow='+DATA/orcl/onlinelog/','/data/oradata/'*.db_file_name_cnotallow='+DATA/orcl/datafile/','/data/oradata/','+DATA/orcl/tempfile/','/data/oradata/'*.fal_client='ORCL_STD'*.fal_server='ORCL1,ORCL2'*.standby_file_management='AUTO'

创建相应的路径:

mkdir -p /u01/app/oracle/admin/orcl/adumpmkdir -p /data/oradata/mkdir -p /u01/app/oraclemkdir -p /data/oradata/fast_recovery_area

8、配置密码文件

将主库A的密码文件复制到备库和 主库B

scp orapworcl1 192.168.2.180:/u01/app/oracle/product/11.2.0.4/dbhome_1/dbsmv orapworcl1 orapworclscp orapworcl1 192.168.2.14:/u01/app/oracle/product/11.2.0.4/db_1/db

9、备库创建spfile ,并启动到nomount

export ORACLE_SID=orclSql> create spfile from pfile='/tmp/pfile.txt';

10、使用RMAN连接主备库,复制数据主库:使用RMAN 复制主库的控制文件和数据文件到备库

rman target sys/oracle@orcl_pri auxiliary sys/oracle@orcl_std

RMAN> duplicate target database for standby from active database nofilenamecheck dorecover;

11、打开备库,并开始同步数据备库:

Alter database open read only;alter database recover managed standby database using current logfile disconnect from session;

end

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Grafana简单用法
下一篇:C# 中的 == 和 equals()有什么区别?
相关文章

 发表评论

暂时没有评论,来抢沙发吧~