Thursday 5 September 2019

export backup script


# $Header: EXP_TAB_cmprss.sh 
# *====================================================================================+
# |  Author - DBACLASS ADMIN TEAM
# |                                                       |
# +====================================================================================+
# |
# | FILENAME
# |     EXP_table_bkp_cmprss_dbaclass.sh
# |
# | DESCRIPTION
# |     Daily Export backup script of a list of table
# | PLATFORM
# |     Linux/Solaris

# +===========================================================================+
#!/bin/bash
echo Set Oracle Database Env
export ORACLE_SID=$1
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin
export TIMESTAMP=`date +%a%d%b%Y`
export dir1=/u02/backup/export

echo =======
echo Export command
echo =======
echo $ORACLE_HOME
$ORACLE_HOME/bin/expdp \'/ as sysdba\' directory=dir1 dumpfile=expdp_pdb1_${TIMESTAMP}_%U.dmp logfile=expdp_log_${TIMESTAMP}.log full=y
PARALLEL=6  COMPRESSION=ALL

echo SEND MAIL TO STAKE HOLDERS
echo =======
mailx -s "$ORACLE_SID $TIMESTAMP Export backup logfile" shymon.ravi@nttdata.com < $EXP_DIR/expdp_log_${TIMESTAMP}.log
echo Export completed at $TIMESTAMP
exit



chmod 755 EXP_TAB_cmprss.sh

00 15  * * * /u02/backup/export/export.sh  PHFMDB

listener.ora

ADMIN_RESTRICTIONS_LISTENER = on

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = sdefr2pldb02.moviantogroup.com)(PORT = 1523))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1523))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
       (ORACLE_HOME = /oraclebase/app/oracle/product/18.0.0/dbhome_1)
      (SID_NAME = PRIPRDSBY)
      (ORACLE_HOME = /oraclebase/app/oracle/product/18.0.0/dbhome_1)
      (SID_NAME = PRIPRD)
    )
  )





ADR_BASE_LISTENER = /oraclebase/dump/
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent
VALID_NODE_CHECKING_REGISTRATION_LISTENER=ON

WORKLOAD MANAGEMENT IN 11g R2 RAC : LOAD BALANCING


will discuss about various types of load balancing techniques that can be configured in 11g R2 RAC for workload management.
In RAC we have multiple instances of a database running on multiple servers.
Workload management involves :
   – Failover : If connection to an instance fails, client should automatically connect to another instance
   – Load balancing : Workload should spread across various instances to obtain maximum performance/throughput
