2015年11月25日 星期三

nfs server step

Server 端

Using NFS to Share Files

NFS (Network File System) is another way of sharing files across a network. It is used primarily in Linux and UNIX systems, although there are NFS clients for Windows.

Installing NFS

1. Use the following command to install NFS:
   rpm -qa nfs-utils nfs-utils-lib 檢查有無安裝 NFS Package
 
   or

   yum -y install nfs-utils nfs-utils-lib

Configuring NFS

Configuration of NFS is pretty simple. You add the directories you wish to export to the file /etc/exports.

2. Create a directory called /public with the following command:

   mkdir -p /u01/app/oracle/oradata/arch

3. Next, edit the file /etc/exports:

   vi /etc/exports

4. Add the following line to /etc/exports:
   
   ex: /public    *(ro,sync)

   /u01/app/oracle/oradata/arch 10.1.1.59(rw,no_root_squash,no_all_squash,sync)

5. Mount
   [root@standby ~]# exportfs -r 重新掛載 /etc/exports 裡面的設定
   [root@standby ~]# exportfs -v
   /u01/app/oracle/oradata/arch 10.1.1.59(rw,wdelay,no_root_squash,no_subtree_check,anonuid=65534,anongid=65534)
   [root@standby ~]# showmount -e localhost
   Export list for localhost:
   /u01/app/oracle/oradata/arch 10.1.1.59

Then, start the nfs server:

        /etc/rc.d/init.d/nfs start

Client 端

確認是否有 server 端是否有提供 NFS 掛載
[root@primary ~]$ showmount -e 10.1.1.60
Export list for 10.1.1.60:
/u01/app/oracle/oradata/arch 10.1.1.59

--add parameter
vim /etc/fstab
10.1.1.60:/u01/app/oracle/oradata/arch    /u01/app/oracle/oradata/arch               nfs     rw              0 0

手動 mount
# mount -t nfs 10.1.1.60:/u01/app/oracle/oradata/arch /u01/app/oracle/oradata/arch

若 alert log file 出現下面錯誤訊息
ORA-27086: unable to lock file - already in use
Linux-x86_64 Error: 37: No locks available
Additional information: 10

解决方法:掛載時使用 nolock 參數
# umount /u02/arch/
# mount -o nolock -t nfs 10.1.1.60:/backup/arch /u02/arch/

How to reset the log sequence number in an Oracle database

[oracle@rman-recovery-test archivelog]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Tue May 26 16:47:57 2015

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 2097152000 bytes
Fixed Size                  2097592 bytes
Variable Size            1979715144 bytes
Database Buffers          100663296 bytes
Redo Buffers               14675968 bytes
Database mounted.

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery


SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open resetlogs;

Database altered.

SQL>


SQL> select open_mode from v$database;

delete archive log file

SQL> alter system archive log current;

SQL> /

SQL> /

SQL> archvie log list;


手動清除v$ARCHIVED_LOG中不管是DELETED還是available 記錄的方法,注意不要在你的產品資料庫上這樣做:

SQL> select count(*) from v$archived_log;
COUNT(*)
———
553

SQL> execute sys.dbms_backup_restore.resetCfileSection(11);
PL/SQL procedure successfully completed.
SQL> select count(*) from v$archived_log;
COUNT(*)
———
0

========================================================================
PROCEDURE resetCfileSection(record_type IN binary_integer );
— This procedure attempts to reset the circular controlfile section.

— Input parameters:
— record_type
— The circular record type whose controlfile section is to be reset.

execute sys.dbms_backup_restore.resetCfileSection(11);  ==> 清理v$ARCHIVED_LOG對應的記錄
execute sys.dbms_backup_restore.resetCfileSection(28);  ==>清理v$rman_status對應的記錄

以上是2個例子,具體的section_id可以這樣獲得:

SQL>  select rownum-1, type from v$controlfile_record_section

ROWNUM-1 TYPE
——— —————————
0 DATABASE
1 CKPT PROGRESS
2 REDO THREAD
3 REDO LOG
4 DATAFILE
5 FILENAME
6 TABLESPACE
7 TEMPORARY FILENAME
8 RMAN CONFIGURATION
9 LOG HISTORY
10 OFFLINE RANGE
11 ARCHIVED LOG
12 BACKUP SET
13 BACKUP PIECE
14 BACKUP DATAFILE
15 BACKUP REDOLOG
16 DATAFILE COPY
17 BACKUP CORRUPTION
18 COPY CORRUPTION
19 DELETED OBJECT
20 PROXY COPY
21 BACKUP SPFILE
22 DATABASE INCARNATION
23 FLASHBACK LOG
24 RECOVERY DESTINATION
25 INSTANCE SPACE RESERVATION
26 REMOVABLE RECOVERY FILES
27 RMAN STATUS
28 THREAD INSTANCE NAME MAPPING
29 MTTR
30 DATAFILE HISTORY
31 STANDBY DATABASE MATRIX
32 GUARANTEED RESTORE POINT
33 RESTORE POINT

