-
Notifications
You must be signed in to change notification settings - Fork 9
Create dataguard
PhilippeLeroux edited this page Mar 2, 2018
·
6 revisions
# Running : ./create_dataguard.sh
# Create dataguard :
# - Primary database : ORION01 on srvorion01
# - Physical standby database : ORION02 on srvorion02
# ==========================================================================================================
# Dataguard broker : 0 database configured.
# ==========================================================================================================
# Log mode archivelog : [ok]
# ==========================================================================================================
20:31:08> ~/plescripts/shell/test_ssh_equi.sh -user=oracle -server=srvorion02
20:31:08> ssh -o BatchMode=yes oracle@srvorion02 true
# ssh equi between oracle@srvorion01 & oracle@srvorion02 : [ok]
# ==========================================================================================================
# Tuned profile ple-oracle, on srvorion02 ple-oracle : [ok]
# ==========================================================================================================
20:31:11> ssh srvorion02 ps -ef | grep -qE 'ora_pmon_[O]RION02'
< ps (ssh) return 1, continue...
# ORION02 not exists on srvorion02 : [ok]
# ==========================================================================================================
# prereq [ok]
# ==========================================================================================================
# Add alias for primary and physical CDB on srvorion01
20:31:12> ~/plescripts/db/add_tns_alias.sh -service=ORION01 -host_name=srvorion01
# srvorion01 : Delete TNS alias ORION01 if exists.
20:31:12> ~/plescripts/db/delete_tns_alias.sh -tnsalias=ORION01
# Alias ORION01 not found.
# srvorion01 : Append new alias : ORION01
20:31:12> ~/plescripts/shell/gen_tns_alias.sh -service=ORION01 -alias_name=ORION01 -server_list=srvorion01 >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
20:31:12> ~/plescripts/db/add_tns_alias.sh -service=ORION02 -host_name=srvorion02
# srvorion01 : Delete TNS alias ORION02 if exists.
20:31:12> ~/plescripts/db/delete_tns_alias.sh -tnsalias=ORION02
# Alias ORION02 not found.
# srvorion01 : Append new alias : ORION02
20:31:12> ~/plescripts/shell/gen_tns_alias.sh -service=ORION02 -alias_name=ORION02 -server_list=srvorion02 >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
# ==========================================================================================================
# Add alias for primary and physical CDB on srvorion02
20:31:13> ssh srvorion02 ". .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=ORION01 -host_name=srvorion01"
# srvorion02 : Delete TNS alias ORION01 if exists.
20:31:13> ~/plescripts/db/delete_tns_alias.sh -tnsalias=ORION01
# srvorion02 : Append new alias : ORION01
20:31:13> ~/plescripts/shell/gen_tns_alias.sh -service=ORION01 -alias_name=ORION01 -server_list=srvorion01 >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
20:31:13> ssh srvorion02 ". .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=ORION02 -host_name=srvorion02"
# srvorion02 : Delete TNS alias ORION02 if exists.
20:31:13> ~/plescripts/db/delete_tns_alias.sh -tnsalias=ORION02
# Alias ORION02 not found.
# srvorion02 : Append new alias : ORION02
20:31:13> ~/plescripts/shell/gen_tns_alias.sh -service=ORION02 -alias_name=ORION02 -server_list=srvorion02 >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# ==========================================================================================================
# Add static listeners on srvorion01 :
#
SID_LIST_LISTENER= # Added by bibi : ORION01
(SID_LIST=
(SID_DESC= # Peut être évité si les propriétés du dataguard sont modifiées.
(SID_NAME=ORION01)
(GLOBAL_DBNAME=ORION01_DGMGRL)
(ORACLE_HOME=/u02/app/oracle/12.1.0.2/dbhome_1)
(ENVS="TNS_ADMIN=/u02/app/oracle/12.1.0.2/dbhome_1/network/admin")
)
(SID_DESC=
(SID_NAME=ORION01)
(GLOBAL_DBNAME=ORION01)
(ORACLE_HOME=/u02/app/oracle/12.1.0.2/dbhome_1)
(ENVS="TNS_ADMIN=/u02/app/oracle/12.1.0.2/dbhome_1/network/admin")
)
) # End bibi : ORION01
20:31:14> chmod ug=rwx /tmp/setup_listener.sh
20:31:14> sudo -iu grid /tmp/setup_listener.sh
Configuration :
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 27-FEB-2018 20:31:14
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srvorion01.orcl)(PORT=1521)))
The command completed successfully
# ==========================================================================================================
# Add static listeners on srvorion02 :
#
SID_LIST_LISTENER= # Added by bibi : ORION02
(SID_LIST=
(SID_DESC= # Peut être évité si les propriétés du dataguard sont modifiées.
(SID_NAME=ORION02)
(GLOBAL_DBNAME=ORION02_DGMGRL)
(ORACLE_HOME=/u02/app/oracle/12.1.0.2/dbhome_1)
(ENVS="TNS_ADMIN=/u02/app/oracle/12.1.0.2/dbhome_1/network/admin")
)
(SID_DESC=
(SID_NAME=ORION02)
(GLOBAL_DBNAME=ORION02)
(ORACLE_HOME=/u02/app/oracle/12.1.0.2/dbhome_1)
(ENVS="TNS_ADMIN=/u02/app/oracle/12.1.0.2/dbhome_1/network/admin")
)
) # End bibi : ORION02
20:31:15> chmod ug=rwx /tmp/setup_listener.sh
20:31:15> scp /tmp/setup_listener.sh srvorion02:/tmp/setup_listener.sh
20:31:15> ssh -t srvorion02 sudo -iu grid /tmp/setup_listener.sh
Configuration :
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 27-FEB-2018 20:31:15
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srvorion02.orcl)(PORT=1521)))
The command completed successfully
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 27-FEB-2018 20:31:15
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Starting /u01/app/grid/12.1.0.2/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.1.0.2.0 - Production
System parameter file is /u01/app/grid/12.1.0.2/network/admin/listener.ora
Log messages written to /u01/app/grid/diag/tnslsnr/srvorion02/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=srvorion02.orcl)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srvorion02.orcl)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 27-FEB-2018 20:31:15
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/12.1.0.2/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/srvorion02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=srvorion02.orcl)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "ORION02" has 1 instance(s).
Instance "ORION02", status UNKNOWN, has 1 handler(s) for this service...
Service "ORION02_DGMGRL" has 1 instance(s).
Instance "ORION02", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
Connection to srvorion02 closed.
# ==========================================================================================================
# ORION01 : 3 redo logs of 128M
# --> Add 4 SRLs of 128M
20:31:16> sqlplus -s sys/Oracle12 as sysdba
SQL> alter database add standby logfile thread 1 size 128M;
Database altered.
Elapsed: 00:00:06.13
SQL> alter database add standby logfile thread 1 size 128M;
Database altered.
Elapsed: 00:00:07.44
SQL> alter database add standby logfile thread 1 size 128M;
Database altered.
Elapsed: 00:00:07.49
SQL> alter database add standby logfile thread 1 size 128M;
Database altered.
Elapsed: 00:00:05.98
20:31:44> sqlplus -s sys/Oracle12 as sysdba
SQL> set lines 130 pages 45
SQL> col member for a60
SQL> break on type skip 1
SQL> select * from v$logfile order by type, group#;
GROUP# STATUS TYPE MEMBER IS_ CON_ID
------------ ------- ------- ------------------------------------------------------------ --- ------------
1 ONLINE +DATA/ORION01/ONLINELOG/group_1.262.969221027 NO 0
1 +FRA/ORION01/ONLINELOG/group_1.257.969221029 YES 0
2 +DATA/ORION01/ONLINELOG/group_2.263.969221031 NO 0
2 +FRA/ORION01/ONLINELOG/group_2.258.969221035 YES 0
3 +DATA/ORION01/ONLINELOG/group_3.264.969221037 NO 0
3 +FRA/ORION01/ONLINELOG/group_3.259.969221041 YES 0
4 STANDBY +DATA/ORION01/ONLINELOG/group_4.276.969222677 NO 0
4 +FRA/ORION01/ONLINELOG/group_4.269.969222679 YES 0
5 +DATA/ORION01/ONLINELOG/group_5.277.969222683 NO 0
5 +FRA/ORION01/ONLINELOG/group_5.270.969222685 YES 0
6 +DATA/ORION01/ONLINELOG/group_6.278.969222691 NO 0
6 +FRA/ORION01/ONLINELOG/group_6.273.969222693 YES 0
7 +DATA/ORION01/ONLINELOG/group_7.279.969222697 NO 0
7 +FRA/ORION01/ONLINELOG/group_7.274.969222701 YES 0
14 rows selected.
# ==========================================================================================================
# Setup primary database ORION01 for duplicate & dataguard.
20:31:44> sqlplus -s sys/Oracle12 as sysdba
SQL> alter database force logging;
Database altered.
Elapsed: 00:00:00.11
# ==========================================================================================================
# Start broker.
20:31:45> sqlplus -s sys/Oracle12 as sysdba
SQL> alter system set dg_broker_config_file1 = '+DATA/ORION01/dr1db_ORION01.dat' scope=both sid='*';
System altered.
Elapsed: 00:00:00.02
SQL> alter system set dg_broker_config_file2 = '+FRA/ORION01/dr2db_ORION01.dat' scope=both sid='*';
System altered.
Elapsed: 00:00:00.00
SQL> alter system set standby_file_management='AUTO' scope=both sid='*';
System altered.
Elapsed: 00:00:00.01
SQL> alter system set dg_broker_start=true scope=both sid='*';
System altered.
Elapsed: 00:00:00.00
# Waiting broker initialisation : 30/30s
# ==========================================================================================================
# Create Dataguard configuration.
20:32:15> dgmgrl -silent -echo sys/Oracle12
create configuration 'DGCONF' as primary database is ORION01 connect identifier is ORION01;
Configuration "DGCONF" created with primary database "orion01"
enable configuration;
# ==========================================================================================================
# Copy password file.
20:32:23> scp $ORACLE_HOME/dbs/orapwORION01 srvorion02:$ORACLE_BASE/12.1.0.2/dbhome_1/dbs/orapwORION02
# ==========================================================================================================
# Create directory /u02/app/oracle/ORION02/adump on srvorion02
20:32:24> ssh srvorion02 mkdir -p $ORACLE_BASE/admin/ORION02/adump
# ==========================================================================================================
# Start ORION02 on srvorion02.
# On srvorion02 :
# $ echo db_name='ORION02' > $ORACLE_HOME/dbs/initORION02.ora
# $ export ORACLE_SID=ORION02
# $ sqlplus -s sys/Oracle12 as sysdba <<<"startup nomount"
# startup nomount return 0
# ==========================================================================================================
# Info :
20:32:35> tnsping ORION01 | tail -3
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP) (HOST = srvorion01) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORION01)))
OK (0 msec)
20:32:35> tnsping ORION02 | tail -3
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP) (HOST = srvorion02) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORION02)))
OK (0 msec)
# ==========================================================================================================
# Physical standby
# db_name : ORION01
# db_unique_name : ORION02
# Run duplicate :
20:32:36> rman target sys/Oracle12@ORION01 auxiliary sys/Oracle12@ORION02 @/tmp/duplicate.rman
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 27 20:32:36 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORION01 (DBID=1328393311)
connected to auxiliary database: ORION02 (not mounted)
RMAN> run {
2> allocate channel prim1 type disk;
3> allocate channel prim2 type disk;
4> allocate auxiliary channel stby1 type disk;
5> allocate auxiliary channel stby2 type disk;
6> duplicate target database for standby from active database
7> using compressed backupset
8> spfile
9> parameter_value_convert 'ORION01','ORION02'
10> set db_name='ORION01' #Obligatoire en 12.2, sinon le duplicate échoue.
11> set db_unique_name='ORION02'
12> set db_create_file_dest='+DATA'
13> set db_recovery_file_dest='+FRA'
14> set control_files='+DATA','+FRA'
15> set cluster_database='false'
16> nofilenamecheck
17> ;
18> }
19>
using target database control file instead of recovery catalog
allocated channel: prim1
channel prim1: SID=265 device type=DISK
[ skipped ]
Recovery Manager complete.
20:37:20< rman running time : 4mn44s
# ==========================================================================================================
20:37:20> ssh -t -t oracle@srvorion02 ". .bash_profile; grep -q '^ORION02' /etc/oratab"</dev/null
** Warning **
** Database instance ORION02 exists
** But not found in /etc/oratab
Connection to srvorion02 closed.
< grep (ssh) return 1, continue...
20:37:21> ssh -t -t oracle@srvorion02 ". .bash_profile; echo "ORION02:$ORACLE_HOME:N" >> /etc/oratab"</dev/null
** Warning **
** Database instance ORION02 exists
** But not found in /etc/oratab
Connection to srvorion02 closed.
# Create links for user oracle.
20:37:22> ssh -t -t oracle@srvorion02 ". .bash_profile; plescripts/db/create_links.sh -db=ORION02"</dev/null
# Create link on /u02/app/oracle/admin/ORION02 to /home/oracle
20:37:22> ln -s $ORACLE_BASE/admin/ORION02 $HOME/ORION02
# Create directory log to /u02/app/oracle/admin/ORION02
20:37:22> mkdir $ORACLE_BASE/admin/ORION02/log
# Create link on /u02/app/oracle/admin/ORION02/log to /home/oracle
20:37:22> ln -s $ORACLE_BASE/admin/ORION02/log $HOME/log
Connection to srvorion02 closed.
# ==========================================================================================================
# Add standby ORION02 to data guard configuration.
add database ORION02 as connect identifier is ORION02 maintained as physical;
Database "orion02" added
enable database ORION02;
# ==========================================================================================================
# ORION02 : recover standby database & start recover.
20:37:49> sqlplus -s sys/Oracle12@ORION02 as sysdba
SQL> recover managed standby database cancel;
Media recovery complete.
SQL> recover managed standby database until consistent;
Media recovery complete.
SQL> alter database enable block change tracking;
Database altered.
Elapsed: 00:00:00.18
SQL> alter database flashback on;
Database altered.
Elapsed: 00:00:03.65
SQL> recover managed standby database disconnect;
Media recovery complete.
# Wait recover : 10/10s
# ==========================================================================================================
# Start with CRS, oracle will be create PDB tempory file.
20:38:13> sqlplus -s sys/Oracle12@ORION02 as sysdba
SQL> shu immediate
ORA-01109: base de donnees non ouverte
Database dismounted.
ORACLE instance shut down.
# ==========================================================================================================
# GI : register standby database on srvorion02 :
20:38:34> ssh -t -t oracle@srvorion02 ". .bash_profile; srvctl add database -db ORION02 -oraclehome $ORACLE_HOME -spfile $ORACLE_BASE/12.1.0.2/dbhome_1/dbs/spfileORION02.ora -role physical_standby -dbname ORION01 -diskgroup DATA,FRA -verbose"</dev/null
Connection to srvorion02 closed.
20:38:36> ssh -t -t oracle@srvorion02 ". .bash_profile; srvctl start database -db ORION02"</dev/null
Connection to srvorion02 closed.
# ==========================================================================================================
20:39:06> sqlplus -s sys/Oracle12@ORION02 as sysdba
SQL> @lspdbs
Instance PDB name Open mode Open time Size (Mb) Reco sta Save state
---------- ------------ ---------- -------------- ------------ -------- --------------
ORION02 CDB$ROOT READ ONLY 18/02/27 20:38 0 ENABLED NOT SAVED
ORION02 PDB$SEED READ ONLY 18/02/27 20:38 0 ENABLED NOT SAVED
ORION02 PDB01 MOUNTED 0 ENABLED NOT SAVED
3 rows selected.
Elapsed: 00:00:00.15
# ==========================================================================================================
20:39:06> ~/plescripts/db/create_srv_for_dataguard.sh -db=ORION01 -pdb=PDB01 -standby=ORION02 -standby_host=srvorion02</dev/null
# Create or update services on Primary orion01[pdb01].
20:39:06> $HOME/plescripts/db/create_srv_for_single_db.sh -db=orion01 -pdb=pdb01 -role=primary -start=yes
# Database orion01 role = primary
# =============================================================================
# srvorion01> orion01 : create service pdb01_oci on pluggable database pdb01.
20:39:07> srvctl \
modify service -service pdb01_oci \
-pdb pdb01 -db orion01 \
-role primary \
-policy automatic \
-failovertype select \
-failovermethod basic \
-failoverretry 20 \
-failoverdelay 3 \
-clbgoal long \
-rlbgoal throughput
20:39:09> ~/plescripts/db/add_tns_alias.sh -service=pdb01_oci -host_name=srvorion01
# srvorion01 : Delete TNS alias pdb01_oci if exists.
20:39:09> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_oci
# Delete alias PDB01_OCI between lines 2 & 12
20:39:09> sed -i '2,12d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:09> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion01 : Append new alias : pdb01_oci
20:39:09> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_oci -alias_name=pdb01_oci -server_list=srvorion01 >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
# srvorion01> orion01 : create service pdb01_java on pluggable database pdb01.
20:39:10> srvctl \
modify service -service pdb01_java \
-pdb pdb01 -db orion01 \
-role primary \
-policy automatic \
-failovertype SELECT \
-failovermethod basic \
-failoverretry 30 \
-failoverdelay 1
20:39:11> ~/plescripts/db/add_tns_alias.sh -service=pdb01_java -host_name=srvorion01
# srvorion01 : Delete TNS alias pdb01_java if exists.
20:39:11> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_java
# Delete alias PDB01_JAVA between lines 2 & 12
20:39:11> sed -i '2,12d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:11> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion01 : Append new alias : pdb01_java
20:39:11> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_java -alias_name=pdb01_java -server_list=srvorion01 >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
20:39:11> $HOME/plescripts/db/create_srv_for_single_db.sh -db=orion01 -pdb=pdb01 -role=physical_standby -start=yes
# Database orion01 role = physical_standby
# =============================================================================
# srvorion01> orion01 : create service pdb01_stby_oci on pluggable database pdb01.
20:39:12> srvctl \
add service -service pdb01_stby_oci \
-pdb pdb01 -db orion01 \
-role physical_standby \
-policy automatic \
-failovertype select \
-failovermethod basic \
-failoverretry 20 \
-failoverdelay 3 \
-clbgoal long \
-rlbgoal throughput
20:39:13> srvctl start service -service pdb01_stby_oci -db orion01
20:39:14> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_oci -host_name=srvorion01
# srvorion01 : Delete TNS alias pdb01_stby_oci if exists.
20:39:14> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_oci
# Alias PDB01_STBY_OCI not found.
# srvorion01 : Append new alias : pdb01_stby_oci
20:39:14> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_oci -alias_name=pdb01_stby_oci -server_list=srvorion01 >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
# srvorion01> orion01 : create service pdb01_stby_java on pluggable database pdb01.
20:39:15> srvctl \
add service -service pdb01_stby_java \
-pdb pdb01 -db orion01 \
-role physical_standby \
-policy automatic \
-failovertype SELECT \
-failovermethod basic \
-failoverretry 30 \
-failoverdelay 1
20:39:16> srvctl start service -service pdb01_stby_java -db orion01
20:39:16> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_java -host_name=srvorion01
# srvorion01 : Delete TNS alias pdb01_stby_java if exists.
20:39:16> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_java
# Alias PDB01_STBY_JAVA not found.
# srvorion01 : Append new alias : pdb01_stby_java
20:39:16> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_java -alias_name=pdb01_stby_java -server_list=srvorion01 >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
# orion01[pdb01] : stop all standby services.
20:39:17> srvctl stop service -db orion01 -service pdb01_stby_oci
20:39:18> srvctl stop service -db orion01 -service pdb01_stby_java
# =============================================================================
# Create service on standby srvorion02[pdb01]
20:39:19> ssh -t srvorion02 '. .bash_profile; export TERM=xterm-256color; $HOME/plescripts/db/create_srv_for_single_db.sh -db=ORION02 -pdb=pdb01 -role=primary -start=no'
Pseudo-terminal will not be allocated because stdin is not a terminal.
# Database ORION02 role = primary
# =============================================================================
# srvorion02> ORION02 : create service pdb01_oci on pluggable database pdb01.
20:39:20> srvctl \
add service -service pdb01_oci \
-pdb pdb01 -db ORION02 \
-role primary \
-policy automatic \
-failovertype select \
-failovermethod basic \
-failoverretry 20 \
-failoverdelay 3 \
-clbgoal long \
-rlbgoal throughput
20:39:21> ~/plescripts/db/add_tns_alias.sh -service=pdb01_oci -host_name=srvorion02
# srvorion02 : Delete TNS alias pdb01_oci if exists.
20:39:21> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_oci
# Alias PDB01_OCI not found.
# srvorion02 : Append new alias : pdb01_oci
20:39:21> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_oci -alias_name=pdb01_oci -server_list=srvorion02 >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
# srvorion02> ORION02 : create service pdb01_java on pluggable database pdb01.
20:39:21> srvctl \
add service -service pdb01_java \
-pdb pdb01 -db ORION02 \
-role primary \
-policy automatic \
-failovertype SELECT \
-failovermethod basic \
-failoverretry 30 \
-failoverdelay 1
20:39:22> ~/plescripts/db/add_tns_alias.sh -service=pdb01_java -host_name=srvorion02
# srvorion02 : Delete TNS alias pdb01_java if exists.
20:39:22> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_java
# Alias PDB01_JAVA not found.
# srvorion02 : Append new alias : pdb01_java
20:39:22> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_java -alias_name=pdb01_java -server_list=srvorion02 >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
20:39:22> ssh -t srvorion02 '. .bash_profile; export TERM=xterm-256color; $HOME/plescripts/db/create_srv_for_single_db.sh -db=ORION02 -pdb=pdb01 -role=physical_standby -start=yes'
Pseudo-terminal will not be allocated because stdin is not a terminal.
# Database ORION02 role = physical_standby
# =============================================================================
# srvorion02> ORION02 : create service pdb01_stby_oci on pluggable database pdb01.
20:39:23> srvctl \
add service -service pdb01_stby_oci \
-pdb pdb01 -db ORION02 \
-role physical_standby \
-policy automatic \
-failovertype select \
-failovermethod basic \
-failoverretry 20 \
-failoverdelay 3 \
-clbgoal long \
-rlbgoal throughput
20:39:24> srvctl start service -service pdb01_stby_oci -db ORION02
20:39:31> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_oci -host_name=srvorion02
# srvorion02 : Delete TNS alias pdb01_stby_oci if exists.
20:39:31> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_oci
# Alias PDB01_STBY_OCI not found.
# srvorion02 : Append new alias : pdb01_stby_oci
20:39:31> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_oci -alias_name=pdb01_stby_oci -server_list=srvorion02 >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
# srvorion02> ORION02 : create service pdb01_stby_java on pluggable database pdb01.
20:39:31> srvctl \
add service -service pdb01_stby_java \
-pdb pdb01 -db ORION02 \
-role physical_standby \
-policy automatic \
-failovertype SELECT \
-failovermethod basic \
-failoverretry 30 \
-failoverdelay 1
20:39:32> srvctl start service -service pdb01_stby_java -db ORION02
20:39:33> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_java -host_name=srvorion02
# srvorion02 : Delete TNS alias pdb01_stby_java if exists.
20:39:33> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_java
# Alias PDB01_STBY_JAVA not found.
# srvorion02 : Append new alias : pdb01_stby_java
20:39:33> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_java -alias_name=pdb01_stby_java -server_list=srvorion02 >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
20:39:33> ~/plescripts/db/update_tns_alias_for_dataguard.sh -pdb=pdb01 -dataguard_list=srvorion02
# =============================================================================
# Add or update alias pdb01_oci
20:39:33> ~/plescripts/db/add_tns_alias.sh -service=pdb01_oci -host_name=srvorion01 -dataguard_list="srvorion02"
# srvorion01 : Delete TNS alias pdb01_oci if exists.
20:39:33> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_oci
# Delete alias PDB01_OCI between lines 35 & 45
20:39:33> sed -i '35,45d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:34> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion01 : Append new alias : pdb01_oci
20:39:34> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_oci -alias_name=pdb01_oci -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
20:39:34> ssh srvorion02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_oci -host_name=srvorion01 -dataguard_list="srvorion02"'
# srvorion02 : Delete TNS alias pdb01_oci if exists.
20:39:34> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_oci
# Delete alias PDB01_OCI between lines 24 & 34
20:39:34> sed -i '24,34d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:34> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion02 : Append new alias : pdb01_oci
20:39:34> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_oci -alias_name=pdb01_oci -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# Add or update alias pdb01_stby_oci
20:39:34> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_oci -host_name=srvorion01 -dataguard_list="srvorion02"
# srvorion01 : Delete TNS alias pdb01_stby_oci if exists.
20:39:34> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_oci
# Delete alias PDB01_STBY_OCI between lines 46 & 56
20:39:34> sed -i '46,56d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:34> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion01 : Append new alias : pdb01_stby_oci
20:39:34> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_oci -alias_name=pdb01_stby_oci -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
20:39:34> ssh srvorion02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_oci -host_name=srvorion01 -dataguard_list="srvorion02"'
# srvorion02 : Delete TNS alias pdb01_stby_oci if exists.
20:39:34> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_oci
# Delete alias PDB01_STBY_OCI between lines 35 & 45
20:39:34> sed -i '35,45d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:34> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion02 : Append new alias : pdb01_stby_oci
20:39:34> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_oci -alias_name=pdb01_stby_oci -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# Add or update alias pdb01_java
20:39:35> ~/plescripts/db/add_tns_alias.sh -service=pdb01_java -host_name=srvorion01 -dataguard_list="srvorion02"
# srvorion01 : Delete TNS alias pdb01_java if exists.
20:39:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_java
# Delete alias PDB01_JAVA between lines 35 & 45
20:39:35> sed -i '35,45d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:35> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion01 : Append new alias : pdb01_java
20:39:35> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_java -alias_name=pdb01_java -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
20:39:35> ssh srvorion02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_java -host_name=srvorion01 -dataguard_list="srvorion02"'
# srvorion02 : Delete TNS alias pdb01_java if exists.
20:39:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_java
# Delete alias PDB01_JAVA between lines 24 & 34
20:39:35> sed -i '24,34d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:35> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion02 : Append new alias : pdb01_java
20:39:35> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_java -alias_name=pdb01_java -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# Add or update alias pdb01_stby_java
20:39:35> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_java -host_name=srvorion01 -dataguard_list="srvorion02"
# srvorion01 : Delete TNS alias pdb01_stby_java if exists.
20:39:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_java
# Delete alias PDB01_STBY_JAVA between lines 35 & 45
20:39:35> sed -i '35,45d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:35> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion01 : Append new alias : pdb01_stby_java
20:39:35> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_java -alias_name=pdb01_stby_java -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion01 : $TNS_ADMIN/tnsnames.ora updated.
20:39:35> ssh srvorion02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_java -host_name=srvorion01 -dataguard_list="srvorion02"'
# srvorion02 : Delete TNS alias pdb01_stby_java if exists.
20:39:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_java
# Delete alias PDB01_STBY_JAVA between lines 24 & 34
20:39:36> sed -i '24,34d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:39:36> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvorion02 : Append new alias : pdb01_stby_java
20:39:36> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_java -alias_name=pdb01_stby_java -server_list="srvorion01 srvorion02" >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
# Wallet add sys for PDB01 to wallet
20:39:36> ssh -t srvorion02 '. .bash_profile; ~/plescripts/db/add_sysdba_credential_for_pdb.sh -db=ORION02 -pdb=PDB01'</dev/null
Pseudo-terminal will not be allocated because stdin is not a terminal.
20:39:36> $HOME/plescripts/db/add_tns_alias.sh -tnsalias=sysPDB01 -service=PDB01 -host_name=srvorion02
# srvorion02 : Delete TNS alias sysPDB01 if exists.
20:39:36> ~/plescripts/db/delete_tns_alias.sh -tnsalias=sysPDB01
# Alias SYSPDB01 not found.
# srvorion02 : Append new alias : sysPDB01
20:39:36> ~/plescripts/shell/gen_tns_alias.sh -service=PDB01 -alias_name=sysPDB01 -server_list=srvorion02 >> $TNS_ADMIN/tnsnames.ora
# srvorion02 : $TNS_ADMIN/tnsnames.ora updated.
20:39:36> $HOME/plescripts/db/wallet/create_credential.sh -nolog -tnsalias=sysPDB01 -user=sys -password=Oracle12
20:39:36> $HOME/plescripts/db/wallet/create_wallet.sh -nolog
tput: No value for $TERM and no -T specified
#
# Create wallet store.
20:39:36> mkdir -p $ORACLE_HOME/oracle/wallet
20:39:36> mkstore -wrl $ORACLE_HOME/oracle/wallet -create <<< Oracle12
Enter password:
Enter password again:
tput: No value for $TERM and no -T specified
#
# Update sqlnet.ora
tput: No value for $TERM and no -T specified
#
# Create Oracle pki
20:39:37> orapki wallet create -wallet $ORACLE_HOME/oracle/wallet -auto_login <<< Oracle12
Oracle PKI Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
Enter wallet password:
20:39:38> mkstore -wrl $ORACLE_HOME/oracle/wallet -nologo -createCredential sysPDB01 sys Oracle12
Enter wallet password:
Create credential oracle.security.client.connect_string1
# Connection to pdb PDB01 with sys user :
# $ sqlplus /@sysPDB01 as sysdba
# ==========================================================================================================
# Copy glogin.sql
20:39:39> scp $ORACLE_HOME/sqlplus/admin/glogin.sql srvorion02:$ORACLE_BASE/12.1.0.2/dbhome_1/sqlplus/admin/glogin.sql
# ==========================================================================================================
# Adjust rman config for dataguard.
20:39:40> rman target sys/Oracle12 @$HOME/plescripts/db/rman/ajust_config_for_dataguard.rman
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 27 20:39:40 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORION01 (DBID=1328393311)
RMAN> configure archivelog deletion policy to applied on all standby;
2>
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
new RMAN configuration parameters are successfully stored
Recovery Manager complete.
20:39:44> ssh -t -t oracle@srvorion02 ". .bash_profile; rman target sys/Oracle12 @$HOME/plescripts/db/rman/purge.rman"</dev/null
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 27 20:39:44 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORION01 (DBID=1328393311)
RMAN> delete noprompt copy of database;
2> delete noprompt backup;
3> crosscheck backup;
4> delete noprompt expired backup;
5> crosscheck copy of database;
6> delete noprompt expired copy of database;
7> delete noprompt archivelog all;
8>
[ skipped ]
Recovery Manager complete.
Connection to srvorion02 closed.
20:40:16> ssh -t -t oracle@srvorion02 ". .bash_profile; rman target sys/Oracle12 @$HOME/plescripts/db/rman/configure_snapshot_controlfile.rman using '+DATA/ORION02/snapshot_ctrl_file.f'"</dev/null
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 27 20:40:16 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORION01 (DBID=1328393311)
RMAN> # Tous les autres paramètres sont dupliqués via RMAN.
2> configure snapshot controlfile name to "+DATA/ORION02/snapshot_ctrl_file.f";
3>
using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+DATA/ORION01/snapshot_ctrl_file.f';
new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+DATA/ORION02/snapshot_ctrl_file.f';
new RMAN configuration parameters are successfully stored
Recovery Manager complete.
Connection to srvorion02 closed.
20:40:19> ssh -t -t oracle@srvorion02 ". .bash_profile; rman target sys/Oracle12 @$HOME/plescripts/db/rman/ajust_config_for_dataguard.rman"</dev/null
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 27 20:40:19 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORION01 (DBID=1328393311)
RMAN> configure archivelog deletion policy to applied on all standby;
2>
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
new RMAN configuration parameters are successfully stored
Recovery Manager complete.
Connection to srvorion02 closed.
20:40:25> ssh -t -t oracle@srvorion02 ". .bash_profile; ~/plescripts/db/image_copy_backup.sh"</dev/null
20:40:25> cd $HOME/plescripts/db/rman
[ skipped ]
Recovery Manager complete.
20:46:10< rman running time : 4mn13s
# =============================================================================
20:46:10> rman target sys/Oracle12 @backup_archive_log.rman
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 27 20:46:10 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORION01 (DBID=1328393311)
RMAN> # Evite des erreurs si des archive logs ont été effacées manuellement.
2> run {
3> allocate channel c1 type disk;
4> allocate channel c2 type disk;
5> crosscheck archivelog all;
6> backup tag 'backup_archlog' archivelog all not backed up delete all input;
7> }
8>
[ skipped ]
Recovery Manager complete.
# =============================================================================
20:46:33> rman target sys/Oracle12 @crosscheck.rman
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 27 20:46:33 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORION01 (DBID=1328393311)
RMAN> crosscheck backup;
2> delete noprompt expired backup;
3>
4> crosscheck copy of database;
5> delete noprompt expired copy of database;
6>
7> crosscheck archivelog all;
8> delete noprompt expired archivelog all;
9>
10> crosscheck datafilecopy all;
11> delete noprompt obsolete;
12>
[ skipped ]
# Bakup valid !
# =============================================================================
# Espace disque avant backup :
# DG Total Free Usable %Usable
# DATA/ 16,380 Mb 10,768 Mb 10,768 Mb 65.7
# FRA/ 16,380 Mb 15,099 Mb 15,099 Mb 92.2
# Espace disque après backup :
20:48:35> $HOME/plescripts/dg/dg_space.sh
# DG Total Free Usable %Usable
# DATA/ 16,380 Mb 10,768 Mb 10,768 Mb 65.7
# FRA/ 16,380 Mb 10,847 Mb 10,847 Mb 66.2
# script image_copy_backup.sh running time : 8mn12s
Connection to srvorion02 closed.
20:48:37< ~/plescripts/db/image_copy_backup.sh"</dev/null (ssh) running time : 8mn12s
20:48:38> ~/plescripts/db/stby/show_dataguard_cfg.sh
# Primary orion01
20:48:39> dgmgrl -silent -echo sys/Oracle12<<EO_CMD
show configuration
Configuration - DGCONF
Protection Mode: MaxPerformance
Members:
orion01 - Primary database
orion02 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 10 seconds ago)
show database orion01
Database - orion01
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
ORION01
Database Status:
SUCCESS
validate database orion01
Database Role: Primary database
Ready for Switchover: Yes
# 1 physical database(s)
# =============================================================================
# Physical orion02
20:48:41> dgmgrl -silent -echo sys/Oracle12<<EO_CMD
show database orion02
Database - orion02
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Average Apply Rate: 1.00 KByte/s
Real Time Query: ON
Instance(s):
ORION02
Database Status:
SUCCESS
validate database orion02
Database Role: Physical standby database
Primary Database: orion01
Ready for Switchover: Yes
Ready for Failover: Yes (Primary Running)
[ skipped ]
# log 20h31mn05_oracle_on_srvorion01_create_dataguard.log copied to /home/oracle/log/2018-02-27
# Running : ./create_dataguard.sh
# Create dataguard :
# - Primary database : POLUX01 on srvpolux01
# - Physical standby database : POLUX02 on srvpolux02
# ============================================================================================================
# Dataguard broker : 0 database configured.
# ============================================================================================================
# Log mode archivelog : [ok]
# ============================================================================================================
20:12:32> ~/plescripts/shell/test_ssh_equi.sh -user=oracle -server=srvpolux02
20:12:32> ssh -o BatchMode=yes oracle@srvpolux02 true
# ssh equi between oracle@srvpolux01 & oracle@srvpolux02 : [ok]
# ============================================================================================================
# Tuned profile ple-oracle, on srvpolux02 ple-oracle : [ok]
# ============================================================================================================
20:12:34> ssh srvpolux02 ps -ef | grep -qE 'ora_pmon_[P]OLUX02'
< ps (ssh) return 1, continue...
# POLUX02 not exists on srvpolux02 : [ok]
# ============================================================================================================
# prereq [ok]
# ============================================================================================================
# Add alias for primary and physical CDB on srvpolux01
20:12:35> ~/plescripts/db/add_tns_alias.sh -service=POLUX01 -host_name=srvpolux01
# srvpolux01 : Delete TNS alias POLUX01 if exists.
20:12:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=POLUX01
# Alias POLUX01 not found.
# srvpolux01 : Append new alias : POLUX01
20:12:35> ~/plescripts/shell/gen_tns_alias.sh -service=POLUX01 -alias_name=POLUX01 -server_list=srvpolux01 >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
20:12:35> ~/plescripts/db/add_tns_alias.sh -service=POLUX02 -host_name=srvpolux02
# srvpolux01 : Delete TNS alias POLUX02 if exists.
20:12:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=POLUX02
# Alias POLUX02 not found.
# srvpolux01 : Append new alias : POLUX02
20:12:35> ~/plescripts/shell/gen_tns_alias.sh -service=POLUX02 -alias_name=POLUX02 -server_list=srvpolux02 >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
# ============================================================================================================
# Add alias for primary and physical CDB on srvpolux02
20:12:36> ssh srvpolux02 ". .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=POLUX01 -host_name=srvpolux01"
# srvpolux02 : Delete TNS alias POLUX01 if exists.
20:12:36> ~/plescripts/db/delete_tns_alias.sh -tnsalias=POLUX01
# srvpolux02 : Append new alias : POLUX01
20:12:36> ~/plescripts/shell/gen_tns_alias.sh -service=POLUX01 -alias_name=POLUX01 -server_list=srvpolux01 >> $TNS_ADMIN/tnsnames.ora
# srvpolux02 : $TNS_ADMIN/tnsnames.ora updated.
20:12:36> ssh srvpolux02 ". .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=POLUX02 -host_name=srvpolux02"
# srvpolux02 : Delete TNS alias POLUX02 if exists.
20:12:36> ~/plescripts/db/delete_tns_alias.sh -tnsalias=POLUX02
# Alias POLUX02 not found.
# srvpolux02 : Append new alias : POLUX02
20:12:36> ~/plescripts/shell/gen_tns_alias.sh -service=POLUX02 -alias_name=POLUX02 -server_list=srvpolux02 >> $TNS_ADMIN/tnsnames.ora
# srvpolux02 : $TNS_ADMIN/tnsnames.ora updated.
# ============================================================================================================
# Add static listeners on srvpolux01 :
#
SID_LIST_LISTENER= # Added by bibi : POLUX01
(SID_LIST=
(SID_DESC= # Peut être évité si les propriétés du dataguard sont modifiées.
(SID_NAME=POLUX01)
(GLOBAL_DBNAME=POLUX01_DGMGRL)
(ORACLE_HOME=/u01/app/oracle/12.2.0.1/dbhome_1)
(ENVS="TNS_ADMIN=/u01/app/oracle/12.2.0.1/dbhome_1/network/admin")
)
(SID_DESC=
(SID_NAME=POLUX01)
(GLOBAL_DBNAME=POLUX01)
(ORACLE_HOME=/u01/app/oracle/12.2.0.1/dbhome_1)
(ENVS="TNS_ADMIN=/u01/app/oracle/12.2.0.1/dbhome_1/network/admin")
)
) # End bibi : POLUX01
20:12:37> chmod ug=rwx /tmp/setup_listener.sh
20:12:37> /tmp/setup_listener.sh
grep: /u01/app/oracle/12.2.0.1/dbhome_1/network/admin/listener.ora: No such file or directory
Configuration :
cp: cannot stat ‘/u01/app/oracle/12.2.0.1/dbhome_1/network/admin/listener.ora’: No such file or directory
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 28-FEB-2018 20:12:37
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
# ============================================================================================================
# Add static listeners on srvpolux02 :
#
SID_LIST_LISTENER= # Added by bibi : POLUX02
(SID_LIST=
(SID_DESC= # Peut être évité si les propriétés du dataguard sont modifiées.
(SID_NAME=POLUX02)
(GLOBAL_DBNAME=POLUX02_DGMGRL)
(ORACLE_HOME=/u01/app/oracle/12.2.0.1/dbhome_1)
(ENVS="TNS_ADMIN=/u01/app/oracle/12.2.0.1/dbhome_1/network/admin")
)
(SID_DESC=
(SID_NAME=POLUX02)
(GLOBAL_DBNAME=POLUX02)
(ORACLE_HOME=/u01/app/oracle/12.2.0.1/dbhome_1)
(ENVS="TNS_ADMIN=/u01/app/oracle/12.2.0.1/dbhome_1/network/admin")
)
) # End bibi : POLUX02
20:12:37> chmod ug=rwx /tmp/setup_listener.sh
20:12:37> scp /tmp/setup_listener.sh srvpolux02:/tmp/setup_listener.sh
20:12:37> ssh -t srvpolux02 '. .bash_profile && /tmp/setup_listener.sh'
cp: cannot stat ‘/u01/app/oracle/12.2.0.1/dbhome_1/network/admin/listener.ora’: No such file or directory
Configuration :
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 28-FEB-2018 20:12:38
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 28-FEB-2018 20:12:38
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Starting /u01/app/oracle/12.2.0.1/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/12.2.0.1/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/srvpolux02/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=srvpolux02.orcl)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 28-FEB-2018 20:12:39
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/12.2.0.1/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/srvpolux02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=srvpolux02.orcl)(PORT=1521)))
Services Summary...
Service "POLUX02" has 1 instance(s).
Instance "POLUX02", status UNKNOWN, has 1 handler(s) for this service...
Service "POLUX02_DGMGRL" has 1 instance(s).
Instance "POLUX02", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
Connection to srvpolux02 closed.
# ============================================================================================================
# POLUX01 : 3 redo logs of 128M
# --> Add 4 SRLs of 128M
20:12:40> sqlplus -s sys/Oracle12 as sysdba
SQL> alter database add standby logfile thread 1 size 128M;
Base de donnees modifiee.
Ecoule : 00 :00 :04.42
SQL> alter database add standby logfile thread 1 size 128M;
Base de donnees modifiee.
Ecoule : 00 :00 :04.20
SQL> alter database add standby logfile thread 1 size 128M;
Base de donnees modifiee.
Ecoule : 00 :00 :04.95
SQL> alter database add standby logfile thread 1 size 128M;
Base de donnees modifiee.
Ecoule : 00 :00 :04.88
20:12:58> sqlplus -s sys/Oracle12 as sysdba
SQL> set lines 130 pages 45
SQL> col member for a60
SQL> break on type skip 1
SQL> select * from v$logfile order by type, group#;
GROUP# STATUS TYPE MEMBER IS_ CON_ID
------------ ------- ------- ------------------------------------------------------------ --- ------------
1 ONLINE /u02/database/POLUX01/onlinelog/o1_mf_1_f9fy7hvt_.log NO 0
1 /u03/recovery/POLUX01/onlinelog/o1_mf_1_f9fy7por_.log YES 0
2 /u02/database/POLUX01/onlinelog/o1_mf_2_f9fy7hvz_.log NO 0
2 /u03/recovery/POLUX01/onlinelog/o1_mf_2_f9fy7p5o_.log YES 0
3 /u02/database/POLUX01/onlinelog/o1_mf_3_f9fy7j1m_.log NO 0
3 /u03/recovery/POLUX01/onlinelog/o1_mf_3_f9fy7p7o_.log YES 0
4 STANDBY /u02/database/POLUX01/onlinelog/o1_mf_4_f9fzs85b_.log NO 0
4 /u03/recovery/POLUX01/onlinelog/o1_mf_4_f9fzsbg1_.log YES 0
5 /u02/database/POLUX01/onlinelog/o1_mf_5_f9fzsdhr_.log NO 0
5 /u03/recovery/POLUX01/onlinelog/o1_mf_5_f9fzsgm7_.log YES 0
6 /u02/database/POLUX01/onlinelog/o1_mf_6_f9fzsjp5_.log NO 0
6 /u03/recovery/POLUX01/onlinelog/o1_mf_6_f9fzsm6l_.log YES 0
7 /u02/database/POLUX01/onlinelog/o1_mf_7_f9fzsonf_.log NO 0
7 /u03/recovery/POLUX01/onlinelog/o1_mf_7_f9fzsr9j_.log YES 0
14 lignes selectionnees.
# ============================================================================================================
# Setup primary database POLUX01 for duplicate & dataguard.
20:12:59> sqlplus -s sys/Oracle12 as sysdba
SQL> alter database force logging;
Base de donnees modifiee.
Ecoule : 00 :00 :00.08
# ============================================================================================================
# Start broker.
20:12:59> sqlplus -s sys/Oracle12 as sysdba
SQL> alter system set dg_broker_config_file1 = '/u02/database/POLUX01/dr1db_POLUX01.dat' scope=both sid='*';
Systeme modifie.
Ecoule : 00 :00 :00.02
SQL> alter system set dg_broker_config_file2 = '/u03/recovery/POLUX01/dr2db_POLUX01.dat' scope=both sid='*';
Systeme modifie.
Ecoule : 00 :00 :00.01
SQL> alter system set standby_file_management='AUTO' scope=both sid='*';
Systeme modifie.
Ecoule : 00 :00 :00.00
SQL> alter system set dg_broker_start=true scope=both sid='*';
Systeme modifie.
Ecoule : 00 :00 :02.05
# Waiting broker initialisation : 30/30s
# ============================================================================================================
# Create Dataguard configuration.
20:13:32> dgmgrl -silent -echo sys/Oracle12
Connected to "POLUX01"
create configuration 'DGCONF' as primary database is POLUX01 connect identifier is POLUX01;
Configuration "DGCONF" created with primary database "polux01"
enable configuration;
# ============================================================================================================
# Copy password file.
20:13:38> scp $ORACLE_HOME/dbs/orapwPOLUX01 srvpolux02:$ORACLE_BASE/12.2.0.1/dbhome_1/dbs/orapwPOLUX02
# ============================================================================================================
# Create directory /u01/app/oracle/POLUX02/adump on srvpolux02
20:13:39> ssh srvpolux02 mkdir -p $ORACLE_BASE/admin/POLUX02/adump
# ============================================================================================================
# Start POLUX02 on srvpolux02.
# ============================================================================================================
20:13:39> ssh -t -t oracle@srvpolux02 ". .bash_profile; grep -q '^POLUX02' /etc/oratab"</dev/null
Connection to srvpolux02 closed.
< grep (ssh) return 1, continue...
20:13:39> ssh -t -t oracle@srvpolux02 ". .bash_profile; echo "POLUX02:$ORACLE_HOME:Y" >> /etc/oratab"</dev/null
Connection to srvpolux02 closed.
# On srvpolux02 :
# $ echo db_name='POLUX02' > $ORACLE_HOME/dbs/initPOLUX02.ora
# $ export ORACLE_SID=POLUX02
# $ sqlplus -s sys/Oracle12 as sysdba <<<"startup nomount"
# startup nomount return 0
# ============================================================================================================
# Info :
20:13:52> tnsping POLUX01 | tail -3
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP) (HOST = srvpolux01) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = POLUX01)))
OK (0 msec)
20:13:52> tnsping POLUX02 | tail -3
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP) (HOST = srvpolux02) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = POLUX02)))
OK (10 msec)
# ============================================================================================================
# Physical standby
# db_name : POLUX01
# db_unique_name : POLUX02
# Create directories on stby server srvpolux02
20:13:52> ssh srvpolux02 mkdir -p /u02/database/POLUX02
20:13:53> ssh srvpolux02 mkdir -p /u03/recovery/POLUX02
# Run duplicate :
20:13:53> rman target sys/Oracle12@POLUX01 auxiliary sys/Oracle12@POLUX02 @/tmp/duplicate.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:13:53 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
connected to auxiliary database: POLUX02 (not mounted)
RMAN> run {
2> allocate channel prim1 type disk;
3> allocate channel prim2 type disk;
4> allocate auxiliary channel stby1 type disk;
5> allocate auxiliary channel stby2 type disk;
6> duplicate target database for standby from active database
7> using compressed backupset
8> spfile
9> parameter_value_convert 'POLUX01','POLUX02'
10> set db_name='POLUX01' #Obligatoire en 12.2, sinon le duplicate échoue.
11> set db_unique_name='POLUX02'
12> set db_create_file_dest='/u02/database'
13> set db_recovery_file_dest='/u03/recovery'
14> set control_files='/u02/database/POLUX02/control01.ctl','/u03/recovery/POLUX02/control02.ctl'
15> set cluster_database='false'
16> nofilenamecheck
17> ;
18> }
19>
using target database control file instead of recovery catalog
allocated channel: prim1
channel prim1: SID=268 device type=DISK
[ skipped ]
Recovery Manager complete.
20:18:19< rman running time : 4mn26s
# ============================================================================================================
20:18:19> ssh -t -t oracle@srvpolux02 ". .bash_profile; grep -q '^POLUX02' /etc/oratab"</dev/null
Connection to srvpolux02 closed.
# Create links for user oracle.
20:18:19> ssh -t -t oracle@srvpolux02 ". .bash_profile; plescripts/db/create_links.sh -db=POLUX02"</dev/null
# Create link on /u01/app/oracle/admin/POLUX02 to /home/oracle
20:18:20> ln -s $ORACLE_BASE/admin/POLUX02 $HOME/POLUX02
# Create directory log to /u01/app/oracle/admin/POLUX02
20:18:20> mkdir $ORACLE_BASE/admin/POLUX02/log
# Create link on /u01/app/oracle/admin/POLUX02/log to /home/oracle
20:18:20> ln -s $ORACLE_BASE/admin/POLUX02/log $HOME/log
Connection to srvpolux02 closed.
# ============================================================================================================
# Add standby POLUX02 to data guard configuration.
Connected to "POLUX01"
add database POLUX02 as connect identifier is POLUX02 maintained as physical;
Database "polux02" added
enable database POLUX02;
# ============================================================================================================
# POLUX02 : recover standby database & start recover.
20:18:46> sqlplus -s sys/Oracle12@POLUX02 as sysdba
SQL> recover managed standby database cancel;
Restauration physique terminee.
SQL> recover managed standby database until consistent;
Restauration physique terminee.
SQL> alter database enable block change tracking;
Base de donnees modifiee.
Ecoule : 00 :00 :00.28
SQL> alter database flashback on;
Base de donnees modifiee.
Ecoule : 00 :00 :03.46
SQL> recover managed standby database disconnect;
Restauration physique terminee.
# Wait recover : 10/10s
# Bounce database to create PDB tempory file.
20:19:10> ssh -t -t oracle@srvpolux02 ". .bash_profile; ~/plescripts/db/bounce_db.sh"</dev/null
20:19:10> $HOME/plescripts/db/stop_db.sh
20:19:10> sqlplus -s sys/Oracle12 as sysdba
SQL> shutdown immediate
ORA-01109: base de donnees non ouverte
Base de donnees demontee.
Instance ORACLE arretee.
20:19:43> $HOME/plescripts/db/start_db.sh
20:19:43> sqlplus -s sys/Oracle12 as sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 1174405120 bytes
Fixed Size 8792056 bytes
Variable Size 838862856 bytes
Database Buffers 318767104 bytes
Redo Buffers 7983104 bytes
Base de donnees montee.
Base de donnees ouverte.
20:20:30> sqlplus -s sys/Oracle12 as sysdba
SQL> @/home/oracle/plescripts/db/sql/lspdbs.sql
Instance PDB name Open mode Open time Size (Mb) Reco sta Save state
---------- ------------ ---------- -------------- ---------- -------- --------------
POLUX02 CDB$ROOT READ ONLY 18/02/28 20:20 0 ENABLED NOT SAVED
POLUX02 PDB$SEED READ ONLY 18/02/28 20:20 744 ENABLED NOT SAVED
POLUX02 PDB01 READ ONLY 18/02/28 20:20 2074 ENABLED OPEN
Ecoule : 00 :00 :00.26
Connection to srvpolux02 closed.
20:20:30< ~/plescripts/db/bounce_db.sh"</dev/null (ssh) running time : 1mn20s
# ============================================================================================================
20:20:30> sqlplus -s sys/Oracle12@POLUX02 as sysdba
SQL> @lspdbs
Instance PDB name Open mode Open time Size (Mb) Reco sta Save state
---------- ------------ ---------- -------------- ------------ -------- --------------
POLUX02 CDB$ROOT READ ONLY 18/02/28 20:20 0 ENABLED NOT SAVED
POLUX02 PDB$SEED READ ONLY 18/02/28 20:20 744 ENABLED NOT SAVED
POLUX02 PDB01 READ ONLY 18/02/28 20:20 2 074 ENABLED OPEN
3 lignes selectionnees.
Ecoule : 00 :00 :00.06
# ============================================================================================================
20:20:31> ~/plescripts/db/create_srv_for_dataguard.sh -db=POLUX01 -pdb=PDB01 -standby=POLUX02 -standby_host=srvpolux02</dev/null
# Create or update services on Primary polux01[pdb01].
20:20:31> $HOME/plescripts/db/create_srv_for_single_db.sh -db=polux01 -pdb=pdb01 -role=primary -start=yes
# Database polux01 role = primary
# =============================================================================
# srvpolux01> polux01 : create service pdb01_oci on pluggable database pdb01.
< srvpolux01> modify service without crs nothing to do ?
# srvpolux01> polux01[pdb01] : start service pdb01_oci
20:20:31> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.40
SQL> exec dbms_service.start_service( 'pdb01_oci' );
BEGIN dbms_service.start_service( 'pdb01_oci' ); END;
*
ERREUR a la ligne 1 :
ORA-44305: le service pdb01_oci est en cours d'execution
ORA-06512: a "SYS.DBMS_SYS_ERROR", ligne 86
ORA-06512: a "SYS.DBMS_SERVICE_ERR", ligne 26
ORA-06512: a "SYS.DBMS_SERVICE", ligne 486
ORA-06512: a ligne 1
Ecoule : 00 :00 :00.39
# =============================================================================
# srvpolux01> polux01 : create service pdb01_java on pluggable database pdb01.
< srvpolux01> modify service without crs nothing to do ?
# srvpolux01> polux01[pdb01] : start service pdb01_java
20:20:32> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.00
SQL> exec dbms_service.start_service( 'pdb01_java' );
BEGIN dbms_service.start_service( 'pdb01_java' ); END;
*
ERREUR a la ligne 1 :
ORA-44305: le service pdb01_java est en cours d'execution
ORA-06512: a "SYS.DBMS_SYS_ERROR", ligne 86
ORA-06512: a "SYS.DBMS_SERVICE_ERR", ligne 26
ORA-06512: a "SYS.DBMS_SERVICE", ligne 486
ORA-06512: a ligne 1
Ecoule : 00 :00 :00.00
20:20:32> $HOME/plescripts/db/create_srv_for_single_db.sh -db=polux01 -pdb=pdb01 -role=physical_standby -start=yes
# Database polux01 role = physical_standby
# =============================================================================
# srvpolux01> polux01 : create service pdb01_stby_oci on pluggable database pdb01.
# srvpolux01> polux01[pdb01] : create service pdb01_stby_oci
20:20:32> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.00
SQL> exec dbms_service.create_service( service_name=>'pdb01_stby_oci', network_name=>'pdb01_stby_oci' );
Procedure PL/SQL terminee avec succes.
Ecoule : 00 :00 :00.22
# srvpolux01> polux01[pdb01] : start service pdb01_stby_oci
20:20:33> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.00
SQL> exec dbms_service.start_service( 'pdb01_stby_oci' );
Procedure PL/SQL terminee avec succes.
Ecoule : 00 :00 :00.04
20:20:33> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_oci -host_name=srvpolux01
# srvpolux01 : Delete TNS alias pdb01_stby_oci if exists.
20:20:33> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_oci
# Alias PDB01_STBY_OCI not found.
# srvpolux01 : Append new alias : pdb01_stby_oci
20:20:33> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_oci -alias_name=pdb01_stby_oci -server_list=srvpolux01 >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
# srvpolux01> polux01 : create service pdb01_stby_java on pluggable database pdb01.
# srvpolux01> polux01[pdb01] : create service pdb01_stby_java
20:20:33> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.00
SQL> exec dbms_service.create_service( service_name=>'pdb01_stby_java', network_name=>'pdb01_stby_java' );
Procedure PL/SQL terminee avec succes.
Ecoule : 00 :00 :00.09
# srvpolux01> polux01[pdb01] : start service pdb01_stby_java
20:20:33> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.00
SQL> exec dbms_service.start_service( 'pdb01_stby_java' );
Procedure PL/SQL terminee avec succes.
Ecoule : 00 :00 :00.00
20:20:33> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_java -host_name=srvpolux01
# srvpolux01 : Delete TNS alias pdb01_stby_java if exists.
20:20:33> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_java
# Alias PDB01_STBY_JAVA not found.
# srvpolux01 : Append new alias : pdb01_stby_java
20:20:33> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_java -alias_name=pdb01_stby_java -server_list=srvpolux01 >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
# =============================================================================
# polux01[pdb01] : stop all standby services.
20:20:33> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.00
SQL> exec dbms_service.stop_service( 'pdb01_stby_oci' );
Procedure PL/SQL terminee avec succes.
Ecoule : 00 :00 :00.00
20:20:33> sqlplus -s sys/Oracle12 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.00
SQL> exec dbms_service.stop_service( 'pdb01_stby_java' );
Procedure PL/SQL terminee avec succes.
Ecoule : 00 :00 :00.01
# =============================================================================
# POLUX02[pdb01] : start all standby services.
20:20:33> sqlplus -s sys/Oracle12@POLUX02 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.28
SQL> exec dbms_service.start_service( 'pdb01_stby_oci' );
BEGIN dbms_service.start_service( 'pdb01_stby_oci' ); END;
*
ERREUR a la ligne 1 :
ORA-44786: Impossible d'executer l'operation de service.
ORA-06512: a "SYS.DBMS_SERVICE", ligne 76
ORA-06512: a "SYS.DBMS_SERVICE", ligne 483
ORA-06512: a ligne 1
Ecoule : 00 :00 :00.43
20:20:34> sqlplus -s sys/Oracle12@POLUX02 as sysdba
SQL> alter session set container=pdb01;
Session modifiee.
Ecoule : 00 :00 :00.03
SQL> exec dbms_service.start_service( 'pdb01_stby_java' );
BEGIN dbms_service.start_service( 'pdb01_stby_java' ); END;
*
ERREUR a la ligne 1 :
ORA-44786: Impossible d'executer l'operation de service.
ORA-06512: a "SYS.DBMS_SERVICE", ligne 76
ORA-06512: a "SYS.DBMS_SERVICE", ligne 483
ORA-06512: a ligne 1
Ecoule : 00 :00 :00.05
# =============================================================================
20:20:34> ~/plescripts/db/update_tns_alias_for_dataguard.sh -pdb=pdb01 -dataguard_list=srvpolux02
# =============================================================================
# Add or update alias pdb01_oci
20:20:34> ~/plescripts/db/add_tns_alias.sh -service=pdb01_oci -host_name=srvpolux01 -dataguard_list="srvpolux02"
# srvpolux01 : Delete TNS alias pdb01_oci if exists.
20:20:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_oci
# Delete alias PDB01_OCI between lines 2 & 12
20:20:35> sed -i '2,12d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:20:35> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvpolux01 : Append new alias : pdb01_oci
20:20:35> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_oci -alias_name=pdb01_oci -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
20:20:35> ssh srvpolux02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_oci -host_name=srvpolux01 -dataguard_list="srvpolux02"'
# srvpolux02 : Delete TNS alias pdb01_oci if exists.
20:20:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_oci
# Alias PDB01_OCI not found.
# srvpolux02 : Append new alias : pdb01_oci
20:20:35> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_oci -alias_name=pdb01_oci -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux02 : $TNS_ADMIN/tnsnames.ora updated.
# Add or update alias pdb01_stby_oci
20:20:35> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_oci -host_name=srvpolux01 -dataguard_list="srvpolux02"
# srvpolux01 : Delete TNS alias pdb01_stby_oci if exists.
20:20:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_oci
# Delete alias PDB01_STBY_OCI between lines 46 & 56
20:20:35> sed -i '46,56d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:20:35> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvpolux01 : Append new alias : pdb01_stby_oci
20:20:35> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_oci -alias_name=pdb01_stby_oci -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
20:20:35> ssh srvpolux02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_oci -host_name=srvpolux01 -dataguard_list="srvpolux02"'
# srvpolux02 : Delete TNS alias pdb01_stby_oci if exists.
20:20:35> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_oci
# Alias PDB01_STBY_OCI not found.
# srvpolux02 : Append new alias : pdb01_stby_oci
20:20:36> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_oci -alias_name=pdb01_stby_oci -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux02 : $TNS_ADMIN/tnsnames.ora updated.
# Add or update alias pdb01_java
20:20:36> ~/plescripts/db/add_tns_alias.sh -service=pdb01_java -host_name=srvpolux01 -dataguard_list="srvpolux02"
# srvpolux01 : Delete TNS alias pdb01_java if exists.
20:20:36> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_java
# Delete alias PDB01_JAVA between lines 2 & 12
20:20:36> sed -i '2,12d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:20:36> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvpolux01 : Append new alias : pdb01_java
20:20:36> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_java -alias_name=pdb01_java -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
20:20:36> ssh srvpolux02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_java -host_name=srvpolux01 -dataguard_list="srvpolux02"'
# srvpolux02 : Delete TNS alias pdb01_java if exists.
20:20:36> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_java
# Alias PDB01_JAVA not found.
# srvpolux02 : Append new alias : pdb01_java
20:20:36> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_java -alias_name=pdb01_java -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux02 : $TNS_ADMIN/tnsnames.ora updated.
# Add or update alias pdb01_stby_java
20:20:36> ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_java -host_name=srvpolux01 -dataguard_list="srvpolux02"
# srvpolux01 : Delete TNS alias pdb01_stby_java if exists.
20:20:36> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_java
# Delete alias PDB01_STBY_JAVA between lines 35 & 45
20:20:36> sed -i '35,45d' $TNS_ADMIN/tnsnames.ora
# Replace multiple empty lines with a single empty line.
20:20:36> sed -i '/^$/N;/^\n$/D' $TNS_ADMIN/tnsnames.ora
# srvpolux01 : Append new alias : pdb01_stby_java
20:20:36> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_java -alias_name=pdb01_stby_java -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux01 : $TNS_ADMIN/tnsnames.ora updated.
20:20:36> ssh srvpolux02 '. .bash_profile && ~/plescripts/db/add_tns_alias.sh -service=pdb01_stby_java -host_name=srvpolux01 -dataguard_list="srvpolux02"'
# srvpolux02 : Delete TNS alias pdb01_stby_java if exists.
20:20:37> ~/plescripts/db/delete_tns_alias.sh -tnsalias=pdb01_stby_java
# Alias PDB01_STBY_JAVA not found.
# srvpolux02 : Append new alias : pdb01_stby_java
20:20:37> ~/plescripts/shell/gen_tns_alias.sh -service=pdb01_stby_java -alias_name=pdb01_stby_java -server_list="srvpolux01 srvpolux02" >> $TNS_ADMIN/tnsnames.ora
# srvpolux02 : $TNS_ADMIN/tnsnames.ora updated.
# Wallet add sys for PDB01 to wallet
20:20:37> ssh -t srvpolux02 '. .bash_profile; ~/plescripts/db/add_sysdba_credential_for_pdb.sh -db=POLUX02 -pdb=PDB01'</dev/null
Pseudo-terminal will not be allocated because stdin is not a terminal.
20:20:37> $HOME/plescripts/db/add_tns_alias.sh -tnsalias=sysPDB01 -service=PDB01 -host_name=srvpolux02
# srvpolux02 : Delete TNS alias sysPDB01 if exists.
20:20:37> ~/plescripts/db/delete_tns_alias.sh -tnsalias=sysPDB01
# Alias SYSPDB01 not found.
# srvpolux02 : Append new alias : sysPDB01
20:20:37> ~/plescripts/shell/gen_tns_alias.sh -service=PDB01 -alias_name=sysPDB01 -server_list=srvpolux02 >> $TNS_ADMIN/tnsnames.ora
# srvpolux02 : $TNS_ADMIN/tnsnames.ora updated.
20:20:37> $HOME/plescripts/db/wallet/create_credential.sh -nolog -tnsalias=sysPDB01 -user=sys -password=Oracle12
20:20:38> $HOME/plescripts/db/wallet/create_wallet.sh -nolog
tput: No value for $TERM and no -T specified
#
# Create wallet store.
20:20:38> mkdir -p $ORACLE_HOME/oracle/wallet
20:20:38> mkstore -wrl $ORACLE_HOME/oracle/wallet -create <<< Oracle12
Enter password:
Enter password again:
tput: No value for $TERM and no -T specified
#
# Update sqlnet.ora
tput: No value for $TERM and no -T specified
#
# Create Oracle pki
20:20:39> orapki wallet create -wallet $ORACLE_HOME/oracle/wallet -auto_login <<< Oracle12
Oracle PKI Tool : Version 12.2.0.1.0
Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
Enter wallet password:
Operation is successfully completed.
20:20:39> mkstore -wrl $ORACLE_HOME/oracle/wallet -nologo -createCredential sysPDB01 sys Oracle12
Enter wallet password:
# Connection to pdb PDB01 with sys user :
# $ sqlplus /@sysPDB01 as sysdba
# ============================================================================================================
# Copy glogin.sql
20:20:40> scp $ORACLE_HOME/sqlplus/admin/glogin.sql srvpolux02:$ORACLE_BASE/12.2.0.1/dbhome_1/sqlplus/admin/glogin.sql
# ============================================================================================================
# Adjust rman config for dataguard.
20:20:41> rman target sys/Oracle12 @$HOME/plescripts/db/rman/ajust_config_for_dataguard.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:20:41 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> configure archivelog deletion policy to applied on all standby;
2>
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
new RMAN configuration parameters are successfully stored
Recovery Manager complete.
20:20:45> ssh -t -t oracle@srvpolux02 ". .bash_profile; rman target sys/Oracle12 @$HOME/plescripts/db/rman/purge.rman"</dev/null
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:20:46 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> delete noprompt copy of database;
2> delete noprompt backup;
3> crosscheck backup;
4> delete noprompt expired backup;
5> crosscheck copy of database;
6> delete noprompt expired copy of database;
7> delete noprompt archivelog all;
8>
[ skipped ]
Recovery Manager complete.
Connection to srvpolux02 closed.
20:21:03> ssh -t -t oracle@srvpolux02 ". .bash_profile; rman target sys/Oracle12 @$HOME/plescripts/db/rman/configure_snapshot_controlfile.rman using '/u02/database/POLUX02/snapshot_ctrl_file.f'"</dev/null
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:21:03 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> # Tous les autres paramètres sont dupliqués via RMAN.
2> configure snapshot controlfile name to "/u02/database/POLUX02/snapshot_ctrl_file.f";
3>
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u02/database/POLUX02/snapshot_ctrl_file.f';
new RMAN configuration parameters are successfully stored
Recovery Manager complete.
Connection to srvpolux02 closed.
20:21:05> ssh -t -t oracle@srvpolux02 ". .bash_profile; rman target sys/Oracle12 @$HOME/plescripts/db/rman/ajust_config_for_dataguard.rman"</dev/null
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:21:05 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> configure archivelog deletion policy to applied on all standby;
2>
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
new RMAN configuration parameters are successfully stored
Recovery Manager complete.
Connection to srvpolux02 closed.
20:21:07> ssh -t -t oracle@srvpolux02 ". .bash_profile; ~/plescripts/db/image_copy_backup.sh"</dev/null
20:21:08> cd $HOME/plescripts/db/rman
# =============================================================================
20:21:08> sqlplus -s sys/Oracle12 as sysdba
SQL> @/home/oracle/plescripts/db/sql/show_corrupted_blocks.sql
aucune ligne selectionnee
Ecoule : 00 :00 :00.49
20:21:08> rman target sys/Oracle12 @recover_corruption_list.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:21:08 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> recover corruption list;
2>
Starting recover at 28-FEB-2018 20:21:09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 28-FEB-2018 20:21:11
Recovery Manager complete.
# =============================================================================
20:21:11> rman target sys/Oracle12 @image_copy.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:21:11 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> run {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> backup incremental level 1 for recover of copy database tag 'incr_for_img_copy';
5> recover copy of database with tag 'reco_img_copy';
6> }
7>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=270 device type=DISK
[ skipped ]
Recovery Manager complete.
20:28:57< rman running time : 7mn46s
# =============================================================================
20:28:57> rman target sys/Oracle12 @backup_archive_log.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:28:57 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> # Evite des erreurs si des archive logs ont été effacées manuellement.
2> run {
3> allocate channel c1 type disk;
4> allocate channel c2 type disk;
5> crosscheck archivelog all;
6> backup tag 'backup_archlog' archivelog all not backed up delete all input;
7> }
8>
[ skipped ]
Recovery Manager complete.
# =============================================================================
20:29:07> rman target sys/Oracle12 @crosscheck.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:29:07 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> crosscheck backup;
2> delete noprompt expired backup;
3>
4> crosscheck copy of database;
5> delete noprompt expired copy of database;
6>
7> crosscheck archivelog all;
8> delete noprompt expired archivelog all;
9>
10> crosscheck datafilecopy all;
11> delete noprompt obsolete;
12>
[ skipped ]
Recovery Manager complete.
20:29:11> cd -
/home/oracle
# =============================================================================
20:29:11> ~/plescripts/db/validate_backup.sh
# Validate backup.
# Validate copy of database.
20:29:11> rman target=sys/Oracle12 @$HOME/plescripts/db/rman/validate_copy_of_database.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:29:11 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> run {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> validate copy of database;
5> }
6>
[ skipped ]
Recovery Manager complete.
20:30:40< rman running time : 1mn29s
# Validate archivelogs.
20:30:40> rman target=sys/Oracle12 @$HOME/plescripts/db/rman/validate_archivelog.rman
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Feb 28 20:30:40 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: POLUX01 (DBID=3488973754)
RMAN> run {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> validate archivelog all;
5> }
6>
[ skipped ]
20:30:44< ~/plescripts/db/validate_backup.sh running time : 1mn33s
# Bakup valid !
# =============================================================================
# Espace disque avant backup :
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgorcl-lvorcl 20G 7.3G 13G 37% /u01
/dev/mapper/vgoradata-lvoradata 16G 4.9G 12G 31% /u02
/dev/mapper/vgorafra-lvorafra 16G 1.2G 15G 8% /u03
# Espace disque après backup :
20:30:44> df -h /u01 /u02 /u03
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgorcl-lvorcl 20G 7.3G 13G 37% /u01
/dev/mapper/vgoradata-lvoradata 16G 4.9G 12G 31% /u02
/dev/mapper/vgorafra-lvorafra 16G 5.2G 11G 33% /u03
# script image_copy_backup.sh running time : 9mn36s
Connection to srvpolux02 closed.
20:30:44< ~/plescripts/db/image_copy_backup.sh"</dev/null (ssh) running time : 9mn37s
20:30:44> ~/plescripts/db/stby/show_dataguard_cfg.sh
# Primary polux01
20:30:46> dgmgrl -silent -echo sys/Oracle12<<EO_CMD
Connected to "POLUX01"
show configuration
Configuration - DGCONF
Protection Mode: MaxPerformance
Members:
polux01 - Primary database
polux02 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 58 seconds ago)
show database polux01
Database - polux01
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
POLUX01
Database Status:
SUCCESS
validate database polux01
Database Role: Primary database
Ready for Switchover: Yes
Managed by Clusterware:
polux01: NO
Warning: Ensure primary database's StaticConnectIdentifier property
is configured properly so that the primary database can be restarted
by DGMGRL after switchover
# 1 physical database(s)
# =============================================================================
# Physical polux02
20:30:48> dgmgrl -silent -echo sys/Oracle12<<EO_CMD
Connected to "POLUX01"
show database polux02
Database - polux02
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 1 second ago)
Average Apply Rate: 11.00 KByte/s
Real Time Query: ON
Instance(s):
POLUX02
Database Status:
SUCCESS
validate database polux02
Database Role: Physical standby database
Primary Database: polux01
Ready for Switchover: Yes
Ready for Failover: Yes (Primary Running)
Managed by Clusterware:
polux01: NO
polux02: NO
Warning: Ensure primary database's StaticConnectIdentifier property
is configured properly so that the primary database can be restarted
by DGMGRL after switchover
# script create_dataguard.sh running time : 18mn20s
# log 20h12mn29_oracle_on_srvpolux01_create_dataguard.log copied to /home/oracle/log/2018-02-28