Failover can be
  – Connect Time Connection Failover (CTCF) while making initial connection ()
  - Run time connection failover (RTCF) after connection has been established or (transparent application failover (TAF)
     FAILOVER_METHOD = NONE, BASIC, PRECONNECT
     FAILOVER TYPE   = SESSION, SELECT
Load balancing can be :
  – Connect time load balancing (CTLB)
    . On client side
    . On server side
  –  Run time load balancing (RTLB)
TO configure failover/load balancing, tnsnames.ora should contain multiple listener addresses to connect to multiple instances e.g.
Multiple Listener addresses within a description: i.e. User is trying to connect to a service which is supported by multiple instances.
RAC=
(DESCRIPTION=
   (ADDRESS_LIST=
     (ADDRESS= (PROTOCOL=TCP) (HOST=node1-vip) (PORT=1521))
     (ADDRESS= (PROTOCOL=TCP) (HOST=node2-vip) (PORT=1521))
     (ADDRESS= (PROTOCOL=TCP) (HOST=node3-vip) (PORT=1521))
     (ADDRESS= (PROTOCOL=TCP) (HOST=node4-vip) (PORT=1521))
                      )
    (CONNECT_DATA= (SERVICE_NAME= RAC))
       )
In case SCAN is used, SCAN name is used in the address which resolves to 3 SCAN listeners.
e.g.
RAC=
(DESCRIPTION=
   (ADDRESS_LIST=
     (ADDRESS= (PROTOCOL=TCP) (HOST=cluster01-scan) (PORT=1521))
                      )
    (CONNECT_DATA= (SERVICE_NAME= RAC))
       )
In this post, I will discuss in detail about Load Balancing. To know more about failover , please click here.
LOAD BALANCING 
————–
Load balancing in RAC implies distributing the workload over multiple instances accessing the same physical database. Two kinds load balancing can be configured
  – Connect time load balancing (CTLB)
    . On client side
    . On server side
  – On server side – Run time load balancing (RTLB)
Connect time load balancing (CTLB) : This enables user to connect to one of the instances supporting the service. The connection stays with the same instance until the user disconnects orthe session is killed. It can be configured on the client side and/or server side.
Connect time load balancing on client side: When a user session attempts to connect to the database, Oracle Net chooses an address specified in tnsnames.ora to connect to in a random order rather than sequential order. This has the effect of clients connecting through addresses which are picked up at random and no one address is overloaded. Its configuration is quite simple. You just need to set the parameter LOAD_BALANCE=ON in the client connection definition in tnsnames.ora. For example :
RAC=
(DESCRIPTION=
  (ADDRESS_LIST=
                       (LOAD_BALANCE=ON)
    (ADDRESS= (PROTOCOL=TCP) (HOST=node1-vip) (PORT=1521))
                       (ADDRESS= (PROTOCOL=TCP) (HOST=node2-vip) (PORT=1521))
    (ADDRESS= (PROTOCOL=TCP) (HOST=node3-vip) (PORT=1521))
    (ADDRESS= (PROTOCOL=TCP) (HOST=node4-vip) (PORT=1521))
                      )
   (CONNECT_DATA= (SERVICE_NAME= RAC)
       )
LOAD_BALANCE parameter is set to ON by default. When this parameter is set to ON, Oracle Net Services progresses through the list of listener addresses in a random sequence, balancing the load on several listeners. When it is set to OFF, the addresses are tried out sequentially until one succeeds.
When using SCAN in the connection definition, Oracle database randomly connects to one of the available SCAN listeners in a round robin fashion and balances the connections on the three scan listeners. Here is a sample tnsnames.ora for a RAC database using SCAN.
RAC=
(DESCRIPTION=
    (LOAD_BALANCE=ON)
    (ADDRESS= (PROTOCOL=TCP) (HOST=SCAN-HOSTNAME) (PORT=1521))
                  )
   (CONNECT_DATA= (SERVICE_NAME= RAC)
       )
Limitation of connect time load balancing : The connection stays with the same instance for the life of a session. If connection lasts a long time, it might be possible that load of current instance increases and some other less loaded instance might be preferable. In that case we would like the connection to switch the other more appropriate instance. This can be achieved by using Run time Load Balancing (RTLB).
Connect time load balancing on server side: After a listener receives the connection request, it can forward the request to another instance based on the connect time load balancing goal (CLB_GOAL)specified for the service. CLB_GOAL can be :
LONG(Default) - used for application connections that are connected for a long period such as third party connection pools and SQL*Forms applications. In this case,
   . the listener will load balance on number of sessions
   . Run time load balancing goal will not be used in this case
SHORT - used for application connections that are short in duration. This should be used with connection pools integrated with the load balancing advisory. In this case, listener uses Load Balancing Advisory (LBA) to make the connection based on CPU utilization on the node.
Limitation of Connect time load balancing on client side : The listener has no idea if the session has been assigned to an endpoint whose corresponding database server is already overloaded. Hence, timeouts can occur if the node is heavily loaded and unable to respond quickly.Hence, to overcome this problem, server side connect time load balancing needs to be configured. It is useful to spread initial connection load among all listeners inthe cluster. Client may then be redirected based on server side load balancing.
Run Time (Server side) load Balancing (RTLB): In this case, the listener routes incoming client connections according to policies and based on the current service level provided by the database instances. The listener determines the connection distribution depending upon profile statistics that  are dynamically updated by PMON. The higher the load on the node, the more frequently PMON updates the load profile.Thus connections may be switched depending upon changes in cluster configuration, application wrokload  overworked nodes or hangs.
   The core of server side laod balancing id Dynamic service registration so that a services are registered with all the listeners. Since PMON on each node sends load profile to all the listeners with which the service is registered,  all the  listeners come to know about load profile of all the instances and hence the connection is forwarded to the most appropriate listener depending upon the goal of the run time load balancing.
  Run time load balancing is achieved using connection pools. Work requests are automatically balanced across the pool of connections.The connection allocation is based on the current performance level provided by the database instances as indicated by the LBA FAN events. This provides load balancing at the transaction level instead of load balancing at the time of initial connection. 
With server-side load balancing, the listener directs a connection request to the best instance currently providing the service by using the load balancing advisory.
Load Balancing Advisory
- is an advisory for balancing work across RAC instances
- Monitors workload activity for a service across all instances in the cluster
- Analyzes the service level for each instance based on defined metric goal
    Metric: service time (GOAL_SERVICE_TIME)
    Metric: throughput (GOAL_THROUGHPUT)
- Publishes FAN events recommending amount of work to be sent to each instance and data quality  flag
- Default is Off.
-  Directs work to where services are executing well and resources are available
- Adjusts distribution for different power nodes, different priority and shape workloads, changing demand
- Stops sending work to slow, hung, failed nodes early
How to configure server side load balancing:
1. set parameters LOCAL_LISTENER and REMOTE_LISTENER
2. set CLB_GOAL = SHORT for the service
3. set RTLB_GOAL for the service
1. set parameters LOCAL_LISTENER and REMOTE_LISTENER
LOCAL_LISTENER parameter should be set to name of the listener defined in the same node
REMOTE_LISTENER should be set to names of the listeners running on other nodes
For example in a 3 node setup
Host01 running instance orcl1
Host02 running instance orcl2
Host03 running instance orcl3
For host01,
local_listener  – (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) HOST=host01-vip)(PORT=1521))))
remote_listener  – (DESCRIPTION=(ADDRESS_LIST=
                                 (ADDRESS=(PROTOCOL=TCP) HOST=host02-vip)(PORT=1521)
                                 (ADDRESS=(PROTOCOL=TCP) HOST=host03-vip)(PORT=1521))))