Oracle 10g 修改SGA,PGA大小

一、概念
共享記憶體(System Global Area:SGA)是用於存儲資料庫的內存區,該信息為資料庫processes所共享。
單個服務器processes或單個後台進程(Process Global Area:PGA)單個PROCESS(thread)私有。

SGA進程共享而,PGA 是只被一個進程使用的區域,PGA 在創建進程時分配,在終止進程時回收。
Oracle 10g提供了PGA內存的自動管理。參數pga_aggregate_target可以指定PGA內存的最大值。
當參數pga_aggregate_target大於0時,Oracle將自動管理pga內存,並且各進程的所佔PGA之和,不大於pga_aggregate_target所指定的值。

二、配置
oracle推薦OLTP(on-line Transaction Processing)系統oracle佔系統總內存的80%,然後再分配80%給SGA,20%給PGA。也就是
SGA=system_total_memory*80%*80%
PGA=system_total_memory*80%*20%

三、操作
用SYS用戶以SYSDBA身份登錄系統
alter system set sga_max_size=2000m scope=spfile;
alter system set sga_target=2000m scope=spfile;
alter system set pga_aggregate_target=500m scope=spfile;

然後重新啟動數據庫
最後查看一下是否生效
show parameter sga_max_size;
show parameter sga_target;
show parameter pga_aggregate_target;

2015年11月24日 星期二

RMAN Restore

--Install Oracle10g on Enterprise Linux 5.5
(1).套裝軟體安裝
Desktop Environments -> 勾選 KDE
Development -> Development Libraries -> 按下[Optional Packages]
                 勾選 libstdc++44devel-4.4.0-6.el5.I386
                  -> Development Tools -> 按下[Optional Packages]
                 勾選 gcc44-4.4.0-6.el5.x86_64
                       gcc44-c++-4.4.0-6.el5.x86_64
                  -> 勾選Java Development
                  -> 勾選KDE Software Development
                  -> 勾選Legacy Software Development -> 按下[Optional Packages]
                 勾選 gtk+-1.2.10-56.el5.x86_64
                  -> 勾選 Ruby
                  -> X Software Development -> 按下[Optional Packages]
                 勾選 openmotif-devel-2.3.1-2.el5.x86_64
                       xorg-x11-server-sdk-1.1.1-48.52.0.1.el5.x86_64
                       xorg-x11.xbitmaps-1.0.1-4.1.x86_64
Servers -> 勾選 FTP Server
           -> 勾選 Legacy Network Server -> 按下[Optional Packages]
             勾選 telnet-server-0.17-39.el5.x86_64
           -> 勾選 Mail Server
           -> 勾選 Network Server
           -> 勾選 Printing Supports
           -> 勾選 Server Configuration Tools
           -> 勾選 Windows FIle Server
Base System -> Legacy Software Support -> 按下[Optional Packages]
                 勾選 compat-db-4.2.52-5.1.i386
                       openmotif22-2.2.3-18.I386
                       qt4-4.2.1-1.x86_64
                  -> System Tools -> 按下[Optional Packages]
                 勾選 Click gnutls-utils-1.4.1-3.el5_2.1.x86_64
                       sysstat-7.0.2-3.el5.x86_64

(2).硬體環境檢查
記憶體需求:
最少記憶體1GB
空間需求:
1.5GB~2GB swap
400MB的/tmp空間
1.5GB的oracle軟體安裝空間
2GB的flash recovery area空間

oracle install before,check Linux package。use rpm -q check:
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel libXp

yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel libXp

========================================================================
--install oracle 10g
You should now have a single directory containing installation files. Depending on the age of the download this may either be named "db/Disk1" or "database".

Hosts File

The "/etc/hosts" file must contain a fully qualified name for the server.

   
For example.

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.        localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
10.1.1.58       test


Set Kernel Parameters

Add the following lines to the "/etc/sysctl.conf" file.

#kernel.shmall = 2097152
#kernel.shmmax = 2147483648
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 101365
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=1048576
net.core.rmem_max=1048576
net.core.wmem_default=262144
net.core.wmem_max=262144


Run the following command to change the current kernel parameters.

/sbin/sysctl -p

Add the following lines to the "/etc/security/limits.conf" file.

*               soft    nproc   2047
*               hard    nproc   16384
*               soft    nofile  1024
*               hard    nofile  65536

Add the following line to the "/etc/pam.d/login" file, if it does not already exist.

session    required     pam_limits.so

Disable secure linux by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.

