Beruflich Dokumente
Kultur Dokumente
Database
#Create Data Guard on OEL 6.3
Ver. V1.0
Daftar Isi
Table of Contents
DOCUMENT UPDATE……………………………………………………………………………….1
DOCUMENT PURPOSE……………………………………………………………………………..2
INTRODUCTION……………………………………………………………………………………………………………………………..2
DOCUMENT PURPOSE……………………………………………………………………………………………………………………2
AUDIENCE………………………………………………………………………………………………………………………………………2
RESPONSES…………………………………………………………………………………………………………………………………….2
DAFTAR ISI……………………………………………………………………………………………3
I. INSTALASI SISTEM OPERASI…………………………………………………………….4
II. INSTALASI ORACLE 11GR2 DATABASE……………………………………………….6
III. PEMBUATAN DATA GUARD……………………………………………………………..18
1
EFB
Ver. V1.0
Mesin Primary
2
EFB
Ver. V1.0
Setting Firewall:
[root@efb1 ~]# service iptables status
[root@efb1 ~]# service iptables save
[root@efb1 ~]# service iptables stop
[root@efb1 ~]# chkconfig iptables off
Atau
[root@efb1 ~]# system-config-firewall-tui
3
EFB
Ver. V1.0
disabled selinux:
[root@efb1 ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
Membuat Direktori:
[root@efb1 ~]# mkdir -p /oradata
[root@efb1 ~]# mkdir -p /oracle
[root@efb1 ~]# mkdir -p /archive
[root@efb1 ~]# mkdir -p /backup_rman
[root@efb1 ~]# mkdir -p /staging
[root@efb1 ~]# mkdir -p /source
[root@efb1 ~]# mkdir -p /oraInventory
[root@efb1 ~]# chown -R oracle:oinstall /oradata/
[root@efb1 ~]# chmod -R 775 /oradata
[root@efb1 ~]# chown -R oracle:oinstall /oracle/
4
EFB
Ver. V1.0
Mounting CDROM:
Pastikan CD sudah dimasukkan.
[root@efb1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_efb1-lv_root
18G 1.8G 15G 11% /
tmpfs 496M 0 496M 0% /dev/shm
/dev/sda1 485M 54M 406M 12% /boot
/dev/sr0 3.5G 3.5G 0 100% /media/cdrom
5
EFB
Ver. V1.0
name=localrepo
baseurl=file:///repo/
enabled=1
gpgcheck=0
Install Package:
yum install binutils-2*x86_64*
yum install glibc-2*x86_64*nss-softokn-freebl-3*x86_64*
yum install glibc-2*i686*nss-softokn-freebl-3*i686*
yum install compat-libstdc++-33*x86_64*
yum install glibc-common-2*x86_64*
yum install glibc-devel-2*x86_64*
yum install glibc-devel-2*i686*
yum install glibc-headers-2*x86_64*
yum install elfutils-libelf-0*x86_64*
yum install elfutils-libelf-devel-0*x86_64*
yum install gcc-4*x86_64*
yum install gcc-c++-4*x86_64*
yum install ksh-*x86_64*
yum install libaio-0*x86_64*
yum install libaio-devel-0*x86_64*
yum install libaio-0*i686*
yum install libaio-devel-0*i686*
yum install libgcc-4*x86_64*
yum install libgcc-4*i686*
yum install libstdc++-4*x86_64*
yum install libstdc++-4*i686*
yum install libstdc++-devel-4*x86_64*
yum install make-3.81*x86_64*
yum install numactl-devel-2*x86_64*
yum install sysstat-9*x86_64*
yum install compat-libstdc++-33*i686*
yum install compat-libcap*
Cek xclock:
[root@efb1 repo]# yum provides */xclock
[root@efb1 repo]# yum install xorg-x11-apps
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmni = 4096
kernel.shmmax = 34359738368
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
6
EFB
Ver. V1.0
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
Save and exit the file. Enter the following command to change the current values of the
kernel parameters:
#[root@efb1 ~] /sbin/sysctl -p
Set the resource limits in the limits.conf file. Enter the following command to edit
resource limits:
[root@efb1 ~]# vi /etc/security/limits.conf
Membuat profile:
[oracle@efb1 ~]$ vi .bash_profile
# .bash_profile
PATH=$PATH:$HOME/bin
export PATH
#Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_UNQNAME=rmst; export ORACLE_UNQNAME
ORACLE_HOSTNAME=efb1.localdomain
ORACLE_BASE=/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=rmst; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
7
EFB
Ver. V1.0
total 2442052
-rw-r--r--. 1 root root 1142195302 Jul 23 13:57 p10404530_112030_Linux-x86-64_2of7.zip
-rw-r--r--. 1 root root 1358454646 Jul 23 13:58 p10404530_112030_Linux-x86-64_1of7.zip
[oracle@efb1 source]$ unzip p10404530_112030_Linux-x86-64_2of7.zip
Checking Temp space: must be greater than 120 MB. Actual 7081 MB Passed
Checking swap space: must be greater than 150 MB. Actual 1981 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual 16777216
Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-07-23_02-13-
29PM. Please wait ...
8
EFB
Ver. V1.0
9
EFB
Ver. V1.0
10
EFB
Ver. V1.0
11
EFB
Ver. V1.0
12
EFB
Ver. V1.0
13
EFB
Ver. V1.0
14
EFB
Ver. V1.0
15
EFB
Ver. V1.0
Untuk OS dan Engine Database Mesin Standby dapat dilakukan dengan cara cloning dari
Mesin Primary, kemudian:
atau
[root@efb1 ~]# reboot
[root@efb2 ~]#
16
EFB
Ver. V1.0
Mesin Primary
Membuat Listener:
17
EFB
Ver. V1.0
18
EFB
Ver. V1.0
19
EFB
Ver. V1.0
Install Database:
20
EFB
Ver. V1.0
21
EFB
Ver. V1.0
22
EFB
Ver. V1.0
23
EFB
Ver. V1.0
24
EFB
Ver. V1.0
25
EFB
Ver. V1.0
26
EFB
Ver. V1.0
Mesin Primary
LOG_MODE
------------
ARCHIVELOG
Database altered.
SQL> select FORCE_LOGGING from v$database;
FOR
---
YES
3. Membuat redolog standby jumlah redolog yang ada ditambah 1 redolog (n + 1).
SQL> alter database add standby logfile group '<name>' size <size>;
GROUP# MEMBER
------ ---------------------------------------------
1 /oradata/rmst/redo01.log
2 /oradata/rmst/redo02.log
3 /oradata/rmst/redo03.log
4 /oradata/rmst/srl04.log
5 /oradata/rmst/srl05.log
6 /oradata/rmst/srl06.log
7 /oradata/rmst/srl07.log
7 rows selected.
27
EFB
Ver. V1.0
7 0 0 YES UNASSIGNED
-- Optional
SQL> alter system set DB_FILE_NAME_CONVERT='/oradata/rmststby/','/oradata/rmst/'
scope=spfile;
SQL> alter system set LOG_FILE_NAME_CONVERT='/oradata/rmststby/','/oradata/rmst/'
scope=spfile;
5. Create tnsnames.ora
[oracle@efb1 ~]$ cd /oracle/product/11.2.0/db_1/network/admin
[oracle@efb1 admin]$ vi tnsnames.ora
RMST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = efb1.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rmst)
)
)
rmststby =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = efb2.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rmststby)
)
)
Mesin Standby
1. Create listener.ora
[oracle@efb2 dbs]$ cd /oracle/product/11.2.0/db_1/network/admin/
[oracle@efb2 admin]$ vi listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
28
EFB
Ver. V1.0
(GLOBAL_DBNAME = rmststby)
(ORACLE_HOME = /oracle/product/11.2.0/db_1)
(SID_NAME = rmststby)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = efb2.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
2. Create tnsnames.ora
[oracle@efb2 admin]$ vi tnsnames.ora
rmst =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = efb1.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rmst)
)
)
rmststby =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = efb2.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rmststby)
)
)
Primary:
[oracle@efb1 admin]$ tnsping rmst
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 23-JUL-2013 22:10:03
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =
efb1.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =
rmst)))
OK (400 msec)
29
EFB
Ver. V1.0
Standby:
[oracle@efb2 admin]$ tnsping rmststby
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 23-JUL-2013 22:14:42
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =
efb2.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =
rmststby)))
OK (30 msec)
a. 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.
30
EFB
Ver. V1.0
The password file name must match the instance name/SID used at the standby site, not
the DB_NAME.
c. Create the necessary directories in the standby location to place the datafiles and
the trace files in the $ADR_HOME.
d. Set the environment variable ORACLE_SID to the standby service and start the
standby-instance.
# Addtl. comment
# If DUPLICATE without TARGET connection is used you cannot use SPFILE
# else getting
RMAN-05537: DUPLICATE without TARGET connection when auxiliary instance is started with
spfile cannot use SPFILE clause
Primary:
[oracle@efb1 ~]$ sqlplus "/as sysdba"
SQL> connect sys/oracle@rmststby AS SYSDBA
Connected.
SQL> connect sys/oracle@rmst AS SYSDBA
Connected.
Standby:
[oracle@efb2 ~]$ sqlplus "/as sysdba"
31
EFB
Ver. V1.0
f. On the primary system invoke the RMAN executable and connect to the primary and the
auxiliary database (i.e., the standby).
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
RMAN> run {
duplicate target database for standby from active database
spfile
parameter_value_convert 'rmst','rmststby'
set db_unique_name='rmststby'
set DB_FILE_NAME_CONVERT='/oradata/rmst/','/oradata/rmststby/'
set LOG_FILE_NAME_CONVERT='/oradata/rmst/','/oradata/rmststby/'
set control_files='/oradata/rmststby/control01.ctl'
set log_archive_max_processes='5'
set fal_client='rmststby'
set fal_server='rmst'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(rmst,rmststby)'
set log_archive_dest_2='service=rmst ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)
db_unique_name=rmst'
;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16>
32
EFB
Ver. V1.0
33
EFB
Ver. V1.0
sql statement: alter system set fal_client = ''rmststby'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''rmst'' comment= '''' scope=spfile
34
EFB
Ver. V1.0
{
backup as copy current controlfile for standby auxiliary format
'/oradata/rmststby/control01.ctl';
}
executing Memory Script
35
EFB
Ver. V1.0
RMAN>
36
EFB
Ver. V1.0
Mesin Primary
System altered.
SEQUENCE# APPLIED
---------- ---------
38 YES
38 NO
39 NO
39 YES
40 NO
40 NO
SEQUENCE# APPLIED
---------- ---------
38 YES
38 NO
39 NO
39 YES
40 YES
40 NO
37
EFB
Ver. V1.0
Mesin Standby
SEQUENCE# APPLIED
---------- ---------
39 YES
40 NO
10 rows selected.
38
EFB
Ver. V1.0
RFS 0 0 IDLE
RFS 1 41 IDLE
RFS 0 0 IDLE
11 rows selected.
SEQUENCE# APPLIED
---------- ---------
39 YES
40 YES
Mesin Standby
Database altered.
SEQUENCE# APPLIED
39
EFB
Ver. V1.0
---------- ---------
39 YES
40 YES
41 YES
42 YES
Switchover
Mesin Primary:
SQL> SELECT NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;
System altered.
SWITCHOVER_STATUS
--------------------
TO STANDBY
Database altered.
SWITCHOVER_STATUS
--------------------
RECOVERY NEEDED
40
EFB
Ver. V1.0
Mesin Standby:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
Database altered.
Database altered.
Mesin Primary:
SQL> SHUTDOWN IMMEDIATE;
ORA-01092: ORACLE instance terminated. Disconnection forced
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@efb1 ~]$ sqlplus "/as sysdba"
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.
41
EFB
Ver. V1.0
Mesin Standby:
SQL> SELECT NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;
System altered.
End
42
EFB