For host02,
local_listener  – (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) HOST=host02-vip)(PORT=1521))))
remote_listener  – (DESCRIPTION=(ADDRESS_LIST=
                                 (ADDRESS=(PROTOCOL=TCP) HOST=host01-vip)(PORT=1521)
                                 (ADDRESS=(PROTOCOL=TCP) HOST=host03-vip)(PORT=1521))))
For host03,
local_listener  – (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) HOST=host03-vip)(PORT=1521))))
remote_listener  – (DESCRIPTION=(ADDRESS_LIST=
                                 (ADDRESS=(PROTOCOL=TCP) HOST=host02-vip)(PORT=1521)
                                 (ADDRESS=(PROTOCOL=TCP) HOST=host01-vip)(PORT=1521))))
When we start the three instances the corresponding PMON processes get dynamically registered with all the listeners and start feeding listeners with load profile information. Now all the listeners come to know about load profile of all the instances and hence the connection is forwarded to the listener of the least loaded node.
When SCAN is used, remote_listener parameter should be set to SCAN name on all the nodes i.e.
remote_listener – myrac-cluster-scan:1521
So that PMON process of each instance registers the database services with the default listener on the local node and with each SCAN listener, which is specified by the REMOTE_LISTENER database parameter.
2. set CLB_GOAL = SHORT for the service
   EXECUTE DBMS_SERVICE.MODIFY_SERVICE
   (service_name => ‘sjob’ -
   , clb_goal => DBMS_SERVICE.CLB_GOAL_SHORT);
OR
   srvctl modify service
      -s orcl_serv database -d orcl
      -j SHORT   // connection load balancing goal {long|short}
