2、安装oracle软件
3、规划数据库:逻辑结构、数据库设计、备份策略、等
4、创建和打开数据库
5、备份、恢复数据库
6、创建数据库用户
7、执行数据库设计
8、备份正常工作的数据库
9、调优数据库性能
vi /etc/sysctl.conf修改类似下面的内容:
(下面的内容为11g要求,不同版本参数可能不同,http://docs.oracle.com/cd/B28359_01/install.111/b32285/toc.htm#CEGFBCFD)
fs.file-max = 65536
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
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 = 1048576
使用下面的命令使得内核改变立即生效:
/sbin/sysctl -p
验证下配置是否有效,可用/sbin/sysctl -a查看。
然后可以继续你的工作了
切换:1.停止Redo Apply
如果备库正处于RedoApply过程,需要先取消。
sys@ora11gdg>alter database recover managed standby database cancel
Database altered.
2.查看当前备库状态确保备库处于MOUNTED状态
sys@ora11gdg>select database_role,open_mode from v$database
DATABASE_ROLEOPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED
此时备库是物理备库角色,运行模式是MOUNTED。
3.确保闪回恢复区已指定
友情提示:实现SnapshotStandby数据库功能并不需要开启主库和备库的闪回数据库(Flashback Database)功能,与是否开启闪回数据库无关。
sys@ora11gdg>show parameter db_recovery_file_dest
NAME TYPE VALUE
--------------------------- ------------ ------------------------------------
db_recovery_file_dest string /u01/app/oracle/flash_recovery_area
db_recovery_file_dest_size big integer 3852M
确认主库闪回功能并未开启
sys@ora11g>select FLASHBACK_ON from v$database
FLASHBACK_ON
------------------
NO
确认备库闪回功能并未开启
sys@ora11gdg>select FLASHBACK_ON from v$database
FLASHBACK_ON
------------------
NO
4.调整备库到SnapshotStandby数据库状态
只需要执行一条非常简单的SQL命令便可以将备库调整到Snapshot Standby数据库。
sys@ora11gdg>alter database convert to snapshot standby
Database altered.
sys@ora11gdg>select database_role,open_mode from v$database
DATABASE_ROLEOPEN_MODE
---------------- --------------------
SNAPSHOT STANDBY MOUNTED
5.将备库置于对外可读写状态
sys@ora11gdg>alter database open
Database altered.
sys@ora11gdg>select database_role,open_mode from v$database
DATABASE_ROLEOPEN_MODE
---------------- --------------------
SNAPSHOT STANDBY READ WRITE
一套全新的可读写数据库展现在我们面前。
6.分析切换过程中的日志信息
ora11g主库alert日志:
Mon Mar 19 18:46:28 2012
LNS: Attempting destination LOG_ARCHIVE_DEST_2 network reconnect (3135)
LNS: Destination LOG_ARCHIVE_DEST_2 network reconnect abandoned
Errors in file/u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_nsa2_27302.trc:
ORA-03135: connection lost contact
Error 3135 for archive log file 2 to 'ora11gdg'
Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_nsa2_27302.trc:
ORA-03135: connection lost contact
LNS: Failed to archive log 2 thread 1 sequence 50 (3135)
Errors in file/u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_nsa2_27302.trc:
ORA-03135: connection lost contact
ora11gdg备库alert日志:
Mon Mar 19 18:46:26 2012
alter database convert to snapshot standby
Starting background process RVWR
Mon Mar 19 18:46:26 2012
RVWR started with pid=26, OS id=8824
Allocated 3981204 bytes in shared pool for flashback generation buffer
Created guaranteed restore point SNAPSHOT_STANDBY_REQUIRED_03/19/201218:46:26
krsv_proc_kill: Killing 3 processes (all RFS)
Begin: Standby Redo Logfile archival
End: Standby Redo Logfile archival
RESETLOGS after complete recovery through change 1472476
Resetting resetlogs activation ID 4174194338 (0xf8cd26a2)
Online log /u01/app/oracle/oradata/ora11gdg/redo01.log: Thread 1 Group 1 waspreviously cleared
Online log /u01/app/oracle/oradata/ora11gdg/redo02.log: Thread 1 Group 2 waspreviously cleared
Online log /u01/app/oracle/oradata/ora11gdg/redo03.log: Thread 1 Group 3 waspreviously cleared
Standby became primary SCN: 1472474
Mon Mar 19 18:46:29 2012
Setting recovery target incarnation to 5
CONVERT TO SNAPSHOT STANDBY: Complete - Database mounted as snapshot standby
Completed: alter database convert to snapshot standby
关键的一行提示信息“Created guaranteed restore point SNAPSHOT_STANDBY_REQUIRED_03/19/201218:46:26”,这里给出了我们转换成snapshot的时刻,便于后面的回切。
7.测试备库处于SnapshotStandby数据库对主库日志的接收
当主库切换日志时,备库依然可以接收到日志,只是并不应用
1)主库切换日志
sys@ora11g>alter system switch logfile
System altered.
2)主库记录的alert日志内容
ora11g主库alert日志:
Mon Mar 19 18:52:00 2012
Thread 1 cannot allocate new log, sequence 52
Private strand flush not complete
Current log# 3 seq# 51 mem# 0: /u01/app/oracle/oradata/ora11g/redo03.log
Mon Mar 19 18:52:00 2012
ARC3: Standby redo logfile selected for thread 1 sequence 50 for destinationLOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 52 (LGWR switch)
Current log# 1 seq# 52 mem# 0: /u01/app/oracle/oradata/ora11g/redo01.log
Mon Mar 19 18:52:03 2012
Archived Log entry 91 added for thread 1 sequence 51 ID 0xf8cd26a2 dest 1:
Mon Mar 19 18:52:03 2012
LNS: Standby redo logfile selected for thread 1 sequence 51 for destinationLOG_ARCHIVE_DEST_2
LNS: Standby redo logfile selected for thread 1 sequence 52 for destinationLOG_ARCHIVE_DEST_2
ora11gdg备库alert日志:
Mon Mar 19 18:52:00 2012
RFS[5]: Assigned to RFS process 9174
RFS[5]: Identified database type as 'snapshot standby': Client is ARCH pid27296
Mon Mar 19 18:52:00 2012
RFS[6]: Assigned to RFS process 9176
RFS[6]: Identified database type as 'snapshot standby': Client is ARCH pid27300
RFS[6]: Selected log 4 for thread 1 sequence 50 dbid -120744030 branch778023141
Mon Mar 19 18:52:00 2012
Archived Log entry 47 added for thread 1 sequence 50 ID 0xf8cd26a2 dest 1:
Mon Mar 19 18:52:03 2012
RFS[7]: Assigned to RFS process 9180
RFS[7]: Identified database type as 'snapshot standby': Client is LGWR ASYNCpid 27302
RFS[7]: Selected log 4 for thread 1 sequence 51 dbid -120744030 branch778023141
Mon Mar 19 18:52:04 2012
Archived Log entry 48 added for thread 1 sequence 51 ID 0xf8cd26a2 dest 1:
RFS[7]: Selected log 4 for thread 1 sequence 52 dbid -120744030 branch778023141
3)查看主库和备库归档目录下的日志文件内容
(1)主库归档日志文件
ora11g@secdb /home/oracle/arch/ora11g$ ls -ltr
total 879M
……省略其他……
-rw-r----- 1 oracle oinstall 1.1M Mar 19 18:51 1_50_778023141.arc
-rw-r----- 1 oracle oinstall 363K Mar 19 18:52 1_51_778023141.arc
(2)备库归档日志文件
ora11g@secdb /home/oracle/arch/ora11gdg$ ls -ltr
total 847M
……省略其他……
-rw-r----- 1 oracle oinstall 1.1M Mar 19 18:52 1_50_778023141.arc
-rw-r----- 1 oracle oinstall 363K Mar 19 18:52 1_51_778023141.arc
可见,备库已经接受到主库发过来的日志。
8.在SnapshotStandby数据创建用户和表并初始化数据
sys@ora11gdg>create user ocmu identified by ocmu
User created.
secooler@ora11gdg>grant dba to ocmu
Grant succeeded.
secooler@ora11gdg>conn ocmu/ocmu
Connected.
ocmu@ora11gdg>create table t (x varchar2(8))
Table created.
ocmu@ora11gdg>insert into t values ('Secooler')
1 row created.
ocmu@ora11gdg>commit
Commit complete.
ocmu@ora11gdg>select * from t
X
--------
Secooler
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)