SELINUX=disabled
Alternatively, this alteration can be done using the GUI tool (System > Administration > Security Level and Firewall).
Click on the SELinux tab and disable the feature.

Create the new groups and users.

groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
useradd -u 500 -g oinstall -G dba oracle
passwd oracle

Create the directories in which the Oracle software will be installed.

mkdir -p /u01/app/oracle/product/10.2.0/db/
mkdir -p /Source
chown -R oracle:oinstall /u01

Edit the "/etc/redhat-release" file replacing the current release information
 (Red Hat Enterprise Linux Server release 5 (Tikanga)) with the following:

redhat-4

Login as the oracle user and add the following lines at the end of the ".bash_profile" file.

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=`hostname` ; export ORACLE_HOSTNAME
ORACLE_UNQNAME=xxx ; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db; export ORACLE_HOME
ORACLE_SID=xxx; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
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/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

alias sqlplus='/usr/local/rlwrap/bin/rlwrap sqlplus'
alias rman='/usr/local/rlwrap/bin/rlwrap rman'

if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi

========================================================================
--install rarlinux-x64-5.1.0.tar.gz
[root@test ~]# tar -zxvf rarlinux-x64-5.1.0.tar.gz
[root@test ~]# cd rar
[root@test rar]# make && make install

這個時候,執行rar或者unrar會報一系列錯誤
[root@test rar]# rar
rar: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by rar)
[root@test rar]# unrar
unrar: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by unrar)

這個時候不要慌張,執行下列命令
yes|cp rar_static /usr/local/bin/rar && yes|cp rar_static /usr/local/bin/unrar

[root@test rar]# yes|cp rar_static /usr/local/bin/rar && yes|cp rar_static /usr/local/bin/unrar
cp: overwrite `/usr/local/bin/rar'? cp: overwrite `/usr/local/bin/unrar'?
========================================================================
Unpack Files
gunzip the files.
[root@test ~]# cd /Source/
[root@test Source]# gunzip 10201_database_linux_x86_64.cpio.gz
[root@test Source]# cpio -idmv < 10201_database_linux_x86_64.cpio

--Installation

Start the Oracle Universal Installer (OUI) by issuing the following command in the database directory.
[oracle@test ~]$ cd /Source/database/
[oracle@test database]$ ./runInstaller
-------------------------------------------------------------------
[oracle@test ~]# /u01/app/oracle/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oracle/oraInventory to 770.
Changing groupname of /u01/app/oracle/oraInventory to oinstall.
The execution of the script is complete
[root@test ~]# /u01/app/oracle/product/10.2.0/db/root.sh
Running Oracle10 root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/10.2.0

Enter the full pathname of the local bin directory: [/usr/local/bin]:
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
-------------------------------------------------------------------
--因為還沒有安裝資料庫,故先升級到 10205 version

[root@test Source]# unzip p8202632_10205_Linux-x86-64.zip

Edit the "/etc/redhat-release" with the following:

Red Hat Enterprise Linux Server release 5 (Tikanga)

[oracle@test Source]$ cd Disk1
[oracle@test Disk1]$ ./runInstaller

--Change Kernel Parameters

Add the following lines to the "/etc/sysctl.conf" file.

net.ipv4.ip_local_port_range = 9000 65500

Run the following command to change the current kernel parameters.

/sbin/sysctl -p 讓參數生效

upgrade EM
[root@test Source]# unzip p8350262_10205_Generic.zip
[root@test Source]# su - oracle
[oracle@test ~]$ cd /Source/8350262/
[oracle@test 8350262]$ /u01/app/oracle/product/10.2.0/db/OPatch/opatch apply

結束安裝 oracle 10g 並升級 DB 與 EM (10.2.0.5.0)
========================================================================
--還原資料庫

把備份出來的檔案copy到要還原的機器上,注意還原機器的還原目錄路徑要跟備份的機器的目錄相同

測試還原
環境:
建立一個全新的db(如有舊db的也請先刪除,並且要確認datafile已被刪除,然後再建立新的db)
sid要設的跟備份機器相同
放db檔案路徑也相同
使用tree 指令讀取一下 Product 的目錄結構
tree /u01/app/oracle/ -L 5 -d

========================================================================
--Copy Product DB RMAN Backup && Archive log

--Copy password to /u01/app/oracle/product/10.2.0/db/dbs/
[oracle@test rman_bak]$ cp orapwxxx /u01/app/oracle/product/10.2.0/db/dbs/

or create password (若沒有密碼檔)

[oracle@test ~]$ orapwd file=/u01/app/oracle/product/10.2.0/dbs/orapwxxx password=oracle entries=5

--使用 rman 還原資料庫
[oracle@test rman_bak]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Mar 12 09:10:01 2015

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db/dbs/initxxx.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

Total System Global Area     159383552 bytes