3. set RTLB_GOAL for the service
A request for a connection is serviced by selecting a connection based on the service goal as determined by the Load Balancing Advisory. The service goal determines whether the connection provides best service quality, that is, how efficiently a single transaction completes, or best throughput, that is, how efficiently an entire job or long-running query completes.
For RTLB, we can define service level goal which will be used only if CLB_GOAL= SHORT
There are 3 options available
NONE – Default setting, you are not taking advantage of this feature
THROUGHPUT – Work requests are directed based on throughput.  THROUGHPUT should be used when the work in a service completes at homogenous rates.  An example is a trading system where work requests are similar lengths. Attempts to direct work requests according to throughput. The load balancing advisory analyzes the service level for each instance based on the service time and is based on the rate that work is completed in the service plus available bandwidth to the service. For example for the use of THROUGHPUT is for workloads such as batch processes,trading system work requests have similar lengths and  next job starts when the last job completes:
EXECUTE DBMS_SERVICE.MODIFY_SERVICE
 (service_name => ‘sjob’ -
  , goal => DBMS_SERVICE.GOAL_THROUGHPUT );
OR
srvctl modify  service
      -s orcl_serv database -d orcl
      -B throughput      // runtime connection load balancing goal { service_time|throughput | none}
SERVICE_TIME – Work requests are directed based on response time. SERVICE_TIME should be used when the work in a service completes at various rates.  In this case, Load balancing advisory data is based on elapsed time for work done in the service plus available bandwidth to the service. An example for the use of SERVICE_TIME is for workloads such as internet shopping where the rate of demand changes and work requests are of differing various lengths.:
EXECUTE DBMS_SERVICE.MODIFY_SERVICE
(service_name => ‘OE’ -
, goal => DBMS_SERVICE.GOAL_SERVICE_TIME -
);
OR
srvctl modify  service
      -s orcl_serv database -d orcl
      -B service_time      // runtime connection load balancing goal { service_time|throughput | none}
 You can see the goal settings for a service in the data dictionary and in the DBA_SERVICES, V$SERVICES, and V$ACTIVE_SERVICES views.
SUMMARY:
Workload management involves :
   – Failover : If connection to an instance fails, client should automatically connect to another instance
   – Load balancing : Workload should spread across various instances to obtain maximum performance/throughput
Load balancing can be :
  – Connect time load balancing (CTLB)
    . On client side
    . On server side
  –  Run time load balancing (RTLB)
TO configure failover/load balancing, tnsnames.ora should contain multiple listener addresses to connect to multiple instances
Connect time load balancing (CTLB) : This enables user to connect to one of the instances supporting the service. The connection stays with the same instance until the user disconnects orthe session is killed. It can be configured on the client side and/or server side.
Connect time load balancing on client side: When a user session attempts to connect to the database, Oracle Net chooses an address specified in tnsnames.ora to connect to in a random order rather than sequential order. This has the effect of clients connecting through addresses which are picked up at random and no one address is overloaded. Its configuration is quite simple. You just need to set the parameter LOAD_BALANCE=ON in the client connection definition in tnsnames.ora.
Limitation of Connect time load balancing (CTLB) on client side : The listener has no idea if the session has been assigned to an endpoint whose corresponding database server is already overloaded.
Connect time load balancing (CTLB) on server side: After a listener receives the connection request, it can forward the request to another instance based on the connect time load balancing goal (CLB_GOAL)specified for the service. CLB_GOAL can be : LONG or SHORT
LONG(Default) – In this case,
   . the listener will load balance on number of sessions
   . Run time load balancing goal will not be used in this case
SHORT - used for application connections that are short in duration. This should be used with connection pools integrated with the load balancing advisory. In this case, listener uses Load Balancing Advisory (LBA) to make the connection based on CPU utilization on the node.
Limitation of connect time load balancing : The connection stays with the same instance for the life of a session. If connection lasts a long time, it might be possible that load of current instance increases and some other less loaded instance might be preferable.
Run Time (Server side) load Balancing (RTLB): In this case, the listener routes incoming client connections according to policies and based on the current service level provided by the database instances. With server-side load balancing, the listener directs a connection request to the best instance currently providing the service by using the load balancing advisory.
To configure server side load balancing:
1. set parameters LOCAL_LISTENER and REMOTE_LISTENER
2. set CLB_GOAL = SHORT for the service
3. set RTLB_GOAL for the service

create of physical standby through active database


source and target database should be same configuration



primary





SQL> select name, open_mode, database_role, INSTANCE_NAME from v$database,v$instance;



NAME      OPEN_MODE            DATABASE_ROLE    INSTANCE_NAME

