Oracle 11g RAC 配置單例項 DataGuard
主庫:RAC public IP 節點1 192.168.126.42 節點2 192.168.126.43
scan IP 192.168.20.100
作業系統:Redhat linux 6.5
儲存:ASM
備庫: 單例項 192.168.126.44
作業系統:Redhat linux 6.5
儲存:檔案系統
下面是主備庫的DB_UNIQUE_NAME和Oracle Net Service Name
Database DB_UNIQUE_NAME Oracle Net Service Name Primary atfdb atfdb Physical standby atfdbdg atfdbdg |
安裝步驟:
1. 安裝備庫的資料庫軟體
1.1 先在主庫上查詢字符集,保證備庫的字符集與主庫一致
select * from V$NLS_PARAMETERS p where p.parameter like '%CHARACTER%';
NLS_CHARACTERSET ZHS16GBK NLS_NCHAR_CHARACTERSET AL16UTF16
show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 11.2.0.0.0 |
1.2 檢查備庫的系統引數是否滿足安裝要求
#檢視主機記憶體 grep MemTotal /proc/meminfo
#交換空間,如果實體記憶體在16G以上,推薦交換空間至少為16G grep SwapTotal /proc/meminfo free
#檢查機器的硬體名稱 uname -m
#檢查臨時表空間,至少1G df -h /tmp df -h
#檢查 linux 版本 cat /proc/version lsb_release -id
#檢查核心 uname –r |
1.3 禁用防火牆和SELINUX
#使用root使用者登入 service iptables status service iptables stop chkconfig iptables off
#然後輸入以下命令,禁用SELinux: vi /etc/selinux/config SELINUX=disabled |
1.4 檢查軟體包
rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" binutils compat-libstdc elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel |
1.5 建立組和使用者
/usr/sbin/groupadd oinstall /usr/sbin/groupadd -g 502 dba /usr/sbin/groupadd -g 503 oper id oracle /usr/sbin/useradd -u 502 -g oinstall -G dba,oper oracle passwd oracle |
1.6 設定環境變數,從rac的其中一個節點複製環境變數檔案到備庫上面
#登入主庫的節點1 cd
scp .bash_profile oracle@beiku_ip:/home/oracle |
1.7 設定核心引數
vi /etc/sysctl.conf #增加或者修改以下內容: fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576
#使用以下命令驗證配置: sysctl -p
#修改使用者oracle的shell限制: vi /etc/security/limits.conf #增加以下內容: grid soft nproc 2047 grid hard nproc 16384 grid soft nofile 1024 grid hard nofile 65536 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
#修改登入引數,執行以下操作: vi /etc/pam.d/login #增加以下內容: session required /lib64/security/pam_limits.so session required pam_limits.so
#同樣執行以下操作: vi /etc/profile #增加以下內容: I f [ $USER = "oracle" ] ; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi |
1.8 建立檔案目錄
mkdir -p /u01/app/oracle/product/11.2.0/db_1 chown -R oracle:oinstall /u01/app/oracle chmod -R 775 /u01
#建立資料庫檔案目錄 mkdir /data #建立資料庫日誌目錄 mkdir /log #建立歸檔日誌目錄 mkdir /arc |
1.9 安裝Oracle軟體,此步驟不建庫
#使用oracle使用者登入 #首先解壓安裝檔案: unzip p10404530_112030_Linux-x86-64_1of7.zip unzip p10404530_112030_Linux-x86-64_2of7.zip #開啟圖形設定,開啟Xmanager4 的 Passive模式。 export DISPLAY=ip:0.0 #此ip不是伺服器的ip,為自己的筆記本ip #然後進入解壓後的database目錄,執行以下命令: ./runInstaller |
2. DataGuard 主庫的相關配置
2.1 主庫開啟FORCE LOGGING模式
ALTER DATABASE FORCE LOGGING;
作用:不管什麼操作都會生成redo日誌
特點:1.在資料庫mount狀態和open狀態都可以啟動force logging模式
2.臨時表空間和臨時回滾段動作不會生成redo日誌
在主庫節點一上執行
cd $ORACLE_HOME/dbs sqlplus / as sysdba create pfile from spfile; exit
#備份引數檔案 cp initatfdb1.ora /home/oracle/initatfdb1.ora_bak |
編輯引數檔案
vi initatfdb.ora
*.db_unique_name=atfdb *.LOG_ARCHIVE_DEST_1='LOCATION=+FRA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=atfdb' *.log_archive_config='DG_CONFIG=(atfdb,atfdbdg)' *.LOG_ARCHIVE_DEST_2= 'SERVICE=atfdbdg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=atfdbdg' *.LOG_ARCHIVE_DEST_STATE_1=ENABLE *.LOG_ARCHIVE_DEST_STATE_2=ENABLE #更改之前的archive log format *.LOG_ARCHIVE_FORMAT = log%d_%t_%s_%r.arc *.LOG_ARCHIVE_MAX_PROCESSES=30 *.fal_server=atfdbdg *.STANDBY_FILE_MANAGEMENT=AUTO |
#用新編輯的PFILE生成SPFILE,並重啟資料庫 cd $ORACLE_HOME/dbs create spfile='+DATA/atfdb/spfileatfdb.ora' from pfile = 'initatfdb1.ora';
#在兩個節點下,分別在init.ora下面增加下列引數,確保dbs目錄下沒有spfile.ora和spfile.ora檔案,有的話需要改名
#重啟資料庫 srvctl stop database –d atfdb –o immediate srvctl start database –d atfdb |
2.3 建立standby logfile
ALTER DATABASE ADD STANDBY LOGFILE GROUP 17 SIZE 200M; ALTER DATABASE ADD STANDBY LOGFILE GROUP 18 SIZE 200M; ALTER DATABASE ADD STANDBY LOGFILE GROUP 19 SIZE 200M; ALTER DATABASE ADD STANDBY LOGFILE GROUP 20 SIZE 200M; |
作用:主庫切換到備庫角色時接收主庫redo日誌
檢查:
SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM GV$STANDBY_LOG; |
特點:
1. standby logfile和online redolog大小應一致,管理方便
2. 如果是單例項資料庫那麼standby logfile組比online redolog組的個數多一個;如果是rac架構那麼standby logfile組個數=rac節點數*(online redolog組個數+1)
2.4 在各節點分別配置監聽
cd $ORACLE_HOME/network/admin vi tnsnames.ora
#modified by neo for the data guard on date
ATFDBDG = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ATFDBDG)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = atfdbdg) ) ) |
2.5 建立主庫資料檔案的備份
#登入到主庫的RAC節點2 #建立備份存放目錄 mkdir /home/oracle/backup rman tareget / run { allocate channel d1 type disk; backup tag 'dbfull' format '/home/oracle/backup/dbfull_%d_%s_%p.bck' database include current controlfile; backup tag 'logfull' format '/home/oracle/backup/logfull_%d_%s_%p.bck' archivelog all; release channel d1;} exit |
#登入到節點2 su – oracle sqlplus / as sysdba shutdown immediate STARTUP MOUNT; ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/oracle/backup/controlfile.ctl'; ALTER DATABASE OPEN; #在備庫建立對應的備份存放目錄 mkdir /home/oracle/backup scp /home/oracle/backup/* oracle@ip:/home/oracle/backup |
2.7 複製主庫密碼檔案到備庫上
cd $ORACLE_HOME/dbs scp orapwatfdb1 oracle@ip:/u01/app/oracle/product/11.2.0/db_1/dbs/ |
2.8 複製主庫的引數檔案到備庫
cd scp init* oracle@ip:/u01/app/oracle/product/11.2.0/db_1/dbs/ |
3. 配置Dataguard備庫的相關配置
3.1 配置備庫的引數檔案
vi initatfdb.ora
atfdb2.__db_cache_size=10670309376
atfdb1.__db_cache_size=10670309376
這樣的引數改為一個,如
*.__db_cache_size=10670309376
去掉下面引數
atfdb1.instance_number=1
atfdb2.instance_number=2
atfdb1.instance_number=1
atfdb2.instance_number=2
*.cluster_database=true
*.remote_listener='rac-scan:1521'
增加下面引數
*.db_name='atfdb' DB_UNIQUE_NAME=atfdbdg *.db_create_file_dest='/data' *.db_create_online_log_dest_1='/log' *.db_create_online_log_dest_2='/log' *.control_files='/u01/app/oracle/product/11.2.0/db_1/dbs/controlfile01.ctl, /u01/app/oracle/product/11.2.0/db_1/dbs/controlfile02.ctl' LOG_ARCHIVE_DEST_1= 'LOCATION=/arc VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=atfdbdg' LOG_ARCHIVE_DEST_2= 'SERVICE=misdb ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=atfdb' FAL_SERVER=atfdb LOG_ARCHIVE_CONFIG='DG_CONFIG=(atfdb,atfdbdg)' STANDBY_FILE_MANAGEMENT=AUTO |
複製從主庫傳送過來的控制檔案到對應目錄
cp /home/oracle/backup/controlfile.ctl /u01/app/oracle/product/11.2.0/db_1/dbs/controlfile01.ctl
cp /home/oracle/backup/controlfile.ctl /u01/app/oracle/product/11.2.0/db_1/dbs/controlfile02.ctl
3.2 配置備庫的監聽
在備庫的/etc/hosts裡面,新增主庫rac-scan和其ip的解析
su - root
vi /etc/hostsATFDB ip
ATFDBDG ip
cd $ORACLE_HOME/network/admin
vi listener.ora
# Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = atfdbdg) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = atfdb1) ) )
LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ATFDBDG)(PORT = 1521)) ) ADR_BASE_LISTENER = /u01/app/oracle |
vi tnsnames.ora
ATFDBDG = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ATFDBDG)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = atfdbdg) ) )
ATFDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ATFDB )(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = atfdb) ) ) |
lsnrctl stop
lsnrctl start
3.3 透過RMAN恢復從主庫傳送過來的備份檔案在備庫下建立spfile
cd $ORACLE_HOME/dbs sqlplus / as sysdba create spfile from pfile= 'initatfdb1.ora_bak'; |
啟動資料庫到mount狀態
sqlplus / as sysdba
startup mount
透過RMAN恢復從主庫傳送過來的備份檔案
CATALOG START WITH '/home/oracle/backup/'; |
3.4 備庫啟動日誌應用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION; SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
|
3.5 啟動資料庫日誌實時應用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; |
3.6 檢查備庫資料庫狀態
select database_role,switchover_status,open_mode from v$database; |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-1810725/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 11g RAC 配置單例項 DataGuard(通過 DUPLICATE 方式)Oracle單例
- ORACLE 11G 建立 DATAGUARD(雙節點RAC-->單例項DG)Oracle單例
- oracle單例項通過dataguard遷移到RAC 轉Oracle單例
- Oracle 11g RAC到單例項OGG同步Oracle單例
- oracle單例項轉RACOracle單例
- Oracle11g 搭建單例項DataGuardOracle單例
- 配置 Oracle 10g 單例項物理dataguard和邏輯standbyOracle 10g單例
- Oracle DataBase單例項遷移到Oracle RACOracleDatabase單例
- oracle 11G dataguard配置Oracle
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(7)LinuxOracle
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(6)LinuxOracle
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(5)LinuxOracle
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(4)LinuxOracle
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(3)LinuxOracle
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(2)LinuxOracle
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(1)LinuxOracle
- Oracle 11g RAC跨例項控制並行Oracle並行
- [zt] Oracle 11g DataGuard 配置Oracle
- oracle 11g 單例項安裝Oracle單例
- Oracle10g RAC環境下DataGuard備庫搭建例項Oracle
- Oracle 單機配置DataGuardOracle
- ORACLE 11g dataguard配置練習Oracle
- oracle rac及單例項開啟歸檔Oracle單例
- 單例項和RAC打造的ORACLE STREAM(完)單例Oracle
- 單例項和RAC打造的ORACLE STREAM(四)單例Oracle
- 單例項和RAC打造的ORACLE STREAM(三)單例Oracle
- 單例項和RAC打造的ORACLE STREAM(二)單例Oracle
- 單例項和RAC打造的ORACLE STREAM(一)單例Oracle
- Oracle10g RAC環境下DataGuard備庫搭建例項-eygleOracle
- 配置 Oracle 10g RAC primary + RAC physical standby dataguardOracle 10g
- RAC起單例項make單例
- oracle rac + dataguardOracle
- 11G RAC 異機恢復至單例項測試單例
- RAC 例項 遷移到 單例項 -- 使用RMAN Duplicate單例
- oracle 10g rac 單例項恢復至ORACLE10G RAC RMANOracle 10g單例
- Oracle 11G資料庫單例項安裝Oracle資料庫單例
- RAC+DG(asm單例項)ASM單例
- rac恢復到單例項單例