数据库新手。对 Oracle Data Guard 感兴趣。新使用 RMAN。
所有这些仅用于测试,不涉及任何类型的生产环境。
使用 ORACLE 文档:
- 使用 RMAN DUPLICATE...FROM ACTIVE DATABASE 创建物理备用的分步指南(文档 ID 1075908.1)
. .=================================================== ==========================。.
主数据库:
[oracle@ol12c pridb]$ env | grep ORA
ORACLE_UNQNAME=cdb1
ORACLE_SID=pridb
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=ol12c.localdomain
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1
SQL> startup pfile=/u01/app/oracle/product/12.1.0.2/db_1/dbs/initpridb.ora;
SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/fast_recovery_
area
db_recovery_file_dest_size big integer 2G
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 12
Next log sequence to archive 13
Current log sequence 13
. .=================================================== ==========================。.
2. 待机:
[oracle@ol12c stbdb]$ env | grep ORA
ORACLE_UNQNAME=cdb1
ORACLE_SID=stbdb
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=ol12c.localdomain
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1
SQL> startup nomount pfile='/u01/app/oracle/product/12.1.0.2/db_1/dbs/initstbdb.ora'
SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/fast_recovery_
area/stbdb
db_recovery_file_dest_size big integer 2G
. .=================================================== ==========================。.
3. RMAN(在主数据库上):
[oracle@ol12c pridb]$ rman
RMAN> connect target sys/oracle@pridb
connected to target database: PRIDB (DBID=1212094364)
RMAN> connect auxiliary sys/oracle@stbdb
connected to auxiliary database: PRIDB (not mounted)
. .=================================================== ==========================。.
4.错误:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "db_unique_name": expecting one of: "archivelog, autobackup, auxiliary, auxname, backup, catalog, command, compression, controlfile, database, dbid, decryption, default, echo, encryption, high, incarnation, incremental, long, maxcorrupt, maxseq, newname, nocfau, numwidth, restore, snapshot, to restore point, until restore point, until, "
RMAN-01007: at line 1 column 1 file: standard input
和
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "archivelog, autobackup, auxiliary, auxname, backup, catalog, command, compression, controlfile, database, dbid, decryption, default, echo, encryption, high, incarnation, incremental, long, maxcorrupt, maxseq, newname, nocfau, numwidth, restore, snapshot, to restore point, until restore point, until, "
RMAN-01008: the bad identifier was: log_archive_dest_2
RMAN-01007: at line 1 column 7 file: standard input
对于从 log_file_name_convert 开始的命令中指定的所有参数,我收到RMAN-01008错误。
. .=================================================== ==========================。.
5. 我的意见:
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate auxiliary channel aux type disk;
duplicate target database for standby from active database
parameter_value_convert'pridb','stbdb'
set db_unique_name='stbdb'
set db_file_name_convert='pridb','stbdb'
set log_file_name_convert='pridb','stbdb'
set control_files='/u01/app/oracle/oradata/stbdb/stbdb_control1.ctl'
set standby_file_management='AUTO'
set log_archive_max_processes='10'
set fal_client='stbdb'
set fal_server='pridb'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(pridb,stbdb)'
set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=stbdb'
set log_archive_dest_2='service=testdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=stbdb'
;
}
首先我得到:
RMAN-05557:目标实例未使用服务器参数文件启动
因为我在尝试:duplicate target database for standby from active database spfile
而且我不是从 spfile 开始,而是直接从 pfile 开始。
根据我的研究,我应该能够不指定 SPfile:
因此,我从我检查的链接中duplicate target database for standby from active database spfile
提到duplicate target database for standby from active database
的应该工作的地方改变了。
--> 但是我现在要更新哪些参数?在我看来,这似乎不合逻辑。 .
上面的代码在分配通道时成功运行了一次,但随后停止并开始抛出错误。
目前我正在运行脚本rman checksyntax
只是为了确保我不会破坏任何东西.. :)
. .=================================================== ==========================。.
你能帮我吗:
我试图更好地理解 RMAN。
找出我在上述情况下做错了什么。(+ 为什么!)
我对了解正在发生的事情等比快速完成这项工作更感兴趣。
(即使它工作起来会很棒!:)此时的目的是学习)
预先感谢您的帮助!
. .=================================================== ==========================。.
解决方案
需要一个 SPFILE
在主数据库上:
SQL> create spfile from pfile='/u01/app/oracle/product/12.1.0.2/db_1/dbs/initpridb.ora';
File created.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 2932632 bytes
Variable Size 671088744 bytes
Database Buffers 394264576 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
然后启动 RMAN 并运行脚本,正如我们所说的那样运行!:) -耶!
以下错误:
RMAN-05537:当使用 spfile 启动辅助实例时,没有 TARGET 连接的 DUPLICATE 不能使用 SPFILE 子句
通过更新脚本值和重新连接数据库来解决。
使用的最终脚本:
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate auxiliary channel aux type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert'pridb','stbdb'
set db_unique_name='stbdb'
set db_file_name_convert='/u01/app/oracle/oradata/pridb/PRIDB/datafile/','/u01/app/oracle/oradata/stbdb/STBDB/datafile/'
set log_file_name_convert='/u01/app/oracle/oradata/pridb/PRIDB/onlinelog/','/u01/app/oracle/oradata/stbdb/STBDB/onlinelog/'
set control_files='/u01/app/oracle/oradata/stbdb/stbdb_control1.ctl'
set standby_file_management='AUTO'
set log_archive_max_processes='10'
set fal_client='stbdb'
set fal_server='pridb'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(pridb,stbdb)'
set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=stbdb'
set log_archive_dest_2='service=testdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=stbdb'
;
}
parameter_value_convert
没有就不能使用spfile
。重复:
dupOptionList::=
主数据库是用 spfile 启动的:
待机是用 pfile 启动的:
复制:
您的主要应使用 spfile。