« May 2008 | Digest首页 | July 2008 »

June 29, 2008

Oracle Dataguard三种保护模式概述

出处:http://www.eygle.com/digest

Oracle的DataGuard技术有三种实现模式,分别是max performance、max availability、max protection这三种模式。

以下是来自Oracle文档的摘要信息:
In some situations, a business cannot afford to lose data. In other situations, the availability of the database may be more important than the loss of data. Some applications require maximum database performance and can tolerate some small amount of data loss. The following descriptions summarize the three distinct modes of data protection.

Maximum protection This protection mode ensures that no data loss will occur if the primary database fails. To provide this level of protection, the redo data needed to recover each transaction must be written to both the local online redo log and to the standby redo log on at least one standby database before the transaction commits. To ensure data loss cannot occur, the primary database shuts down if a fault prevents it from writing its redo stream to the standby redo log of at least one transactionally consistent standby database.

Maximum availability This protection mode provides the highest level of data protection that is possible without compromising the availability of the primary database. Like maximum protection mode, a transaction will not commit until the redo needed to recover that transaction is written to the local online redo log and to the standby redo log of at least one transactionally consistent standby database. Unlike maximum protection mode, the primary database does not shut down if a fault prevents it from writing its redo stream to a remote standby redo log. Instead, the primary database operates in maximum performance mode until the fault is corrected, and all gaps in redo log files are resolved. When all gaps are resolved, the primary database automatically resumes operating in maximum availability mode.

This mode ensures that no data loss will occur if the primary database fails, but only if a second fault does not prevent a complete set of redo data from being sent from the primary database to at least one standby database.

Maximum performance This protection mode (the default) provides the highest level of data protection that is possible without affecting the performance of the primary database. This is accomplished by allowing a transaction to commit as soon as the redo data needed to recover that transaction is written to the local online redo log. The primary database's redo data stream is also written to at least one standby database, but that redo stream is written asynchronously with respect to the transactions that create the redo data.

When network links with sufficient bandwidth are used, this mode provides a level of data protection that approaches that of maximum availability mode with minimal impact on primary database performance.

The maximum protection and maximum availability modes require that standby redo log files are configured on at least one standby database in the configuration. All three protection modes require that specific log transport attributes be specified on the LOG_ARCHIVE_DEST_n initialization parameter to send redo data to at least one standby database. See Section 5.6 for complete information about the data protection modes.

以下是对以上摘要信息的翻译信息:

在一些情况下,业务不允许丢失数据。在另外一些情况下,数据库的可用性比丢失数据更为重要。一些应用需要最强的数据库性能并且能容忍丢失少量的数据。下面的描述概述了三种不同的数据保护模式。

最大保护模式 -- 这种保护模式确保如果主数据库故障不会发生数据丢失。要提供这种级别的保护,恢复每个事务所需的重做数据必须在事务提交之前同时写到本地联机重做日志和至少一个备数据库上的备重做日志。要确保不发生数据丢失,如果故障导致主数据库无法写重做流到至少一个事务一致性备数据库的备重做日志时,主数据库会关闭。

最大可用性模式 -- 这种保护模式提供了可能的最高级别的数据保护,而不用与主数据库的可用性相折衷。与最大保护模式相同,在恢复事务所需的重做写到本地联机重做日志和至少一个事务一致性备数据库上的备重做日志之前,事务将不会提交。与最大保护模式不同的是,如果故障导致主数据库无法写重做流到异地备重做日志时,主数据库不会关闭。替代地,主数据库以最大性能模式运行直到故障消除,并且解决所有重做日志文件中的中断。当所有中断解决之后,主数据库自动继续以最大可用性模式运行。

这种模式确保如果主数据库故障,但是只有当第二次故障没有阻止完整的重做数据集从主数据库发送到至少一个备数据库时,不发生数据丢失。

最大性能模式 -- 这种保护模式(默认)提供了可能的最高级别的数据保护,而不影响主数据库的性能。这是通过允许事务在恢复该事务所需重做数据在写到本地联机重做日志后立即提交而实现的。主数据库的重做数据流也写到至少一个备数据库,但是那个重做流相对于创建重做数据的事务是异步写的。

当所用的网络连接有足够的带宽,这种模式提供了近似于最大可用性模式的数据保护级别,并且对主数据库性能的影响最小。
最大保护和最大可用性模式需要备重做日志文件配置在配置中的至少一个备数据库上。所有三种保护模式需要在LOG_ARCHIVE_DEST_n 初始化参数上指定特定的日志传输属性以发送重做数据到至少一个备数据库。查看5.6 节以获得数据保护模式的完整信息。

Posted by eygle at 7:22 PM | Comments (0)

June 24, 2008

AIX 系统中 PVID 的含义与作用

出处:http://www.eygle.com/digest

Pvid是aix系统中的ODM LVM用于识别PV的序列号,操作系统通过pvid来识别pv,就好像我们每个人的ID card。

当pv被添加到系统中之后,可以通过两种方式生成pvid

1,cfgmgr -v
2,lspv 如果没有PVID的话,执行chdev -l hdiskn -a pv=yes

也就是说当系统可以识别硬盘 并将硬盘认可为pv(即lvm的组件)的时候。系统就分配了pvid给硬盘,系统的odm库中保存有pvid。
Pvid的生成原则是 主板序列号+形成pv时候的时间戳,pvid除了写入odm库,在硬盘头信息里(0扇区的头几个字节)以及VGDA 也将写入pvid

