Oracle并行服务器(OPS)
--------------------------
http://doc.linuxpk.com/49010.html
本文以问答的方式阐述了Oracle并行服务器的相关概念。
1、什么是OPS
OPS(Oracle Parallel Server)可以让位于不同系统的多个实例同时访问同一个数据库。并行服务器可以有效地提高系统的可用性和对多系统的访问性能,但是,如果你的数据没有做很好的分割,性能可能还会下降。
安装OPS时,多个实例mount同一数据库文件,实例间的通讯由分布式锁管理器(DLM)来管理。需要注意的是分布式锁管理器与你所使用的硬件和* 作系统有着密切的关系。为了确定多个企图同时修改同一数据的实例,Oracle使用了十个后台进程:LCK0-LCK9,来锁定某一实例所使用的资源。
OPS主要用于UNIX/LINUX集群环境中。
2、OPS的优点
1)高可用性
2)加快事务响应时间 - 可用于决策支持系统
3)增大交易连接数 - 可用于联机事务处理系统
3、所有的应用都是适合OPS吗?
可以根据功能或数据进行分割的应用最适合OPS。那些有"热数据"(经常被多实例同时访问的数据)的应用并不适合使用OPS。
4、OPS需要特殊的硬件吗?
OPS要求服务器之间互连并共享磁盘子系统。所有可以做成集群的系统都可以,常用的有UNIX/LINUX和NT等。
5、如何设置OPS?
1)关闭数据库
2)启用OPS选项,在UNIX中通过重新连接Oracle软件的方式来完成。
3)使Oracle软件在所有节点上都有效,可以通过复制软件到其他节点或共享磁盘的方式来完成。
4)每个实例要有自己的Redo log file,所以要增加必要的log文件:
ALTER DATABASE ADD LOGFILE THREAD 2
GROUP G4 ('RAW_FILE1') SIZE 500k,
GROUP G5 ('RAW_FILE2') SIZE 500k,
GROUP G6 ('RAW_FILE3') SIZE 500k;
ALTER DATABASE ENABLE PUBLIC THREAD 2;
5)每个实例要有自己的回滚段,所以要增加必要的回滚段:
CREATE ROLLBACK SEGMENT RB2 TABLESPACE RBS;
6)编辑初始化参数文件initSID.ora文件,添加如下几项:
PARALLEL_SERVER = TRUE
INSTANCE_NUMBER = 1
THREAD = 1
ROLLBACK_SEGMENTS = (r01, r02, r03, r04)
7)创建OPS所需的数据字典,即运行CATPARR.SQL。
8)在所有的节点上启动实例。
6、如何确定一个数据库是运行在并行状态?
show parameter parallel_server
7、如何跟踪活动的实例?
SELECT * FROM SYS.V_$ACTIVE_INSTANCES;
SELECT * FROM SYS.V_$THREAD;
8、如何确定每个实例使用了多少个PCM锁?
select count(*) "Number of hashed PCM locks"
from v$lock_element where bitand(flags, 4) != 0
/
select count(*) "Number of fine grain PCM locks"
from v$lock_element where bitand(flags, 4) = 0
/
9、如何查看每个数据文件分配了多少个PCM锁以及ping率?
col file_name format a29
col tablespace format a12
col blocking format 9999999
col nlocks format 99999
col start_lk format 9999999
select l.file_id ¦ ¦ ' ' ¦ ¦ l.file_name file_name,
l.ts_name "TABLESPACE",
start_lk, nlocks, blocking, frequency "PING COUNT"
from sys.file_ping p, sys.file_lock l
where l.file_id = p.file_id
order by l.file_id
/
10、什么是pinging?
Pinging是进程,用于协调多实例对同一数据块的读写*作。OPS性能优化的一个挑战就是要最小化pinging。
11、如何监控PCM锁的活动情况?
查看当前实例活动PCM锁的总数:select * from sys.v$lock_activity;
查看每个数据库对象的PCM锁活动状况:
col table format a40
select file#, kind ¦ ¦' ' ¦ ¦username ¦ ¦'.' ¦ ¦name "TABLE", sum(xnc) pings
from sys.v$false_ping p, sys.dba_users u
where u.user_id = p.owner#
group by file#, kind ¦ ¦' ' ¦ ¦username ¦ ¦'.' ¦ ¦name, xnc
order by xnc desc
/
12、如何设置一个对所有OPS实例通用的SQL*Net连接串?
1)首先要求所有节点上的SID相同,如果不相同可以按如下*作进行更改:
关闭数据库的所有实例
将ORACLE_SID环境变量设成一致
复制原来的初始化文件initOLDSID.ora为initCOMMON.ora
重起所有实例
2)编辑本地TNSNAMES.ora,如下例:
PHOENIX =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.50)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.51)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora8)
)
)
ps:
设置并行查询,提高CPU利用率:
http://www.oracle.com.cn/archiver/?tid-120936.html
-------------------------
Parallel query is the most commonly used of Oracle's parallel execution features. It was the first parallel execution feature to be developed by Oracle and was introduced in Oracle Release 7.1 as the Oracle Parallel Query Option (PQO). Parallel execution can significantly reduce the elapsed time for large queries, but it doesn't apply to every query.
To parallelize a SELECT statement, the following conditions must be met:
1、 At least one of the tables is accessed through a full table scan, or an index is accessed through a range scan involving multiple partitions.
2、 If the execution involves a full table scan, the statement must contain a PARALLEL hint specifying the corresponding table, or the corresponding table must have a parallel declaration in its definition.
3、 If the execution involves an index range scan spanning multiple partitions, the statement must contain a PARALLEL_INDEX hint specifying the corresponding index, or the corresponding index must have a parallel declaration in its definition.
The following two sections explain how the degree of parallelism is chosen for a SELECT statement and discuss restrictions on the use of the parallel query feature.
Setting the Degree of Parallelism
Once Oracle decides to execute a SELECT statement in parallel, the degree of parallelism is determined by following precedence rules:
Oracle retrieves the DEGREE and INSTANCES specifications from the definition of all tables and indexes involved in the query and chooses the highest values found for those settings.
Oracle checks the statement for a parallel hint. If such a hint is found, the hint overrides the degree of parallelism obtained as a result of the previous step.
You can use the PARALLEL and PARALLEL_INDEX hints to specify the degree of parallelism for a SELECT statement. You can use the NOPARALLEL and NOPARALLEL_INDEX hints to ensure that parallel execution is not performed.
Example
alter table emp parallel (degree 4);
select degree from user_tables where table_name = 'EMP';
select count(*) from emp;
alter table emp noparallel;
SELECT /*+ PARALLEL(emp,4) */ COUNT(*)
FROM emp;
--------------------------
http://doc.linuxpk.com/49010.html
本文以问答的方式阐述了Oracle并行服务器的相关概念。
1、什么是OPS
OPS(Oracle Parallel Server)可以让位于不同系统的多个实例同时访问同一个数据库。并行服务器可以有效地提高系统的可用性和对多系统的访问性能,但是,如果你的数据没有做很好的分割,性能可能还会下降。
安装OPS时,多个实例mount同一数据库文件,实例间的通讯由分布式锁管理器(DLM)来管理。需要注意的是分布式锁管理器与你所使用的硬件和* 作系统有着密切的关系。为了确定多个企图同时修改同一数据的实例,Oracle使用了十个后台进程:LCK0-LCK9,来锁定某一实例所使用的资源。
OPS主要用于UNIX/LINUX集群环境中。
2、OPS的优点
1)高可用性
2)加快事务响应时间 - 可用于决策支持系统
3)增大交易连接数 - 可用于联机事务处理系统
3、所有的应用都是适合OPS吗?
可以根据功能或数据进行分割的应用最适合OPS。那些有"热数据"(经常被多实例同时访问的数据)的应用并不适合使用OPS。
4、OPS需要特殊的硬件吗?
OPS要求服务器之间互连并共享磁盘子系统。所有可以做成集群的系统都可以,常用的有UNIX/LINUX和NT等。
5、如何设置OPS?
1)关闭数据库
2)启用OPS选项,在UNIX中通过重新连接Oracle软件的方式来完成。
3)使Oracle软件在所有节点上都有效,可以通过复制软件到其他节点或共享磁盘的方式来完成。
4)每个实例要有自己的Redo log file,所以要增加必要的log文件:
ALTER DATABASE ADD LOGFILE THREAD 2
GROUP G4 ('RAW_FILE1') SIZE 500k,
GROUP G5 ('RAW_FILE2') SIZE 500k,
GROUP G6 ('RAW_FILE3') SIZE 500k;
ALTER DATABASE ENABLE PUBLIC THREAD 2;
5)每个实例要有自己的回滚段,所以要增加必要的回滚段:
CREATE ROLLBACK SEGMENT RB2 TABLESPACE RBS;
6)编辑初始化参数文件initSID.ora文件,添加如下几项:
PARALLEL_SERVER = TRUE
INSTANCE_NUMBER = 1
THREAD = 1
ROLLBACK_SEGMENTS = (r01, r02, r03, r04)
7)创建OPS所需的数据字典,即运行CATPARR.SQL。
8)在所有的节点上启动实例。
6、如何确定一个数据库是运行在并行状态?
show parameter parallel_server
7、如何跟踪活动的实例?
SELECT * FROM SYS.V_$ACTIVE_INSTANCES;
SELECT * FROM SYS.V_$THREAD;
8、如何确定每个实例使用了多少个PCM锁?
select count(*) "Number of hashed PCM locks"
from v$lock_element where bitand(flags, 4) != 0
/
select count(*) "Number of fine grain PCM locks"
from v$lock_element where bitand(flags, 4) = 0
/
9、如何查看每个数据文件分配了多少个PCM锁以及ping率?
col file_name format a29
col tablespace format a12
col blocking format 9999999
col nlocks format 99999
col start_lk format 9999999
select l.file_id ¦ ¦ ' ' ¦ ¦ l.file_name file_name,
l.ts_name "TABLESPACE",
start_lk, nlocks, blocking, frequency "PING COUNT"
from sys.file_ping p, sys.file_lock l
where l.file_id = p.file_id
order by l.file_id
/
10、什么是pinging?
Pinging是进程,用于协调多实例对同一数据块的读写*作。OPS性能优化的一个挑战就是要最小化pinging。
11、如何监控PCM锁的活动情况?
查看当前实例活动PCM锁的总数:select * from sys.v$lock_activity;
查看每个数据库对象的PCM锁活动状况:
col table format a40
select file#, kind ¦ ¦' ' ¦ ¦username ¦ ¦'.' ¦ ¦name "TABLE", sum(xnc) pings
from sys.v$false_ping p, sys.dba_users u
where u.user_id = p.owner#
group by file#, kind ¦ ¦' ' ¦ ¦username ¦ ¦'.' ¦ ¦name, xnc
order by xnc desc
/
12、如何设置一个对所有OPS实例通用的SQL*Net连接串?
1)首先要求所有节点上的SID相同,如果不相同可以按如下*作进行更改:
关闭数据库的所有实例
将ORACLE_SID环境变量设成一致
复制原来的初始化文件initOLDSID.ora为initCOMMON.ora
重起所有实例
2)编辑本地TNSNAMES.ora,如下例:
PHOENIX =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.50)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.51)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora8)
)
)
ps:
设置并行查询,提高CPU利用率:
http://www.oracle.com.cn/archiver/?tid-120936.html
-------------------------
Parallel query is the most commonly used of Oracle's parallel execution features. It was the first parallel execution feature to be developed by Oracle and was introduced in Oracle Release 7.1 as the Oracle Parallel Query Option (PQO). Parallel execution can significantly reduce the elapsed time for large queries, but it doesn't apply to every query.
To parallelize a SELECT statement, the following conditions must be met:
1、 At least one of the tables is accessed through a full table scan, or an index is accessed through a range scan involving multiple partitions.
2、 If the execution involves a full table scan, the statement must contain a PARALLEL hint specifying the corresponding table, or the corresponding table must have a parallel declaration in its definition.
3、 If the execution involves an index range scan spanning multiple partitions, the statement must contain a PARALLEL_INDEX hint specifying the corresponding index, or the corresponding index must have a parallel declaration in its definition.
The following two sections explain how the degree of parallelism is chosen for a SELECT statement and discuss restrictions on the use of the parallel query feature.
Setting the Degree of Parallelism
Once Oracle decides to execute a SELECT statement in parallel, the degree of parallelism is determined by following precedence rules:
Oracle retrieves the DEGREE and INSTANCES specifications from the definition of all tables and indexes involved in the query and chooses the highest values found for those settings.
Oracle checks the statement for a parallel hint. If such a hint is found, the hint overrides the degree of parallelism obtained as a result of the previous step.
You can use the PARALLEL and PARALLEL_INDEX hints to specify the degree of parallelism for a SELECT statement. You can use the NOPARALLEL and NOPARALLEL_INDEX hints to ensure that parallel execution is not performed.
Example
alter table emp parallel (degree 4);
select degree from user_tables where table_name = 'EMP';
select count(*) from emp;
alter table emp noparallel;
SELECT /*+ PARALLEL(emp,4) */ COUNT(*)
FROM emp;