環境
os: linux
oracle: oracle
primary:
standby:
第一部分 oracle
本來我不想寫這方面的東東
/tmp/OraInstall
Oracle Net configuration Assistant
Oracle Database configuration Assistant
Agent configuration Assistant
三個工具的details錯誤信息都是
/home/oracle/jre/
unable to initialize threads: cannot find class java/lang/Thread
Could not create java VM
解決方法
在運行runInstaller之前做下面的步驟
export LD_ASSUME_KERNEL=
ignore your kernal version
下載文件libcwait
上面的方法能使Oracle Net configuration Assistant
修復Agent configuration Assistant不能配置成功的方法
在RHAS
運行runInstaller之後
此補丁也是從下下載
過程如下
$ cp p
$ cd /tmp
$ unzip p
$ export PATH=$PATH:/tmp/OPatch
$ export PATH=$PATH:/sbin # the patch needs
$ unzip p
$ cd
$ opatch apply
[/quote:
$ cd $ORACLE_HOME/network/lib
$ make
現在在運行agentctl start
在這個成功之後
希望你也能成功安裝
運行runInstaller後
export LANG=en_us 再運行runInstaller (這是最簡單實用的辦法)
報/etc/oratab 錯誤
如果在機器上以前安裝過
cp /dev/null /etc/oratab
(
ORA
這時需要給內核指定內存
echo
或者
編輯/etc/nf
kernel
這樣就可以數據庫的安裝
運行
運行oemapp console可以打開oracle企業管理器工具
還有一些錯誤
另外主副主機的目錄設置成一樣
第二步
首先將主副兩主機都設為歸檔模式
登陸主節點
[oracle@primary]$ sqlplus
SQL> startup
SQL> shutdown immediate
SQL> exit
[oracle@primary]pwd
/home/oracle
[oracle@primary]$ ls
admin dictionary
[oracle@primary]tar
[oracle@primary]$ ls
[oracle@primary]$ sqlplus
SQL> startup
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/oradata/primary/archive
Oldest online log sequence
Next log sequence to archive
Current log sequence
SQL> alter database create standby controlfile as
Database altered
SQL> exit
[oracle@primary]
具體步驟
說明一下
[oracle@eygle primary]$ sqlplus
SQL> startup nomount;
SQL> alter database mount standby database;
SQL> alter database recover managed standby database disconnect from session;
這一步時就會報ORA
所以我這在這裡就把primary的orapworacle來替換standby的orapworacl也當作一步必須步驟
在standby主機的$oracle/home/admin下原來有oracle目錄
primary目錄
Primary的參數文件
oracle@primary_andy $cat
#
# Get the aliases and functions
#if [
#
#fi
# User specific environment and startup programs
#export BASH_ENV=$HOME/
PATH=$PATH:/home/oracle/product/
bin:/usr/bin:/usr/ccs/bin:/usr/ucb:/etc:/usr/local/bin:/usr/bin/saved:
export PATH
unset USERNAME
ORACLE_OWNER=oracle
ORACLE_BASE=/home/oracle
export ORACLE_BASE
ORACLE_HOME=/home/oracle/product/
export ORACLE_HOME
LANG=
LC_ALL=
ORACLE_SID=oracle
export ORACLE_SID
TNS_ADMIN=/home; export TNS_ADMIN
NLS_LANG=american_america
#ORA_NLS
CLASSPATH=$Oracle_HOME/JRE:$Oracle_HOME/jlib:$Oracle_HOME/rdbms/jlib:/opt/j
export CLASSPATH
TMPDIR=/tmp;export TMPDIR
umask
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/lib/tls:/lib/i
export LD_LIBRARY_PATH
export LD_PRELOAD=/home/oracle/libcwait
export LD_ASSUME_KERNEL=
DISPLAY=
export PS
#cat initoracle
*
*
patible=
ntrol_files=
ontrol
re_dump_dest=
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
修改standby主機的initoracle
*
*
patible=
ntrol_files=
re_dump_dest=
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
primary=(description=
(address=
(protocol=tcp)
(port=
(host=
(connect_data=
(SID=oracle)))
standby=(description=
(address=
(protocol=tcp)
(port=
(host=
(connect_data=
(SID=oracle)))
同樣
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = oracle)
(GLOBAL_DBNAME = oracle)
(ORACLE_HOME = /home/oracle/oradata)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT =
)
)
在主副庫上啟動lsnrctl
LSNRCTL>start # 啟動監聽服務
在primary機上
在standby機上
sql> startup nomount;
SQL> alter database mount standby database;
Database altered
SQL> alter database recover managed standby database disconnect from session;
Database altered
SQL> alter system set log_archive_dest_
System altered
定義了主庫向副庫傳輸日志
# 定義歸檔到備用庫
# 如果定義為可選狀態(optional)
# 為madatory狀態後
SQL> alter system switch logfile;
System altered
SQL> /
System altered
SQL>
在備用節點觀察日志
[oracle@eygle bdump]$ tail
MRP
Starting datafile
Datafile
Starting datafile
Datafile
…………………………
修改primary的參數文件initoracle
增加
*
*
*
*
*
*
刪除 log_archive_dest_
修改standby的參數文件initoracle
增加
*
*
刪除
*
*
*
*
*
*
在primary主機上執行
SQL> alter database commit to switchover to physical standby with session shutdown ;
Database altered
察看primary主機上的後台日志
……………………………
SQL> shutdown immediate
ORA
ORACLE instance shut down
以備用模式(standby)啟用主數據
SQL> create spfile from pfile;
SQL> startup nomount;
SQL>show parameter standby_file_management;
SQL> alter database mount standby database;
Database altered
打開備用數據庫(在standby主機上執行)
[oracle@standby oracle]$ sqlplus
SQL> alter database commit to switchover to primary with session shutdown ;
Database altered
SQL> shutdown immediate;
ORA
ORACLE instance shut down
SQL>create spfile from pfile;
SQL> startup;
……
Database mounted
Database opened
SQL> select SEQUENCE#
SQL> select sequence#
SEQUENCE# GROUP# STATUS
SQL> alter system switch logfile;
System altered
SQL> select sequence#
SEQUENCE# GROUP# STATUS
在primary主機上執行
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered
在primary主機上觀察日志應用情況
[oracle@primary bdump]$ tail
Starting datafile
Datafile
Starting datafile
Datafile
………………………………………………
Media recover
SQL> create table t as select * from dba_users;
Table created
SQL> alter system switch logfile;
System altered
在從庫上(primary主機上)以read only打開數據庫
SQL> select username from t;
select username from t
*
ERROR at line
ORA
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered
SQL> ALTER DATABASE OPEN READ ONLY;
Database altered
SQL> select username from t;
USERNAME
SYS
SYSTEM
DBSNMP
OUTLN
WMSYS
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered
常見問題
至此
啟動的時候
關閉的時候
第六點我理解得有些問題
Rollingpig
我給個結論吧
SQL> select name
NAME OPEN_MODE PROTECTION_MODE DATABASE_ROLE
PRIMARY MOUNTED MAXIMUM PERFORMANCE PHYSICAL STANDBY
可在副數據庫上運行一些腳本
oracle@standby $cat refresh (刷新腳本)
ORACLE_SID=oracle
ORACLE_HOME=/home/oracle/product/
export ORACLE_SID ORACLE_HOME
DATE=`date
touch /home/oracle/refresh_$DATE
$ORACLE_HOME/bin/sqlplus /nolog << EOF
spool /home/oracle/refresh_$DATE
connect sys/abc
shutdown immediate;
quit
EOF
$ORACLE_HOME/bin/sqlplus /nolog << EOF
spool /home/oracle/refresh_
connect sys/abc
startup nomount pfile=$ORACLE_HOME/dbs/initoracle
alter database mount standby database;
alter database set standby database to maximize performance;
alter database recover managed standby database disconnect from session;
spool off
EOF
oracle@standby $cat readonly (更新腳本)
#!/bin/sh
ORACLE_SID=oracle
ORACLE_HOME=/home/oracle/product/
export ORACLE_SID ORACLE_HOME
$ORACLE_HOME/bin/sqlplus /nolog << EOF
spool /home/oracle/refresh
connect sys/abc
rem change from recover mode to read
alter database recover managed standby database cancel;
alter database open read only ;
spool off
EOF
switchover過程
先將standby此時的initoracle
在主節點(standby主機上)
SQL> alter database commit to switchover to physical standby;
Database altered
SQL> shutdown immediate
ORA
statORACLE instance shut down
SQL> startup nomount pfile=/home/oracle/product/
;
ORACLE instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
SQL> alter database mount standby database;
Database altered
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered
在備用節點(在primary主機上)
先將primary此時的initoracle
SQL> alter database commit to switchover to primary;
Database altered
SQL> shutdown immediate;
ORA
ORACLE instance shut down
SQL> startup pfile=/home/oracle/product/
ORACLE instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted
Database opened
衷心致謝: CU oracle斑竹 sshd
參考文獻
Dataguard配置Step by step (eygle大作)
From:http://tw.wingwit.com/Article/program/Oracle/201311/17817.html