--------- -------------------- ---------------- ----------------

Ram    READ WRITE           PRIMARY          Ram





SQL> select force_logging from v$database;



FORCE_LOGGING

---------------------------------------

NO







SQL> ALTER DATABASE FORCE LOGGING;



Database altered.



SQL> select force_logging from v$database;



FORCE_LOGGING

---------------------------------------

YES





[oracle@rac1 ~]$ cd $ORACLE_HOME/dbs

[oracle@rac1 dbs]$ rm hc_apac.dat

[oracle@rac1 dbs]$ ls -ltr

total 20

-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora

-rw-r----- 1 oracle oinstall   24 Jan  6 22:46 lkW5005PR

-rw-r----- 1 oracle oinstall 1536 Jan  6 22:47 orapww5005pr

-rw-r----- 1 oracle oinstall   41 Jan  6 22:48 initw5005pr.ora

-rw-rw---- 1 oracle oinstall 1544 Jan  6 22:48 hc_w5005pr.dat

[oracle@rac1 dbs]$





configure standby redolog on primary



SQL> set lines 180

col MEMBER for a60

select b.thread#, a.group#, a.member, b.bytes FROM v$logfile a, v$log b WHERE a.group# = b.group#;SQL> SQL>



   THREAD#     GROUP# MEMBER                                                            BYTES

---------- ---------- ------------------------------------------------------------ ----------

         1          3 +DATA01/Ram/ONLINELOG/group_3.259.1018027407               209715200

         1          3 +FLASH01/Ram/ONLINELOG/group_3.1590.1018027409             209715200

         1          2 +DATA01/Ram/ONLINELOG/group_2.267.1018027407               209715200

         1          2 +FLASH01/Ram/ONLINELOG/group_2.1589.1018027409             209715200

         1          1 +DATA01/Ram/ONLINELOG/group_1.260.1018027407               209715200

         1          1 +FLASH01/Ram/ONLINELOG/group_1.1591.1018027409             209715200



6 rows selected.





ALTER DATABASE ADD standby logfile thread 1 group 4 ( '+DATA01','+FLASH01') SIZE 200m;



SQL> ALTER DATABASE ADD standby logfile thread 1 group 5 ('+DATA01','+FLASH01') size 200m;



Database altered.



SQL> ALTER DATABASE ADD standby logfile thread 1 group 6 ('+DATA01','+FLASH01') size 200m;



Database altered.



SQL>  ALTER DATABASE ADD standby logfile thread 1 group 7 ('+DATA01','+FLASH01') size 200m;



Database altered.





SQL> show parameter pfile;



NAME       TYPE         VALUE

---------- ----------- --------------------------------

spfile     string       +DATA/w5005pr/spfilew5005pr.ora



SQL> create pfile='/home/oracle/initw5005pr.ora.bkp' from spfile;



File created.



SQL> alter system set db_unique_name='Ram' scope=spfile;



System altered.



SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(Ram,RamSBY)' scope=both;



System altered.



SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+FLASH01 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=Ram' scope=both;



System altered.



SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=RamSBY LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=RamSBY' scope=both;



System altered.



SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both;



System altered.



SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both;



System altered.



SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' SCOPE=SPFILE;



System altered.



SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=30 scope=both;



System altered.



SQL> ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;



System altered.



SQL> ALTER SYSTEM SET fal_client=Ram scope=both;



System altered.



SQL> ALTER SYSTEM SET fal_server=RamSBY scope=both;



System altered.



SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;



System altered.



SQL> create pfile='/oraclebase/app/oracle/product/18.0.0/dbhome_1/dbs/initRam' from spfile;



File created.



SQL>





Copy the password file from the primary $ORACLE_HOME/dbs and rename it to the standby database name.

The username is required to be SYS and the password needs to be the same on the Primary and Standby.

The best practice for this is to copy the passwordfile as suggested.

The password file name must match the instance name/SID used at the standby site, not the DB_NAME





copy the initora file to standylocation and change it accordingly.



prod pfile

Ram.__data_transfer_cache_size=0

Ram.__db_cache_size=22817013760

Ram.__inmemory_ext_roarea=0

