Step By Step Oracle Dataguard Physical Standby Server --11gr2 Vmware(Linux Platform) Script Mode, Creating New Db With Dataguard Setup
PRIMARY(initk1.ora) STANDBY(initk2.ora)
db_name --> k1 k1
db_unique_name --> K1 K2
directory_name --> k1 k2
server_ip --> 192.168.211.133 192.168.211.135
tns_name --> k1tns k2tns
SAMPLE SYNOPSIS:-
-----------------------------------------------------------------------------------------------------------
step 1) create structure in standby_db
step 2)copy "pfk1" at prim_db server for creating primary db
step 3)run "dbk1.sh" at primary and send primary db data to standby using scp
step 5)check status of "fairewal->disable" and run "lister->started" for two server
step 6)copy "pfk2" at stand_db server
step 7)run "dbk2.sh"
------------------------------------------------------------------------------------------------------------
1)create standby_db structre ---------->for stand_db
cd
mkdir k2
cd k2
mkdir admin oradata
cd admin
mkdir pfile diag create
cd ..
cd oradata
mkdir control log archive data
cd
2)vi dbk1.sh ----->for creating prim_db in primserver
mkdir k1
cd k1
mkdir admin oradata
cd admin
mkdir pfile diag create
cd ..
cd oradata
mkdir control log archive data
cd
cp /home/oracle/pfk1 /home/oracle/k1/admin/pfile/initk1.ora
cd
export ORACLE_SID=k1
sqlplus / as sysdba <<EOF
startup pfile='/home/oracle/k1/admin/pfile/initk1.ora' nomount;
create database k1
datafile '/home/oracle/k1/oradata/data/system01.dbf' size 400m
sysaux datafile '/home/oracle/k1/oradata/data/systemaux01.dbf' size 300m
undo tablespace undo01 datafile '/home/oracle/k1/oradata/data/undo01.dbf' size 100m
default temporary tablespace temp01 tempfile '/home/oracle/k1/oradata/data/temp01.dbf' size 100m
logfile group 1 '/home/oracle/k1/oradata/log/log01.log' size 10m,
group 2 '/home/oracle/k1/oradata/log/log02.log' size 10m;
@?/rdbms/admin/catalog.sql;
@?/rdbms/admin/catproc.sql;
create spfile from pfile='/home/oracle/k1/admin/pfile/initk1.ora';
alter database add standby logfile group 3 '/home/oracle/k1/oradata/log/std3.log' size 100m;
alter database add standby logfile group 4 '/home/oracle/k1/oradata/log/std4.log' size 100m;
create table kf(id number(10));
create tablespace tbs datafile '/home/oracle/k1/oradata/data/tbs.dbf' size 500m;
exec dbms_logmnr_d.set_tablespace('tbs');
alter database add supplemental log data(all) columns;
alter database close;
alter database archivelog;
shut immediate;
!
EOF
export ORACLE_SID=k1
sqlplus / as sysdba <<EOF
startup pfile='/home/oracle/k1/admin/pfile/initk1.ora';
create spfile from pfile='/home/oracle/k1/admin/pfile/initk1.ora';
alter database close;
alter database create standby controlfile as '/home/oracle/control01.ctl';
shut immediate;
!cd $ORACLE_HOME/dbs
!export ORACLE_SID=k1
!orapwd file=orapwk1 password=sys force=y
EOF
3)vi pfk1 -------->for prim_db initialization file
vi initk1.ora
db_name=k1
sga_target=600m
control_files='/home/oracle/k1/oradata/control/control01.ctl'
diagnostic_dest='/home/oriacle/k1/admin/diag'
log_archive_config='DG_CONFIG=(k1,k2)'
db_unique_name=k1
log_archive_dest_2='SERVICE=k2tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=k2'
db_file_name_convert='/home/oracle/k2/oradata/data','/home/oracle/k1/oradata/data'
log_file_name_convert='/home/oracle/k2/oradata/log','/home/oracle/k1/oradata/log'
fal_client=k1tns
fal_server=k2tns
standby_file_management=auto
remote_login_passwordfile=exclusive
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
4)server prim db listener and tns
vi listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.211.133)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = k1)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
)
tnsnames.ora
k1tns =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.211.133)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = k1)
)
)
k2tns =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.211.135)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = k2)
)
)
4.1)server stand_db listener and tns
vi listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.211.135)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = k2)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
)
)
tnsnames.ora
k2tns =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.211.135)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = k2)
)
)
k1tns =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.211.133)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = k1)
)
)
5)PING TWO SERVER AFTER STARTED LISTER THEN SEND DATA TO PRIMARY TO STANDBY SERVER
[root@localhost6 ~]# /sbin/ifconfig
[root@localhost6 ~]# neat
[root@localhost6 ~]# service network restart
[root@test3 ~]# service iptables status
Firewall is stopped.
[root@test3 ~]# service iptables stop
[root@test3 ~]#
ping server from 192.168.211.133:-
ping 192.168.211.135
ping 192.168.211.133
ping server from 192.168.211.135:-
ping 192.168.211.135
ping 192.168.211.133
ping 192.168.211.133
scp send data
scp /home/oracle/control01.ctl oracle@192.168.211.135:/home/oracle/k2/oradata/control/
(copy paste individual)
scp /home/oracle/k1/oradata/data/* oracle@192.168.211.135:/home/oracle/k2/oradata/data/
6) here create password file also ------------>for stand_db
vi dbk2.sh
cp /home/oracle/pfk2 /home/oracle/k2/admin/pfile/initk2.ora
cd $ORACLE_HOME/dbs
export ORACLE_SID=k2
orapwd file=orapwk2 password=sys force=y
export ORACLE_SID=k2
sqlplus / as sysdba <<EOF
startup pfile='/home/oracle/k2/admin/pfile/initk2.ora' nomount;
alter database mount standby database;
alter database open;
alter database recover managed standby database disconnect from session;
create spfile from pfile='/home/oracle/k2/admin/pfile/initk2.ora';
shut immediate;
!
EOF
export ORACLE_SID=k1
sqlplus / as sysdba <<EOF
startup pfile='/home/oracle/k2/admin/pfile/initk2.ora' nomount;
alter database mount standby database;
alter database open;
create spfile from pfile='/home/oracle/k2/admin/pfile/initk2.ora';
EOF
7)standby pfile ------------->for stand_db
vi pfk2
db_name=k1
sga_target=600m
control_files='/home/oracle/k2/oradata/control/control01.ctl'
diagnostic_dest='/home/oracle/k2/admin/diag'
log_archive_config='DG_CONFIG=(k2,k1)'
db_unique_name=k2
log_archive_dest_2='SERVICE=k1tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=k1'
db_file_name_convert='/home/oracle/k1/oradata/data','/home/oracle/k2/oradata/data'
log_file_name_convert='/home/oracle/k1/oradata/log','/home/oracle/k2/oradata/log'
fal_client=k2tns
fal_server=k1tns
standby_file_management=auto
remote_login_passwordfile=exclusive
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
8) create unique_db spfile for both db if u want to connect individually connect to standby or primary
select name,db_unique_name,database_role from v$database;
select APPLIED,CREATOR,SEQUENCE# from v$archived_log;
errors:-
1)At prim_db alert_log
Heartbeat failed to connect to standby 'k2tns'. Error is 1031.
Check that the primary and standby are using a password file
and remote_login_passwordfile is set to SHARED or EXCLUSIVE,
and that the SYS password is same in the password files.
returning error ORA-16191
Solution :
serv 1(192.168.211.133 ):-cd $ORACLE_HOME/dbs
export ORACLE_SID=k1
orapwd file=orapwk1 password=sys force=y
cp $ORACLE_HOME/dbs/orapwk1 /home/oracle/orapwk2
scp /home/oracle/orapwk2 oracle@192.168.211.135:/home/oracle/
serv2(192.168.211.135):-
cd $ORACLE_HOME/dbs
rm orapwk2
export ORACLE_SID=k2
mv /home/oracle/orapwk2 $ORACLE_HOME/dbs
Comments
Post a Comment