Fixed Size                     2094736 bytes
Variable Size                 67111280 bytes
Database Buffers              83886080 bytes
Redo Buffers                   6291456 bytes

--restore spfile
RMAN> restore spfile from '/backup/rman_bak/o1_mf_s_874109496_bj0t9r97_.bkp';

Starting restore at 12-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK

channel ORA_DISK_1: autobackup found: /backup/rman_bak/o1_mf_s_874109496_bj0t9r97_.bkp
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 12-MAR-15

--先shutdown db
RMAN> shutdown immediate

Oracle instance shut down

--離開
RMAN> exit


Recovery Manager complete.


--use sqlplus login
[oracle@test rman_bak]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Mar 12 09:14:39 2015

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL>

--create pfile
SQL> create pfile from spfile;

File created.

SQL> exit
Disconnected

因為是還原演練 所以要先修改 pfile 內容,因為有做 DataGuard。

--use sqlplus login
[oracle@test rman_bak]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Mar 12 09:21:16 2015

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> create spfile from pfile;   重新產生 spfile

File created.

SQL> exit
Disconnected


[oracle@test rman_bak]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Mar 12 09:24:43 2015

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount

Oracle instance started

Total System Global Area    6442450944 bytes

Fixed Size                     2105920 bytes
Variable Size               2030046656 bytes
Database Buffers            4395630592 bytes
Redo Buffers                  14667776 bytes


RMAN> set dbid=xxxxxxxxxxxx

executing command: SET DBID

這邊就可以還原controlfile的囉,注意還原的位置喔,應該要跟原來的一樣

RMAN> restore controlfile from '/backup/rman_bak/o1_mf_s_874109496_bj0t9r97_.bkp';

Starting restore at 12-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1092 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/u02/oradata/xxx/control01.ctl
output filename=/u02/oradata/xxx/control02.ctl
output filename=/u02/oradata/xxx/control03.ctl
Finished restore at 12-MAR-15

RMAN> alter database mount;

--還原資料庫
RMAN> restore database;

Starting restore at 12-MAR-15
Starting implicit crosscheck backup at 12-MAR-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1092 devtype=DISK
Crosschecked 32 objects
Finished implicit crosscheck backup at 12-MAR-15

Starting implicit crosscheck copy at 12-MAR-15
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 12-MAR-15

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/PRIMARY/autobackup/2015_03_11/o1_mf_s_874080942_bhzyfhmb_.bkp

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u02/oradata/xxx/users01.dbf
restoring datafile 00008 to /u03/oraindx/xxx/indx01.dbf
channel ORA_DISK_1: reading from backup piece /backup/rman_bak/xxxdb_nfq1jls5_1_1
.....................
.....................

RMAN> recover database;

Starting recover at 12-MAR-15
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 66742 is already on disk as file
.........
archive log thread 1 sequence 66743 is already on disk as file
.........


RMAN> alter database open resetlogs;

database opened  --> 看到database opened就表示還原完成囉

RMAN> exit


Recovery Manager complete.


Use Oracle VM VirtualBox Creating Shared Drives

cd C:\Program Files\Oracle\VirtualBox

VBoxManage createhd         --filename
                            --size |--sizebyte
                            [--format VDI|VMDK|VHD] (default: VDI)
                            [--variant Standard,Fixed,Split2G,Stream,ESX]


VBoxManage storageattach    
                            --storagectl
                            --port
                            --device
                            [--type dvddrive|hdd|fdd]
                            [--medium none|emptydrive|
                                      ||host:|iscsi]
                            [--mtype normal|writethrough|immutable|shareable|
                                     readonly|multiattach]
                            [--comment ]
                            [--passthrough on|off]
                            [--bandwidthgroup ]
                            [--forceunmount]
                            [--server |]
                            [--target ]
                            [--port ]
                            [--lun ]
                            [--encodedlun ]
                            [--username ]
                            [--password ]
                            [--intnet]

VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE01.vdi" --size 1024 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE02.vdi" --size 1024 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE03.vdi" --size 1024 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA01.vdi" --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA02.vdi" --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA03.vdi" --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA01.vdi" --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA02.vdi" --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA03.vdi" --size 5120 --format VDI --variant Fixed

VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE01.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE02.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE03.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA01.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA02.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA03.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA01.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA02.vdi" --type shareable
VBoxManage modifyhd "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA03.vdi" --type shareable

VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 1 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE01.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 2 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE02.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 3 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE03.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 4 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA01.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 5 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA02.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 6 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA03.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 7 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA01.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 8 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA02.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac1 --storagectl "SATA" --port 9 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA03.vdi" --mtype shareable

VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 1 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE01.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 2 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE02.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 3 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\VOTE03.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 4 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA01.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 5 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA02.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 6 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\DATA03.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 7 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA01.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 8 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA02.vdi" --mtype shareable
VBoxManage storageattach oracle_11gr2_rac2 --storagectl "SATA" --port 9 --device 0 --type hdd --medium "F:\Oracle VM VirtualBox\oracle_11gr2_rac_hd\FRA03.vdi" --mtype shareable

linux yum local media method

RHEL5 & RHEL6
配置yum源,方便安裝套裝軟體  rhel6
[root@test ~]# umount /dev/cdrom
[root@test ~]# mount /dev/cdrom /media
mount: block device /dev/sr0 is write-protected, mounting read-only

[root@test ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda5             17342332   2793528  13667860  17% /
tmpfs                   510268       224    510044   1% /dev/shm
/dev/sda1               198337     28890    159207  16% /boot
/dev/sda3              1032088     34100    945560   4% /tmp
/dev/sr0               3632776   3632776         0 100% /media


[root@test ~]# vi /etc/yum.repos.d/rhel-source.repo

對rhel-source.repo進行修改
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///media
enabled=1
gpgcheck=1
gpgkey=file:///media/RPM-GPG-KEY-redhat-release


[rhel-source-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

配置完yum之後執行下面命令之後就可以進行套裝軟體的安裝了
[root@test yum.repos.d]# yum clean all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel-source
Cleaning up Everything
[root@test yum.repos.d]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-source                                                                          | 3.9 kB     00:00 ...
rhel-source/primary_db                                                               | 3.1 MB     00:00 ...
repo id                        repo name                                                              status
rhel-source                    Red Hat Enterprise Linux 6Server - x86_64 - Source                     3,648
repolist: 3,648
[root@test yum.repos.d]#

安裝套裝軟體
[root@test yum.repos.d]# rpm -qa --qf "%{NAME}_%{VERSION}_%{ARCH}\n"|sort|less 查看已經安裝的套裝軟體
install oracle need pachage
[root@test yum.repos.d]# yum -y install binutils compat-libstdc++-33 compat-libcap1 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel

=======================================================================

配置yum源,方便安裝套裝軟體  rhel5

[root@oracle-primary ~]# umount /dev/cdrom
[root@oracle-primary ~]# mount /dev/cdrom /media
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@oracle-primary ~]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/vda7                 9917      3550      5856  38% /
/dev/vda9                77619       184     73428   1% /backup
/dev/vda6                 9917       151      9254   2% /archivelog
/dev/vda5                14529       165     13614   2% /u01
/dev/vda3                14529       165     13614   2% /u03
/dev/vda2                67810       180     64130   1% /u02
/dev/vda1                   99        12        83  13% /boot
tmpfs                      830         0       830   0% /dev/shm
/dev/hdc                  3532      3532         0 100% /media

[root@oracle-primary ~]# vim /etc/yum.repos.d/rhel-source.repo

對rhel-source.repo進行修改
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///media/Server
enabled=1
gpgcheck=1
gpgkey=file:///media/RPM-GPG-KEY-redhat-release

[root@oracle-primary ~]# yum clean all
Loaded plugins: rhnplugin, security
Cleaning up Everything

[root@oracle-primary ~]# yum repolist
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
rhel-source                                              | 1.3 kB     00:00
rhel-source/primary                                      | 868 kB     00:00
rhel-source                                                           3116/3116
repo id      repo name                                            status
rhel-source  Red Hat Enterprise Linux 5Server - x86_64 - Source   enabled: 3,116
repolist: 3,116

[root@oracle-primary ~]# yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel libXp

Oracle Database 11g Release 2 (11.2) Installation On Redhat Linux 6 & Dataguard

This article describes the installation of Oracle Database 11g Release 2 (11.2) (64-bit) on Redhat Linux 6 (64-bit). The article is based on a server installation with a minimum of 2G swap, with SELinux set to disabled and the firewall disabled. The following package groups were included for this installation.

Base System > Base
Base System > Compatibility libraries
Base System > Console internet tools
Base System > Debugging Tools
Base System > Directory Client
Base System > Hardware monitoring utilities
Base System > Java Platform
Base System > Large Systems Performance
Base System > Network file system client
Base System > Performance Tools
Base System > Perl Support
Servers > Server Platform
Servers > System administration tools
Desktops > Desktop
Desktops > Desktop Platform
Desktops > Fonts
Desktops > General Purpose Desktop
Desktops > Graphical Administration Tools
Desktops > Input Methods
Desktops > X Window System
Applications > Internet Browser
Development > Additional Development
Development > Development Tools
An example of this type of Linux installations can be seen here. Alternative installations may require more packages to be loaded, in addition to the ones listed below.
挑選後,大概在 1,300 個套件左右
l  Download Software
l  Hosts File
l  Oracle Installation Prerequisites
n  Manual Setup
n  Additional Setup
l  Unpack Files
l  Installation

Download Software
Download the Oracle software from OTN or MOS (My Oracle Support) depending on your support status.
Hosts File

The "/etc/hosts" file must contain a fully qualified name for the server.
   
For example.
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.1.1.164      brian-db        primary
10.1.1.165      brian-dg        standby

Oracle Installation Prerequisites

Perform either the Automatic Setup or the Manual Setup to complete the basic prerequisites. The Additional Setup is required for all installations.

Manual Setup

Add or amend the following lines in the "/etc/sysctl.conf" file.
cat >> /etc/sysctl.conf << EOF
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 984936448
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
EOF

Run the following command to change the current kernel parameters.
/sbin/sysctl -p

Add the following lines to the "/etc/security/limits.conf" file.
cat >> /etc/security/limits.conf << EOF
oracle              soft    nproc   16384
oracle              hard    nproc   16384
oracle              soft    nofile   4096
oracle              hard    nofile  65536
oracle              soft    stack   10240
EOF

可以不加
#######################################################################################
Add the following lines to the "/etc/pam.d/login" file.
cat >> /etc/pam.d/login << EOF
session required /lib64/security/pam_limits.so
session required pam_limits.so
EOF

Add the following lines to the "/etc/profile" file.
cat >> /etc/profile << EOF
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
umask 022
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
#######################################################################################

Install the following packages if they are not already present.
# From Redhat Linux 6 DVD
配置yum來源,方便安裝套裝軟體  rhel6
[root@brian-db ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/vda2             28898428   3583444  23847032  14% /
tmpfs                   961228       224    961004   1% /dev/shm
/dev/sr0               3632776   3632776         0 100% /media/RHEL_6.4 x86_64 Disc 1
[root@brian-db ~]# umount /media/RHEL_6.4\ x86_64\ Disc\ 1/
[root@brian-db ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/vda2             28898428   3583436  23847040  14% /
tmpfs                   961228       224    961004   1% /dev/shm
[root@brian-db ~]# mount /dev/cdrom /media
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@brian-db ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/vda2             28898428   3583436  23847040  14% /
tmpfs                   961228       224    961004   1% /dev/shm
/dev/sr0               3632776   3632776         0 100% /media
[root@brian-db ~]# vi /etc/yum.repos.d/rhel-source.repo

rhel-source.repo進行修改
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///media
enabled=1
gpgcheck=1
gpgkey=file:///media/RPM-GPG-KEY-redhat-release


[rhel-source-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

配置完yum之後執行下面命令之後就可以進行套裝軟體的安裝了
[root@brian-db ~]# yum clean all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel-source
Cleaning up Everything
[root@brian-db ~]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-source                                                       | 3.9 kB     00:00 ...
rhel-source/primary_db                                             | 3.1 MB     00:00 ...
repo id               repo name                                                    status
rhel-source           Red Hat Enterprise Linux 6Server - x86_64 - Source           3,648
repolist: 3,648

Install package software
[root@brian-db ~]#
 rpm -qa --qf "%{NAME}_%{VERSION}_%{ARCH}\n"|sort|less 查看已經安裝的套裝軟體

install oracle need pachage
[root@brian-db ~]# yum -y install binutils compat-libstdc++-33 compat-libcap1 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel

Create the new groups and users.
groupadd -g 501 oinstall
groupadd -g 502 dba
useradd -u 502 -g oinstall -G dba oracle
passwd oracle

Additional Setup

Set secure Linux to disabled by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.
SELINUX=disabled
Once the change is complete, restart the server.

If you have the Linux firewall enabled, you will need to disable or configure it, as shown here or here.

Login as the oracle user and add the following lines at the end of the ".bash_profile" file.
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=`hostname` ; export ORACLE_HOSTNAME
ORACLE_UNQNAME=brian; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1; export ORACLE_HOME
ORACLE_SID=brian; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
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/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

#alias sqlplus='/usr/local/rlwrap/bin/rlwrap sqlplus'
#alias rman='/usr/local/rlwrap/bin/rlwrap rman'

SFTP Oracle Source to machine /u01/app/oracle/source
mkdir -p /u01/app/oracle/source
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
pdksh-5.2.14-30.x86_64.rpm

Create the directories in which the Oracle software will be installed.
mkdir -p /u01/app/oracle/product/11.2.0.4/dbhome_1
chown -R oracle:oinstall /u01
Login as root and issue the following command.

Unzip the files

cd /u01/app/oracle/source
# 11.2.0.1
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip

#11.2.0.4
[root@brian-db ~]# cd /u01/app/oracle/source/
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip

Install pdksh package
[root@brian-db ~]# cd /u01/app/oracle/source/
[root@brian-db source]# rpm -ivh pdksh-5.2.14-30.x86_64.rpm
warning: pdksh-5.2.14-30.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 4f2a6fd2: NOKEY
Preparing...                ########################################### [100%]
   1:pdksh                ########################################### [100%]

Reboot machine

Installation
./runInstaller

Login as oracle and issue the following command.














Finsh oracle software

Create listener
Netca









Create database include sample
dbca
















Complete create database



Steps to configure 11g Physical Standby Database
Oracle rdbms software is installed with one database(dell) following is details:

Primary DB_NAME=brian                            IP - 10.1.1.164
Primary DB_UNIQUE_name=primary

On Physical standby I have installed only rdbms software (std will be my standby database)

Standby DB_NAME=brian                            IP - 10.1.1.165
Standby DB_UNIQUE_name=standby

Required Parameters:
Parameter
Recommended Setting for Standby Database
DB_Name
Must be same on parimary and on all dtandby
DB_UNIQUE_NAME
Must be different on parimary and on all dtandby
LOG_ARCHIVE_CONFIG
This parameter includes db_unique_name which are the part of Dataguard configuration
LOG_ARCHIVE_DEST_n
Define local and remote archive log file location
LOG_ARCHIVE_DEST_STATE_n
Define state of archiving (ENABLE or DIFER)
REMOTE_LOGIN_PASSWORDFILE
Must be in EXCLUSIVE Mode
FAL_SERVER
Use for archivelog gap resolution (required only in physical standby server)
DB_FILE_NAME_CONVERT
required when directory structure is different datafile
LOG_FILE_NAME_CONVERT
required when directory structure is different logfile
STANDBY_FILE_MANAGEMENT
Keep auto to create file automatically on standby

Steps
Perform following steps on Primary database:

Make sure database is in archivelog mode
select name from v$database;

if note use following command to change to archive mode
SQL> archive log list
Database log mode            No Archive Mode
Automatic archival            Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence      4
Current log sequence           6

shutdown immediate
startup mount
alter database archivelog;
alter database open;

SQL> archive log list
Database log mode            Archive Mode
Automatic archival            Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence      4
Next log sequence to archive    6
Current log sequence           6

Make sure database is in force logging mode

select force_logging from v$database;
alter database force logging;

Verify DB_NAME and DB_UNIQUE_NAME of Primary Database

show parameter db_name
show parameter db_unique_name

Change db_unique_name

alter system set db_unique_name='primary' scope=spfile;

shutdown immediate
startup

Make DB_UNIQUE_NAME to be part of dataguard.(std service we will create soon)

alter system set log_archive_config='dg_config=(primary,standby)';

Set archivelog destinations
mkdir -p /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch

alter system set log_archive_dest_1='location=/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch valid_for=(all_logfiles,all_roles) db_unique_name=primary' scope=both;

alter system set log_archive_dest_2='service=standby LGWR ASYNC valid_for=(online_logfiles,primary_role) db_unique_name=standby' scope=both;

alter system set log_archive_dest_state_1='ENABLE' scope=both;
alter system set log_archive_dest_state_2='ENABLE' scope=both;

Set remote login password to exclusive

alter system set remote_login_passwordfile=exclusive scope=spfile;
show parameter remote_login

Set fal server and file name convert parameter incase if dirrctory structure is different in primary and standby database

alter system set fal_server=standby scope=both;
alter system set fal_client=primary scope=both;
alter system set db_file_name_convert='standby','primary' scope=spfile;
alter system set log_file_name_convert='standby','primary' scope=spfile;
alter system set log_archive_max_processes=10 scope=both;
alter system set standby_file_management=auto scope=both;

Now configure required service (primary and standby)
netmgr











Now backup Primary Database using rman

rman target /
RMAN> backup database plus archivelog;

Now Create standby controlfile and pfile

alter database create standby controlfile as '/tmp/stdcontrol.ctl';
create pfile='/tmp/initbrian.ora' from spfile;

Modify initbrian.ora file

1.     Change db_unique_name
2.     log_file_name_convert
3.     Change fal_server
4.     Change fal_client
5.     Change log_archive_dest_n
6.     Change location of controlfile


ps: Standby add directory
[oracle@brian-dg database]$ mkdir -p /u01/app/oracle/admin/brian/adump
[oracle@brian-dg database]$ mkdir -p /u01/app/oracle/oradata/brian
[oracle@brian-dg database]$ mkdir -p /u01/app/oracle/fast_recovery_area/brian
[oracle@brian-dg database]$ mkdir -p /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch

Create appropriate directory on physical standby and copy backupset, archivelog, pfile, standby controlfile and password file to physical standby database

# Standby controlfile to all locations.
scp /tmp/stdcontrol.ctl oracle@standby:/u01/app/oracle/oradata/brian/control01.ctl
scp /tmp/stdcontrol.ctl oracle@standby:/u01/app/oracle/fast_recovery_area/brian/control02.ctl

Archivelogs and backups
scp -r /u01/app/oracle/fast_recovery_area/PRIMARY oracle@standby:/u01/app/oracle/fast_recovery_area/

# Parameter file.
scp /tmp/initbrian.ora oracle@standby:/tmp/initbrian.ora

# Remote login password file.
scp /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapwbrian oracle@standby:/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/

On physical standby server

netmgr
















Now start listener on both server
lsnrctl start

Create service on physical standby database and update /etc/oratab file

vi /etc/oratab
brian:/u01/app/oracle/product/11.2.0.4/dbhome_1:N

Restore backup on standby:
create spfile from pfile


. oraenv
brian
sqlplus / as sysdba
create spfile from pfile='/tmp/initbrian.ora';
Restore backupfile

rman target /
startup mount
restore database;

Create standby redolog files on primary and standby database

alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo01.log') size 50M;
alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo02.log') size 50M;
alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo03.log') size 50M;
alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo04.log') size 50M;

select member from v$logfile where type='STANDBY';

On Primary Database

alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo01.log') size 50M;
alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo02.log') size 50M;
alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo03.log') size 50M;
alter database add standby logfile ('/u01/app/oracle/oradata/brian/standby_redo04.log') size 50M;

select member from v$logfile where type='STANDBY';
                                                 
Now start redo apply process on standby

alter database recover managed standby database disconnect from session;

Following command is use to stop redo apply process

alter database recover managed standby database cancel;

Test Log Transport
On the primary server, check the latest archived redo log and force a log switch.

alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
select sequence#, first_time, next_time from v$archived_log order by sequence#;
alter system switch logfile;

Check the now archived redo log has arrived at the standby server and been applied.

alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;

SQL> select name, open_mode, database_role, db_unique_name, protection_mode from v$database;
NAME      OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME
--------- -------------------- ---------------- ------------------------------
PROTECTION_MODE
--------------------
BRIAN     MOUNTED              PHYSICAL STANDBY standby
MAXIMUM PERFORMANCE

Steps to Configure Read Only Standby
step standby
shutdown immediate;
startup mount;
alter database open read only;

Change start redo apply process on standby
shutdown immediate;
startup mount;
alter database recover managed standby database disconnect from session;

alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;


Active Data Guard aconfiguration
step standby
shutdown immediate;
startup mount;
alter database open read only;
alter database recover managed standby database disconnect from session;
select name, open_mode, database_role, protection_mode from v$database;




Snapshot Standby Configuration
step standby
SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
NO

SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database convert to snapshot standby;
SQL> alter database open;

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
RESTORE POINT ONLY

SQL> create table hr.emp5 as select * from hr.employees;

Table created.

SQL> select count(*) from hr.emp5;

  COUNT(*)
----------
       107
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.
Total System Global Area  784998400 bytes
Fixed Size                  2257352 bytes
Variable Size             515903032 bytes
Database Buffers          264241152 bytes
Redo Buffers                2596864 bytes
Database mounted.
shutdown again
SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  784998400 bytes
Fixed Size                  2257352 bytes
Variable Size             515903032 bytes
Database Buffers          264241152 bytes
Redo Buffers                2596864 bytes
SQL> alter database mount standby database;

Database altered.

SQL> alter database recover managed standby database disconnect;

Database altered.

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
NO

SQL> select count(*) from hr.emp5;
select count(*) from hr.emp5
                        *
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only

Database Switchover Roles
step standby

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

NAME      OPEN_MODE            DATABASE_ROLE    PROTECTION_MODE
--------- -------------------- ---------------- --------------------
BRIAN     MOUNTED              PHYSICAL STANDBY MAXIMUM PERFORMANCE
SQL> select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;

step primary

SQL> select name, open_mode, database_role, db_unique_name, protection_mode from v$database;

NAME      OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME
--------- -------------------- ---------------- ------------------------------
PROTECTION_MODE
--------------------
BRIAN     READ WRITE           PRIMARY          primary
MAXIMUM PERFORMANCE

step primary
SQL> alter database commit to switchover to standby;
SQL> shutdown immediate;
SQL> start nomount;
SQL> alter database mount standby database;
SQL> alter database recover managed standby database disconnect from session;
SQL> select name, open_mode, database_role, db_unique_name, protection_mode from v$database;

step standby
SQL> alter database commit to switchover to primary;
SQL> shutdown immediate;
SQL> startup
SQL> select name, open_mode, database_role, protection_mode from v$database;
SQL> select sequence#, first_time, next_time from v$archived_log order by sequence#;
SQL> alter system switch logfile;
SQL> select sequence#, first_time, next_time from v$archived_log order by sequence#;

step primary

SQL> select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;