Ram.__inmemory_ext_rwarea=0

Ram.__java_pool_size=268435456

Ram.__large_pool_size=335544320

Ram.__oracle_base='/oraclebase/app/oracle'#ORACLE_BASE set from environment

Ram.__pga_aggregate_target=3422552064

Ram.__sga_target=26910654464

Ram.__shared_io_pool_size=536870912

Ram.__shared_pool_size=2885681152

Ram.__streams_pool_size=0

*.audit_file_dest='/oraclebase/app/oracle/admin/Ram/adump'

*.audit_trail='db'

*.compatible='18.0.0'

*.control_files='+DATA01/Ram/CONTROLFILE/current.261.1018026219','+FLASH01/Ram/CONTROLFILE/current.256.1018026219'#Restore Controlfile

*.db_block_size=8192

*.db_create_file_dest='+DATA01'

*.db_create_online_log_dest_1='+DATA01'

*.db_create_online_log_dest_2='+FLASH01'

*.db_name='Ram'

*.db_recovery_file_dest_size=100006m

*.db_recovery_file_dest=''

*.db_unique_name='Ram'

*.diagnostic_dest='/oraclebase/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=RamXDB)'

*.fal_client='Ram'

*.fal_server='RamSBY'

*.local_listener='LISTENER_Ram'

*.log_archive_config='DG_CONFIG=(Ram,RamSBY)'

*.log_archive_dest_1='LOCATION=+FLASH01 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=Ram'

*.log_archive_dest_2='SERVICE=RamSBY LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=RamSBY'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.log_archive_format='%t_%s_%r.arc'

*.log_archive_max_processes=30

*.nls_language='AMERICAN'

*.nls_territory='AMERICA'

*.open_cursors=300

*.pga_aggregate_target=3201m

*.processes=1280

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=25602m

*.standby_file_management='AUTO'

*.star_transformation_enabled='TRUE'

*.undo_tablespace='UNDOTBS1'





standby pfile





RamSBY.__data_transfer_cache_size=0

RamSBY.__db_cache_size=22817013760

RamSBY.__inmemory_ext_roarea=0

RamSBY.__inmemory_ext_rwarea=0

RamSBY.__java_pool_size=268435456

RamSBY.__large_pool_size=335544320

RamSBY.__oracle_base='/oraclebase/app/oracle'#ORACLE_BASE set from environment

RamSBY.__pga_aggregate_target=3422552064

RamSBY.__sga_target=26910654464

RamSBY.__shared_io_pool_size=536870912

RamSBY.__shared_pool_size=2885681152

RamSBY.__streams_pool_size=0

*.audit_file_dest='/oraclebase/app/oracle/admin/RamSBY/adump'

*.audit_trail='db'

*.compatible='18.0.0'

*.control_files='+DATA01','+FLASH01'#Restore Controlfile

*.db_block_size=8192

*.db_create_file_dest='+DATA01'

*.db_create_online_log_dest_1='+DATA01'

*.db_create_online_log_dest_2='+FLASH01'

*.db_name='Ram'

*.db_recovery_file_dest_size=100006m

*.db_recovery_file_dest=''

*.db_unique_name='RamSBY'

*.diagnostic_dest='/oraclebase/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=RamSBYXDB)'

*.fal_client='RamSBY'

*.fal_server='Ram'

*.local_listener='LISTENER_RamSBY'

*.log_archive_config='DG_CONFIG=(RamSBY,Ram)'

*.log_archive_dest_1='LOCATION=+FLASH01 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=RamSBY'

*.log_archive_dest_2='SERVICE=Ram LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=Ram'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='DEFER'

*.log_archive_format='%t_%s_%r.arc'

*.log_archive_max_processes=30

*.nls_language='AMERICAN'

*.nls_territory='AMERICA'

*.open_cursors=300

*.pga_aggregate_target=3201m

*.processes=1280

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=25602m

*.standby_file_management='AUTO'

*.star_transformation_enabled='TRUE'

*.undo_tablespace='UNDOTBS1'





***********************************************







mkdir -p /u01/app/oracle/admin/Ramsby/adump