To make a disk into a physical volume, the PVID is placed onto the disk. ThePVID is an combination of the machine's serial number (from the systems EPROMs) and the date the PVID was generated. This combination ensures the extremely low chance of PVIDs being duplicated. When the system is booted, the disk configurator looks at the PVID residing on the disk and compares it with an entry in the ODM. If an entry is found, then the disk is given the hdiskx number in the ODM that is associated with the PVID. If there is no matching entry, then the next name in the pool of 'free' hdisk names is allocated to the physical volume.

可以通过 lquerypv -H hdisk0查看pv上的pvid

ibm150:[/]#lquerypv -H /dev/hdisk0
000af70de396426b0000000000000000
ibm150:[/]#lspv
hdisk0 000af70de396426b datavg
hdisk1 000af70d5c816fc2 rootvg
hdisk2 000af70d4d50358c rootvg

可以看到三个pv的pvid前几位数字是相同的(即主板序列号),后几位数字是不同的。

可以通过以下方法修改pvid
chdev -l hdisk1 -a pv=clear 清除pv 磁盘头的pvid
chdev -l hdisk1 -a pv=yes 重新定义pvid

如果pv已经加入卷组,首先还得先varyoffvg ,exportvg
执行以上步骤,pv的pvid将会改变。这里修改的只是磁盘头的pvid,并没有修改vgda中的pvid


当pv已经是一个卷组的成员时,切记不要随便修改pvid

因为当pv加入一个卷组的时候,pvid将被写入vgda,如果你擅自修改卷组的pvid,然后新生成的pvid将不能和卷组vgda中的pvid相匹配,这样就无法importvg,就无法varyonvg,很有可能就会丢失数据!

当importvg的时候,odm将读取pv上的vgda,如果vgda上pvid与自身磁盘上的pvid不符合的话,将出现错误!


注意:当pv加入卷组以后,pvid在硬盘上存在于至少两个地方,一个是在硬盘头,一个是在vgda中。这两个地方的pvid一般是相同的,但是由于pvid的修改,可能造成不一致,这样就有可能丢失数据。

你可以通过
#lqueryvg -Atp hdisk0 查看pv vgda中的pvid

ibm150:[/]#lqueryvg -Atp hdisk0
Max LVs: 256
PP Size: 25
Free PPs: 85
LV count: 3
PV count: 1
Total VGDAs: 2
Conc Allowed 0
MAX PPs per 1016
MAX PVs: 32
Conc Autovar 0
Varied on Co 0
Logical: 000af70d00004c0000000106e3964781.1 loglv00 1
000af70d00004c0000000106e3964781.2 lv00 1
000af70d00004c0000000106e3964781.3 lv02 1
Physical: 000af70de396426b 2 0
Total PPs: 542
LTG size: 128
HOT SPARE: 0
AUTO SYNC: 0
VG PERMISSIO 0

当然万一修改了,还是有办法恢复数据的!
1, 修复卷组(推荐)
1.首先将原卷组的定义从系统的ODM库中删除:
# exportvg vgname

2.检查硬盘上VGDA 区的信息,从中得到有关逻辑卷的名称及定义:
如:

#lqueryvg -Atp hdisk2
Max LVs: ------256
PP Size: ------26
Free PPs: -----538
LV count: -----2
PV count: -----1
Total VGDAs: --2
Conc Allowed --0
MAX PPs per ---1016
MAX PVs: ------32
Conc Autovar --0
Varied on Co --0
Logical: ------0003f62a00004c00000000f52f1737c5.1 --datalv1 1
---------------0003f62a00004c00000000f52f1737c5.2 --datalv2 1
Physical: -----0003f62a2f135f0e --------------2 ----0
Total PPs: ----542
LTG size: -----128
HOT SPARE: ----0
AUTO SYNC: ----0
VG PERMISSIO --0

3.创建逻辑卷名对应表文件。 第一字段为VGDA区中的逻辑卷的名,第二字段为在新卷组中新的逻辑卷名,可相同也可不同;为了修复原有卷组的内容,通常逻辑卷名保持不变。

如:

#vi /tmp/lvname
datalv1:datalv1
datalv2:datalv2

4. 在硬盘上重新创建卷组,保留原有卷组的数据结构。

#recreatevg -y vgname -l lv_file hdisk_name...
如:
#recreatevg -y testvg -l /tmp/lvname hdisk2

5. 如果卷组上有文件系统,还需修改 /etc/filesystems ,使对应的文件系统的加载点与原来的一致。首先修改/etc/filesystems文件,不行的话就执行下面的步骤
或者:

如果在重新import后,发现mountpoint不同,可以通过smitty chlv修改lv属性,即修改Logical volume LABEL,使之与mount point相同。

为什么要修改/etc/filesystem呢?

recreatevg 后,系统自动创建了目录/fs,所有的文件系统加载到了/fs下,原来的mountpoint是以/为基准的.

来源链接:
http://blog.chinaunix.net/u1/39140/showart_304297.html

Posted by eygle at 10:07 PM | Comments (1)

June 10, 2008

JDBC连接Oracle RAC的连接串配置

出处:http://www.eygle.com/digest

jdbc连接oracle的连接串如下:

String url="jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = ON)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = db.domain)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RETIRES = 20)(DELAY = 15))))";


java测试程序如下:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Test {

public static void main(String arg[]) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = ON)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = db.domain)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RETIRES = 20)(DELAY = 15))))";
Connection c = DriverManager.getConnection(url,"aa","aa");
Statement s = c.createStatement();
ResultSet r = s.executeQuery("select 1 from dual");
while(r.next()) {
System.out.println(r.getString(1));
}
}catch(Exception e) {
System.out.println(e.toString());
}
}

}


Posted by eygle at 10:06 AM | Comments (0)


CopyRight © 2004-2008 eygle.com, All rights reserved.