startup nomount pfile='/oraclebase/app/oracle/product/18.0.0/dbhome_1/dbs/initRamSBY';









create spfile='+DATA01/RamSBY/spfileRamSBY.ora' from pfile='/oraclebase/app/oracle/product/18.0.0/dbhome_1/dbs/initRamSBY';









startup nomount force;



show parameter pfile



SELECT thread#, group#, sequence#, bytes, archived, status FROM v$standby_log order by thread#, group#;







--Example for two members

--alter database add standby logfile THREAD 1 group 5 ('D:\ORACLEXE\STANDBYREDO01A.log','D:\ORACLEXE\STANDBYREDO01B.log') SIZE 200M;


--Example for ASM
--alter database add standby logfile THREAD 1 group 7 ('+DATA(ONLINELOG)','+FRA(ONLINELOG)') SIZE 200M;



configure listener and tnsnames



srvctl modify scan_listener -p TCP:1523



srvctl modify listener -p TCP:1523



Verify connection ‘AS SYSDBA’ from Primary



Verify connection ‘AS SYSDBA’ from Standby



Run the duplicate from active database command from primary



rman target sys/ChangeMe2019@Ram auxiliary sys/ChangeMe2019@RamSBY

duplicate target database for standby from active database nofilenamecheck;

once completed


"alter database mount standby database;
database altered;"
alter database recover managed standby database disconnect from session;
alter system set log_archive_dest_state_2=defer;


on primary



select name, open_mode, database_role, INSTANCE_NAME from v$database,v$instance;


SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SQL> alter system switch logfile;



System altered.



SQL> alter system switch logfile;



System altered.



SQL> select max(sequence#) from v$archived_log where archived='YES';



MAX(SEQUENCE#)

--------------

            10



standyb





SQL> select name, open_mode, database_role, INSTANCE_NAME from v$database,v$instance;



NAME      OPEN_MODE            DATABASE_ROLE    INSTANCE_NAME

--------- -------------------- ---------------- ----------------

ddd   READ ONLY WITH APPLY PHYSICAL STANDBY standy



SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;



 SEQUENCE# FIRST_TIM NEXT_TIME

---------- --------- ---------

         6 07-JAN-16 07-JAN-16

         7 07-JAN-16 07-JAN-16

         8 07-JAN-16 07-JAN-16

         9 07-JAN-16 07-JAN-16

        10 07-JAN-16 07-JAN-16



SQL> select max(sequence#) from v$archived_log where applied='YES';



select process,status,sequence#,thread# from v$managed_standby;



SQL> ALTER SYSTEM SET log_archive_dest_state_2 = DEFER;



System altered.



SQL> ALTER SYSTEM SET log_archive_dest_state_2 =enable';

ALTER SYSTEM SET log_archive_dest_state_2 =enable'

                                                 *

ERROR at line 1:

ORA-01756: quoted string not properly terminated





SQL> ALTER SYSTEM SET log_archive_dest_state_2 = ENABLE;



System altered.







[oracle@rac2 ~]$ which srvctl

/u01/app/oracle/product/11.2.0/db_1/bin/srvctl

[oracle@rac2 ~]$ srvctl add database -d w5005prg -o /u01/app/oracle/product/11.2.0/db_1/ -r physical_standby -s 'READ ONLY'

[oracle@rac2 ~]$ srvctl start database -d w5005prg



[oracle@rac2 ~]$ /u01/app/11.2.0/grid/bin/crsctl stat res -t

--------------------------------------------------------------------------------

NAME           TARGET  STATE        SERVER                   STATE_DETAILS

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------





applying retention policy for rman on both primary and standby



CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;

or


CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;



On Primary Site :
Connect with sys and :
SQL>Alter system set  "_log_deletion_policy" = 'ALL' scope=both;

The Archivelogs will be deleted on stanby site when a "Backup Database occurs in Primary Site" !!! To be confirmed



SELECT DEST_ID,dest_name,status,type,srl,RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS;






Featured post

Postgres commads

 [oracle@Tesdb ~]$ systemctl status postgresql-15 ● postgresql-15.service - PostgreSQL 15 database server    Loaded: loaded (/usr/lib/system...