Monday, February 27, 2012
Tuesday, October 4, 2011
Setup your Oracle Rac using Open Filer...Copy and Paste Post
Install openfiler O/S,it works like NAS and SAN
Install oracle enterprise linux on both rac nodes
Edit hosts file on both nodes and put entries and remove hostname from first line
vi /etc/hosts
172.22.0.175 rac1
172.22.0.176 rac2
172.22.0.178 rac1-vip
172.22.0.179 rac2-vip
172.22.0.177 openfiler
10.0.0.101 rac1-priv
10.0.0.102 rac2-priv
:wq (save and exit)
Oracle group and user add on both nodes
#groupadd dba
#groupadd oinstall
#useradd -c "Oracle software owner" -G dba -g oinstall oracle
#passwd oracle
Both the group and userid same on both rac nodes
issue the below command to check
#cat /etc/group (for groupid)
#cat /etc/passwd (for userid)
if not change this with below commands
#groupadd -g 1001 oinstall
#groupadd -g 1002 dba
#useradd -u 1001 -g 1001 -G 1002 -d /home/oracle -m oracle
setup sysctl.conf file for configuring kernel parameters on both nodes
kernel.shmmax=2147483648
kernel.shmall = 2097152
kernel.shmmni = 4096
kernel.sem=250 32000 100 128
fs.file-max=65536
net.ipv4.ip_local_port_range=1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_sack =1
net.ipv4.tcp_window_scaling = 1
sysctl -p
Download and run compat packages according to system 32bit or 64bit on both nodes
compat-gcc-7.3-2.96.128.i386.rpm
compat-gcc-c++-7.3-2.96.128.i386.rpm
compat-libcwait-2.1-1.i386.rpm
compat-libstdc++-7.3-2.96.128.i386.rpm
compat-libstdc++-devel-7.3-2.96.128.i386.rpm
compat-oracle-rhel4-1.0-5.i386.rpm
issue below command to run compat packages on both nodes
#rpm -ivh compat* --force --aid
Run below package on both nodes to check post installation of oracle RAC using cluvfy later,this package u will get in oracle clusterware software
#rpm -ivh cvuqdisk-1.0.6-1.rpm --force --aid
Create user-equivalence on both nodes
#su - oracle
$ssh-keygen -t rsa
enter
enter
enter
$cd .ssh/
$cat id_rsa.pub >>authorized_keys
$scp authorized_keys to node 2 on same location example:/home/oracle/.ssh
like this create user-equivalence on 2nd node
Check the time on both nodes it should be same if not give below command to make time synchronise
#date 102812542009.35 (the time format is like this monthdatehourminyear.second)
After installing openfiler you get the url like this https://openfiler:446/ or https://172.22.0.177:446/
Copy and paste this url to open storage graphically
First step click on system and configure network access configuration
hostname ipaddress subnetmask share
rac1 172.22.0.175 255.255.0.0 share
rac2 172.22.0.176 255.255.0.0 share
and click on update
Second step click on services and modify
servicename status modification
iscsi disable enable
click on enable in modification column to make status enable
like this enable all services except UPS server
Third step click on block devices
click on edit disk
/dev/hdc
now you will get new screen create primary and logical space
mode
primary extended create
click on create
again you will get
mode
logical physical create
click on create
Fourth step click on volume groups
give volume group name
click on add volume group
click on create
Fifth step click on add volume
give volume name
give volume Description
give Required space(MB)
give File system iscsi
click on create
Sixth step click on ISCSI targets
click on Target IQN and click on add
click on LAN mapping and click on map
click on Network ACL and click allow on access column and finally click on update to complete configuration
Add parameter on both nodes in iscsi.conf file
#vi /etc/iscsi.conf
add this line
DiscoveryAddress=openfiler
After configuration openfiler and add line in iscsi.conf you will get sharing disk on both nodes issue below command as a root user to check
#fdisk -l
(the output shows sharing disk as contains not a valid partition)
Partitions creating on sharing disk
#service iscsi restart
#fdisk -l
#fdisk /dev/sdb
p (type p to print partition)
n (to create new partition)
p (to create primary partition)
1
enter
enter
+2048m (give size and enter this partition is for ocr information)
n
p
2
enter
enter
+2048m (give size and enter this partition is for voting disk information)
n
p
3
enter
enter
+14000M (give size and enter this partition is for data)
n
e (this is extended partition)
enter
enter
n
enter
+25000m (give full remaining space is for data)
:w (save and exit)
#partprobe /dev/sdb (is for update kernel)
#fdisk -l (here you will get mount points)
#mkfs.ext3 /dev/sdb1 (make ocr and voting disk in ext3 format)
#mkfs.ext3 /dev/sdb2
Give this entry and reboot system once to create logical disk on follwing location on both nodes)
#vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdb2
/dev/raw/raw3 /dev/sdb3
/dev/raw/raw4 /dev/sdb4
:wq
#services iscsi restart
#services rawdevices restart
#chown root.oinstall /dev/raw/raw1 (give permissions to all logical devices for raw1 give root.oinstall because here information of ocr)
#chown oracle.oinstall /dev/raw/raw2
#chown oracle.oinstall /dev/raw/raw3
#chown oracle.oinstall /dev/raw/raw4
login as oracle user and check pre and post installation using cluvfy
$/home/oracle/clusterware/cluvfy/runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose (for pre installation)
$/home/oracle/clusterware/cluvfy/runcluvfy.sh stage -post hwos -n rac1,rac2 -verbose (for post installation)
output shows preinstallation checking successfully completed so we can continue installing clusterware software,if it show unsuccessfully check the errors.
If u get error like user equivalence failed again create keygen and copy on both nodes.If u get error like couldn't find a suitable interfaces for vips.We
can ignore this error and create vip manually using vipca.This error gets due to:-
CVU checks for the following criteria before considering set of interface:
-the interfaces should have the same name across nodes.
-they should belong to the same subnet and same netmask
-they should be on public (and routable) network
Oftentimes,the interfaces planned for the vip's are configured on 10.*.m172.16.*,172.31.*or192.168.* networks which are not routable.Hence CVU does not
consider them as suitable for vip's.If name of the available interfaces satistfy this criteria,cvu complain "error-couldn't find a suitable set of interfaces
for vip's.It is worth nothing that,such addresses will actually work if things are public but cvu just things they're private and reports accordingly.To
invoke vipca go to $ORA_CRS_HOME/bin and run the following command as root user after *.sh scripts are run on both nodes at cluster software installation.
#./vipca
1)click on next button
2)select eth0 and click on next button.
3)Type in the IP alias name for the vip and IP address and click on next
4)lastly click on finish
This will configure startup the vip.Now you can go back to the first screen (means last screen of clusterware software) and click ok.
http://www.idevelopment.into/data/Oracle/DBA_tips/Oracle10gRAC/CLUSTER_18.shtml
Installation clusterware software:
$cd /home/oracle/cluster/
$./runInstaller
u will get window like specify cluster configuration
click on add
public node name (give in bracket(rac2))
private node name (give in bracket(rac2-priv))
virtual host name (give in bracket(rac2-vip))
and click on ok to continue
u will get next window like specify oracle cluster registry(ocr) location
select on external redundancy and on next line give location
specify ocr location /dev/raw/raw1 and click on next to continue
u will get next window specify voting disk location
select on external redundancy and on next line give location
voting disk location /dev/raw/raw2 and click on next to continue
u will get next window click on install to start installation
At the end u will get window to run root.sh and Orainstroot.sh on both nodes with root user
After running this scripts if u r getting error in pre requistion like couldn't find a suitable interfaces for vip's so configure vip using vipca it resides
in clusterware software bin folder and configure vip's as explain above in this note.
Finally u will get window installation completed successfully
OCR :- keeps information of number of rac nodes
Voting Disk :- Cluster processes vote we are alive.It ups another nodes background process if existing nodes fails.
Installation of ASM:
Using normal 10g software install asm
$/home/oracle/oracle10gsoftware/runInstaller
u will get first window select enterprise edition and click on next
u will get second window specify the location of asm to install ex:/home/oracle/product/10.2/asm
u will get next window specify hardware cluster installation mode
select cluster installation,click on rac2 and finally click on next to continue
u will get next window select configure automatic storage management(ASM)
give password specify asm sys password (sys)
give conform password (sys) and finally click on next to continue
u will get next window select on external
on same window select candidates and also select 1st and 2nd point and click on next to continue
u will get next window to run root.sh on both nodes as root user
finally u will get installation completed successfully click on exit to complete installation
Creating ASM database
$export PATH
$export CLASS_PATH
$export LD_LIBRARY
$dbca if not works go to $ORACLE_ASM/bin and run
u will get 1st window select cluset Real Application and click on next
u will get next window select configure automatic storage management
the output shows rac1 and rac2 on same window and click on select all to continue
u will get next window give password:sys and click on next to continue
u will get next window in that u will get by default Disk group name DATA
in the same window select external
in the same window select show candidates it will give output of third and fourth logical derives like /dev/raw/raw3 /dev/raw/raw4
By default i think selected if not select on both and click on ok to continue
u will get next window click on finish to complete asm instance creation.
Installation of Normal Oracle 10g software
$/home/oracle/oracle10gsoftware/runInstaller
u will get window Specify Hardware Cluster Installation Mode select on cluster installation
in the same window u will get rac1 and rac2 by default it is selected if not select both rac1 and rac2 and click on select all to continue
u will get next window click on next to continue
u will get next window click on next to continue
u will get next window select configuration option select install database software only and click on next to continue
u will get next window click on install to complete installations
Creation of database
$export ORACLE_HOME=/home/oracle/product/10.2/db_1
$export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
$dbca
u will get first window select oracle RAC and click on next to continue
u will get next window select on create database and click on next ot continue
u will get next window in that u will get by default rac1 and rac2 and click on select all to continue
u will get next window select general purpose and click on next to continue
u will get next window write dbname and click on next to continue
u will get next window click on next to continue
u will get next window give password and click on next to continue
u will get next window select automatic storage management and click on next to continue
u will get next window specify sys password specific to asm give password and click on next to continue
u will get next window select DATA and click on next to continue
u will get next window select on use common location +DATA and click on next to continue
u will get final window db creation completed successfully
u will get prod1 instance on rac1 and prod2 instance name on rac2
u will get dbname prod on both nodes
put the instance entries in /etc/oratab on both nodes
for ex:prod1:/home/oracle/product/10.2/db_1
to check status of resources
#/home/oracle/product/10.2/crs/bin/crs_stat -t
to stop all resources
#/home/oracle/product/10.2/crs/bin/crs_stop -all
to check daemons
#/home/oracle/product/10.2/crs/bin/crsctl check crs
to stop daemons
#/home/oracle/product/10.2/crs/bin/crsctl stop crs
to stop services
#service iscsi stop
#service rawdevices stop
to start services
#service iscsi start
#service rawdevices start
#chown root.oinstall /dev/raw/raw1
#chown oracle.oinstall /dev/raw/raw2
#chown oracle.oinstall /dev/raw/raw3
#chown oracle.oinstall /dev/raw/raw4
vi editor to change from existing to new
:%s/stop/start/g or
:1,$s /stop/start
To uninstall RAC
1)stop crs on both nodes
2)#/home/oracle/product/10.2/crs/install/rootdelete.sh local nosharedvar nosharedhome on bothnodes
3)rm -rf /etc/ora* on both nodes
4)rm -rf /var/tmp/.oracle on both nodes
5)rm -rf /crs /db_1 /asm
6)rm -rf /etc/inittab.no*
7)rm -rf /home/oracle/oraInventory
8)ps -ef|grep pmon
crs
init.d
oracle
$kill -9
9)dd if=/dev/o of=/dev/raw/raw1 bs=8192 count=5000
10)remove if available .crs .cssd .ocmd in /etc/rco.d
To check performance of i/o harddisk.
$dd if=/dev/zero of=/pyrosan/eastdata/santest bs=1024k count=10000 (it copied 10gb file)
Install oracle enterprise linux on both rac nodes
Edit hosts file on both nodes and put entries and remove hostname from first line
vi /etc/hosts
172.22.0.175 rac1
172.22.0.176 rac2
172.22.0.178 rac1-vip
172.22.0.179 rac2-vip
172.22.0.177 openfiler
10.0.0.101 rac1-priv
10.0.0.102 rac2-priv
:wq (save and exit)
Oracle group and user add on both nodes
#groupadd dba
#groupadd oinstall
#useradd -c "Oracle software owner" -G dba -g oinstall oracle
#passwd oracle
Both the group and userid same on both rac nodes
issue the below command to check
#cat /etc/group (for groupid)
#cat /etc/passwd (for userid)
if not change this with below commands
#groupadd -g 1001 oinstall
#groupadd -g 1002 dba
#useradd -u 1001 -g 1001 -G 1002 -d /home/oracle -m oracle
setup sysctl.conf file for configuring kernel parameters on both nodes
kernel.shmmax=2147483648
kernel.shmall = 2097152
kernel.shmmni = 4096
kernel.sem=250 32000 100 128
fs.file-max=65536
net.ipv4.ip_local_port_range=1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_sack =1
net.ipv4.tcp_window_scaling = 1
sysctl -p
Download and run compat packages according to system 32bit or 64bit on both nodes
compat-gcc-7.3-2.96.128.i386.rpm
compat-gcc-c++-7.3-2.96.128.i386.rpm
compat-libcwait-2.1-1.i386.rpm
compat-libstdc++-7.3-2.96.128.i386.rpm
compat-libstdc++-devel-7.3-2.96.128.i386.rpm
compat-oracle-rhel4-1.0-5.i386.rpm
issue below command to run compat packages on both nodes
#rpm -ivh compat* --force --aid
Run below package on both nodes to check post installation of oracle RAC using cluvfy later,this package u will get in oracle clusterware software
#rpm -ivh cvuqdisk-1.0.6-1.rpm --force --aid
Create user-equivalence on both nodes
#su - oracle
$ssh-keygen -t rsa
enter
enter
enter
$cd .ssh/
$cat id_rsa.pub >>authorized_keys
$scp authorized_keys to node 2 on same location example:/home/oracle/.ssh
like this create user-equivalence on 2nd node
Check the time on both nodes it should be same if not give below command to make time synchronise
#date 102812542009.35 (the time format is like this monthdatehourminyear.second)
After installing openfiler you get the url like this https://openfiler:446/ or https://172.22.0.177:446/
Copy and paste this url to open storage graphically
First step click on system and configure network access configuration
hostname ipaddress subnetmask share
rac1 172.22.0.175 255.255.0.0 share
rac2 172.22.0.176 255.255.0.0 share
and click on update
Second step click on services and modify
servicename status modification
iscsi disable enable
click on enable in modification column to make status enable
like this enable all services except UPS server
Third step click on block devices
click on edit disk
/dev/hdc
now you will get new screen create primary and logical space
mode
primary extended create
click on create
again you will get
mode
logical physical create
click on create
Fourth step click on volume groups
give volume group name
click on add volume group
click on create
Fifth step click on add volume
give volume name
give volume Description
give Required space(MB)
give File system iscsi
click on create
Sixth step click on ISCSI targets
click on Target IQN and click on add
click on LAN mapping and click on map
click on Network ACL and click allow on access column and finally click on update to complete configuration
Add parameter on both nodes in iscsi.conf file
#vi /etc/iscsi.conf
add this line
DiscoveryAddress=openfiler
After configuration openfiler and add line in iscsi.conf you will get sharing disk on both nodes issue below command as a root user to check
#fdisk -l
(the output shows sharing disk as contains not a valid partition)
Partitions creating on sharing disk
#service iscsi restart
#fdisk -l
#fdisk /dev/sdb
p (type p to print partition)
n (to create new partition)
p (to create primary partition)
1
enter
enter
+2048m (give size and enter this partition is for ocr information)
n
p
2
enter
enter
+2048m (give size and enter this partition is for voting disk information)
n
p
3
enter
enter
+14000M (give size and enter this partition is for data)
n
e (this is extended partition)
enter
enter
n
enter
+25000m (give full remaining space is for data)
:w (save and exit)
#partprobe /dev/sdb (is for update kernel)
#fdisk -l (here you will get mount points)
#mkfs.ext3 /dev/sdb1 (make ocr and voting disk in ext3 format)
#mkfs.ext3 /dev/sdb2
Give this entry and reboot system once to create logical disk on follwing location on both nodes)
#vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdb2
/dev/raw/raw3 /dev/sdb3
/dev/raw/raw4 /dev/sdb4
:wq
#services iscsi restart
#services rawdevices restart
#chown root.oinstall /dev/raw/raw1 (give permissions to all logical devices for raw1 give root.oinstall because here information of ocr)
#chown oracle.oinstall /dev/raw/raw2
#chown oracle.oinstall /dev/raw/raw3
#chown oracle.oinstall /dev/raw/raw4
login as oracle user and check pre and post installation using cluvfy
$/home/oracle/clusterware/cluvfy/runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose (for pre installation)
$/home/oracle/clusterware/cluvfy/runcluvfy.sh stage -post hwos -n rac1,rac2 -verbose (for post installation)
output shows preinstallation checking successfully completed so we can continue installing clusterware software,if it show unsuccessfully check the errors.
If u get error like user equivalence failed again create keygen and copy on both nodes.If u get error like couldn't find a suitable interfaces for vips.We
can ignore this error and create vip manually using vipca.This error gets due to:-
CVU checks for the following criteria before considering set of interface:
-the interfaces should have the same name across nodes.
-they should belong to the same subnet and same netmask
-they should be on public (and routable) network
Oftentimes,the interfaces planned for the vip's are configured on 10.*.m172.16.*,172.31.*or192.168.* networks which are not routable.Hence CVU does not
consider them as suitable for vip's.If name of the available interfaces satistfy this criteria,cvu complain "error-couldn't find a suitable set of interfaces
for vip's.It is worth nothing that,such addresses will actually work if things are public but cvu just things they're private and reports accordingly.To
invoke vipca go to $ORA_CRS_HOME/bin and run the following command as root user after *.sh scripts are run on both nodes at cluster software installation.
#./vipca
1)click on next button
2)select eth0 and click on next button.
3)Type in the IP alias name for the vip and IP address and click on next
4)lastly click on finish
This will configure startup the vip.Now you can go back to the first screen (means last screen of clusterware software) and click ok.
http://www.idevelopment.into/data/Oracle/DBA_tips/Oracle10gRAC/CLUSTER_18.shtml
Installation clusterware software:
$cd /home/oracle/cluster/
$./runInstaller
u will get window like specify cluster configuration
click on add
public node name (give in bracket(rac2))
private node name (give in bracket(rac2-priv))
virtual host name (give in bracket(rac2-vip))
and click on ok to continue
u will get next window like specify oracle cluster registry(ocr) location
select on external redundancy and on next line give location
specify ocr location /dev/raw/raw1 and click on next to continue
u will get next window specify voting disk location
select on external redundancy and on next line give location
voting disk location /dev/raw/raw2 and click on next to continue
u will get next window click on install to start installation
At the end u will get window to run root.sh and Orainstroot.sh on both nodes with root user
After running this scripts if u r getting error in pre requistion like couldn't find a suitable interfaces for vip's so configure vip using vipca it resides
in clusterware software bin folder and configure vip's as explain above in this note.
Finally u will get window installation completed successfully
OCR :- keeps information of number of rac nodes
Voting Disk :- Cluster processes vote we are alive.It ups another nodes background process if existing nodes fails.
Installation of ASM:
Using normal 10g software install asm
$/home/oracle/oracle10gsoftware/runInstaller
u will get first window select enterprise edition and click on next
u will get second window specify the location of asm to install ex:/home/oracle/product/10.2/asm
u will get next window specify hardware cluster installation mode
select cluster installation,click on rac2 and finally click on next to continue
u will get next window select configure automatic storage management(ASM)
give password specify asm sys password (sys)
give conform password (sys) and finally click on next to continue
u will get next window select on external
on same window select candidates and also select 1st and 2nd point and click on next to continue
u will get next window to run root.sh on both nodes as root user
finally u will get installation completed successfully click on exit to complete installation
Creating ASM database
$export PATH
$export CLASS_PATH
$export LD_LIBRARY
$dbca if not works go to $ORACLE_ASM/bin and run
u will get 1st window select cluset Real Application and click on next
u will get next window select configure automatic storage management
the output shows rac1 and rac2 on same window and click on select all to continue
u will get next window give password:sys and click on next to continue
u will get next window in that u will get by default Disk group name DATA
in the same window select external
in the same window select show candidates it will give output of third and fourth logical derives like /dev/raw/raw3 /dev/raw/raw4
By default i think selected if not select on both and click on ok to continue
u will get next window click on finish to complete asm instance creation.
Installation of Normal Oracle 10g software
$/home/oracle/oracle10gsoftware/runInstaller
u will get window Specify Hardware Cluster Installation Mode select on cluster installation
in the same window u will get rac1 and rac2 by default it is selected if not select both rac1 and rac2 and click on select all to continue
u will get next window click on next to continue
u will get next window click on next to continue
u will get next window select configuration option select install database software only and click on next to continue
u will get next window click on install to complete installations
Creation of database
$export ORACLE_HOME=/home/oracle/product/10.2/db_1
$export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
$dbca
u will get first window select oracle RAC and click on next to continue
u will get next window select on create database and click on next ot continue
u will get next window in that u will get by default rac1 and rac2 and click on select all to continue
u will get next window select general purpose and click on next to continue
u will get next window write dbname and click on next to continue
u will get next window click on next to continue
u will get next window give password and click on next to continue
u will get next window select automatic storage management and click on next to continue
u will get next window specify sys password specific to asm give password and click on next to continue
u will get next window select DATA and click on next to continue
u will get next window select on use common location +DATA and click on next to continue
u will get final window db creation completed successfully
u will get prod1 instance on rac1 and prod2 instance name on rac2
u will get dbname prod on both nodes
put the instance entries in /etc/oratab on both nodes
for ex:prod1:/home/oracle/product/10.2/db_1
to check status of resources
#/home/oracle/product/10.2/crs/bin/crs_stat -t
to stop all resources
#/home/oracle/product/10.2/crs/bin/crs_stop -all
to check daemons
#/home/oracle/product/10.2/crs/bin/crsctl check crs
to stop daemons
#/home/oracle/product/10.2/crs/bin/crsctl stop crs
to stop services
#service iscsi stop
#service rawdevices stop
to start services
#service iscsi start
#service rawdevices start
#chown root.oinstall /dev/raw/raw1
#chown oracle.oinstall /dev/raw/raw2
#chown oracle.oinstall /dev/raw/raw3
#chown oracle.oinstall /dev/raw/raw4
vi editor to change from existing to new
:%s/stop/start/g or
:1,$s /stop/start
To uninstall RAC
1)stop crs on both nodes
2)#/home/oracle/product/10.2/crs/install/rootdelete.sh local nosharedvar nosharedhome on bothnodes
3)rm -rf /etc/ora* on both nodes
4)rm -rf /var/tmp/.oracle on both nodes
5)rm -rf /crs /db_1 /asm
6)rm -rf /etc/inittab.no*
7)rm -rf /home/oracle/oraInventory
8)ps -ef|grep pmon
crs
init.d
oracle
$kill -9
9)dd if=/dev/o of=/dev/raw/raw1 bs=8192 count=5000
10)remove if available .crs .cssd .ocmd in /etc/rco.d
To check performance of i/o harddisk.
$dd if=/dev/zero of=/pyrosan/eastdata/santest bs=1024k count=10000 (it copied 10gb file)
Thursday, December 30, 2010
Analyze Statement and Transferring Statistics.
Analyze Statement
The ANALYZE statement can be used to gather statistics for a specific table, index or cluster. The statistics can be computed exactly, or estimated based on a specific number of rows, or a percentage of rows:
ANALYZE TABLE employees COMPUTE STATISTICS;
ANALYZE INDEX employees_pk COMPUTE STATISTICS;
ANALYZE TABLE employees ESTIMATE STATISTICS SAMPLE 100 ROWS;
ANALYZE TABLE employees ESTIMATE STATISTICS SAMPLE 15 PERCENT;
DBMS_STATS
The DBMS_STATS package was introduced in Oracle 8i and is Oracles preferred method of gathering object statistics. Oracle list a number of benefits to using it including parallel execution, long term storage of statistics and transfer of statistics between servers. Once again, it follows a similar format to the other methods:
EXEC DBMS_STATS.gather_database_stats;
EXEC DBMS_STATS.gather_database_stats(estimate_percent => 15);
EXEC DBMS_STATS.gather_schema_stats('SCOTT');
EXEC DBMS_STATS.gather_schema_stats('SCOTT', estimate_percent => 15);
EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES');
EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES', estimate_percent => 15);
EXEC DBMS_STATS.gather_index_stats('SCOTT', 'EMPLOYEES_PK');
EXEC DBMS_STATS.gather_index_stats('SCOTT', 'EMPLOYEES_PK', estimate_percent => 15);
This package also gives you the ability to delete statistics:
EXEC DBMS_STATS.delete_database_stats;
EXEC DBMS_STATS.delete_schema_stats('SCOTT');
EXEC DBMS_STATS.delete_table_stats('SCOTT', 'EMPLOYEES');
EXEC DBMS_STATS.delete_index_stats('SCOTT', 'EMPLOYEES_PK');
Transfering Stats
=================
First the statistics must be collected into a statistics table. In the following examples the statistics for the APPS user are collected into a new table, STATS_TABLE, which is owned by scott:
SQL> EXEC DBMS_STATS.create_stat_table('SCOTT','STATS_TABLE');
SQL> EXEC DBMS_STATS.export_schema_stats('APPS','STATS_TABLE',NULL,'SCOTT');
This table can then be transfered to another server using your preferred method (Export/Import ) and the stats imported into the data dictionary as follows:
SQL> EXEC DBMS_STATS.import_schema_stats('APPS','STATS_TABLE',NULL,'SCOTT');
SQL> EXEC DBMS_STATS.drop_stat_table('APPS','STATS_TABLE');
The ANALYZE statement can be used to gather statistics for a specific table, index or cluster. The statistics can be computed exactly, or estimated based on a specific number of rows, or a percentage of rows:
ANALYZE TABLE employees COMPUTE STATISTICS;
ANALYZE INDEX employees_pk COMPUTE STATISTICS;
ANALYZE TABLE employees ESTIMATE STATISTICS SAMPLE 100 ROWS;
ANALYZE TABLE employees ESTIMATE STATISTICS SAMPLE 15 PERCENT;
DBMS_STATS
The DBMS_STATS package was introduced in Oracle 8i and is Oracles preferred method of gathering object statistics. Oracle list a number of benefits to using it including parallel execution, long term storage of statistics and transfer of statistics between servers. Once again, it follows a similar format to the other methods:
EXEC DBMS_STATS.gather_database_stats;
EXEC DBMS_STATS.gather_database_stats(estimate_percent => 15);
EXEC DBMS_STATS.gather_schema_stats('SCOTT');
EXEC DBMS_STATS.gather_schema_stats('SCOTT', estimate_percent => 15);
EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES');
EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES', estimate_percent => 15);
EXEC DBMS_STATS.gather_index_stats('SCOTT', 'EMPLOYEES_PK');
EXEC DBMS_STATS.gather_index_stats('SCOTT', 'EMPLOYEES_PK', estimate_percent => 15);
This package also gives you the ability to delete statistics:
EXEC DBMS_STATS.delete_database_stats;
EXEC DBMS_STATS.delete_schema_stats('SCOTT');
EXEC DBMS_STATS.delete_table_stats('SCOTT', 'EMPLOYEES');
EXEC DBMS_STATS.delete_index_stats('SCOTT', 'EMPLOYEES_PK');
Transfering Stats
=================
First the statistics must be collected into a statistics table. In the following examples the statistics for the APPS user are collected into a new table, STATS_TABLE, which is owned by scott:
SQL> EXEC DBMS_STATS.create_stat_table('SCOTT','STATS_TABLE');
SQL> EXEC DBMS_STATS.export_schema_stats('APPS','STATS_TABLE',NULL,'SCOTT');
This table can then be transfered to another server using your preferred method (Export/Import ) and the stats imported into the data dictionary as follows:
SQL> EXEC DBMS_STATS.import_schema_stats('APPS','STATS_TABLE',NULL,'SCOTT');
SQL> EXEC DBMS_STATS.drop_stat_table('APPS','STATS_TABLE');
TSM for ORACLE Installation
TSM for ORACLE Installation :-
On TSM server :-
1. Create Policy domain and backup copy group ( vere=1, verd=0, retain extra=0, retain only=0)
2. Register TDP for Oracle node
On TSM client :-
1. Install TDP for oracle fileset
2. Configure dsm.opt file in /usr/tivoli/tsm/client/api/bin64/dsm.opt
example :-
SErvername tsmserv (provide tsm server name)
3. Configure dsm.sys file in /usr/tivoli/tsm/client/api/bin64/dsm.sys
example :-
SErvername tsmserv (provide tsm server name)
COMMmethod TCPip
TCPPort 1500
TCPServeraddress 192.168.13.104 (provide tsm server IP)
compression no
errorlogname /tmp/dsmerror_erpdev_ora.log (provide error log path)
nodename erpdev_ora (provide node name)
4. Configure tdpo.opt file in /usr/tivoli/tsm/client/oracle/bin64/tdpo.opt
example :-
DSMI_ORC_CONFIG /usr/tivoli/tsm/client/api/bin64/dsm.opt (provide option file path)
DSMI_LOG /tmp/ (provide error log directory)
TDPO_FS orc9_db
TDPO_NODE erpdev_ora (provide node name)
*TDPO_OWNER
*TDPO_PSWDPATH /usr/tivoli/tsm/client/oracle/bin64
*TDPO_DATE_FMT 1
*TDPO_NUM_FMT 1
*TDPO_TIME_FMT 1
*TDPO_MGMT_CLASS_2 mgmtclass2
*TDPO_MGMT_CLASS_3 mgmtclass3
*TDPO_MGMT_CLASS_4 mgmtclass4
5. Go to /usr/tivoli/tsm/client/oracle/bin64 and run
./tdpoconf password
6. Put the node password and confirm with same password and you can oracle environment by giving ./tdpoconf showenv in the same path
7. Then give permission to
dsmerror_erpprod_ora.log in /tmp (path of error log file)
8. Link the "TSM for DB" library file within oracle
-Shutdown oracle instance
-Change directory to oracle's lib directory
# cd /
# cd lib
-Check presence of original libobk.a file
# ls -l libobk.a
-If found rename it
# ln libobk.a libobk.a.org
-Link to TSM library
# ln –s /usr/lib/libobk64.a libobk.a
-Start oracle instance
9. Oracle administrator role is to create RMAN script for backup and set environment variable path for tdpo.opt file as " /usr/tivoli/tsm/client/oracle/bin64/tdpo.opt"
On TSM server :-
1. Create Policy domain and backup copy group ( vere=1, verd=0, retain extra=0, retain only=0)
2. Register TDP for Oracle node
On TSM client :-
1. Install TDP for oracle fileset
2. Configure dsm.opt file in /usr/tivoli/tsm/client/api/bin64/dsm.opt
example :-
SErvername tsmserv (provide tsm server name)
3. Configure dsm.sys file in /usr/tivoli/tsm/client/api/bin64/dsm.sys
example :-
SErvername tsmserv (provide tsm server name)
COMMmethod TCPip
TCPPort 1500
TCPServeraddress 192.168.13.104 (provide tsm server IP)
compression no
errorlogname /tmp/dsmerror_erpdev_ora.log (provide error log path)
nodename erpdev_ora (provide node name)
4. Configure tdpo.opt file in /usr/tivoli/tsm/client/oracle/bin64/tdpo.opt
example :-
DSMI_ORC_CONFIG /usr/tivoli/tsm/client/api/bin64/dsm.opt (provide option file path)
DSMI_LOG /tmp/ (provide error log directory)
TDPO_FS orc9_db
TDPO_NODE erpdev_ora (provide node name)
*TDPO_OWNER
*TDPO_PSWDPATH /usr/tivoli/tsm/client/oracle/bin64
*TDPO_DATE_FMT 1
*TDPO_NUM_FMT 1
*TDPO_TIME_FMT 1
*TDPO_MGMT_CLASS_2 mgmtclass2
*TDPO_MGMT_CLASS_3 mgmtclass3
*TDPO_MGMT_CLASS_4 mgmtclass4
5. Go to /usr/tivoli/tsm/client/oracle/bin64 and run
./tdpoconf password
6. Put the node password and confirm with same password and you can oracle environment by giving ./tdpoconf showenv in the same path
7. Then give permission to
dsmerror_erpprod_ora.log in /tmp (path of error log file)
8. Link the "TSM for DB" library file within oracle
-Shutdown oracle instance
-Change directory to oracle's lib directory
# cd /
# cd lib
-Check presence of original libobk.a file
# ls -l libobk.a
-If found rename it
# ln libobk.a libobk.a.org
-Link to TSM library
# ln –s /usr/lib/libobk64.a libobk.a
-Start oracle instance
9. Oracle administrator role is to create RMAN script for backup and set environment variable path for tdpo.opt file as " /usr/tivoli/tsm/client/oracle/bin64/tdpo.opt"
ora-01555 snapshot too old error.
Now that we understand why the ORA-1555 occurs and some aspects about how they can occur we need to examine the following:
How can we logically determine and resolve what has occurred to cause the ORA-1555?
1) Determine if UNDO_MANAGEMENT is MANUAL or AUTO
If set to MANUAL, it is best to move to AUM. If it is not feasible to switch to AUM see
Note 69464.1 Rollback Segment Configuration & Tips
to attempt to tune around the ORA-1555 using V$ROLLSTAT
If set to AUTO, proceed to #2
2) Gather the basic data
a) Acquire both the error message from the user / client ... and the message in the alert log
User / Client session example:
ORA-01555: snapshot too old: rollback segment number 9 with name "_SYSSMU1$" too small
Alert log example
ORA-01555 caused by SQL statement below (Query Duration=9999 sec, SCN:0x000.008a7c2d)
b) Determine the QUERY DURATION from the message in the alert log
From our example above ... this would be 9999
c) Determine the undo segment name from the user / client message
From our example above ... this would be _SYSSMU1$
d) Determine the UNDO_RETENTION of the undo tablespace
show parameter undo_retention
3) Determine if the ORA-1555 is occurring with an UNDO or a LOB segment
If the undo segment name is null ...
ORA-01555: snapshot too old: rollback segment number with name "" too small
or the undo segment is unknown
ORA-01555: snapshot too old: rollback segment number # with name "???" too small
then this means this is a read consistent failure on a LOB segment
If the segment_name or the undo segment is known the error is occurring with an UNDO segment.
==============================================================================================
What to do if an ORA-1555 is occurring with an UNDO segment
-------------------------------------------------------------------------------------------------
1) QUERY DURATION > UNDO_RETENTION
There are no guarantees that read consistency can be maintained after the transaction slot for the
committed row has expired (exceeded UNDO_RETENTION)
Why would one think that the transaction slot's time has exceeded UNDO_RETENTION?
Lets answer this with an example
If UNDO_RETENTION = 900 seconds ... but our QUERY DURATION is 2000 seconds ...
This says that our query has most likely encountered a row that was committed more than 900
seconds ago ... and has been overwritten as we KNOW that the transaction slot being examined
no longer matches the row we are looking for
The reason we say "most likely" is that it is possible that an unexpired committed transaction slot was
overwritten due to either space pressure on the undo segment or this is a bug
SOLUTION:
The best solution is to tune the query can to reduce its duration. If that cannot be done then increase
UNDO_RETENTION based on QUERY DURATION to allow it to protect the committed
transaction slots for a longer period of time
NOTE: Increasing UNDO_RETENTION requires additional space in the UNDO tablespace. Make
sure to accommodate for this space. One method of doing this is to set AUTOEXTEND on one or
more of the UNDO tablespace datafiles for a period of time to allow for the increased space. Once the
size has stabilized, AUTOEXTEND can be removed.
See the solution for #2 below for more options
2) QUERY DURATION <= UNDO_RETENTION
This case is most often due to the UNDO tablespace becoming full sometime during the time when the
query was running
How do we tell if the UNDO tablespace has become full during the query?
Examine V$UNDOSTAT.UNXPSTEALCNT for the period while the query that generated the
ORA-1555 occurred.
This column shows committed transaction slots that have not exceeded UNDO_RETENTION but
were overwritten due to space pressure on the undo tablespace (IE became full).
If UNEXPSTEACNT > 0 for the time period during which the query was running then this shows
that the undo tablespace was too small to be able to maintain UNDO_RETENTION. Unexpired
blocks were over written, thus ending read consistency for those blocks for that time period.
set pagesize 25
set linesize 120
select inst_id,
to_char(begin_time,'MM/DD/YYYY HH24:MI') begin_time,
UNXPSTEALCNT "# Unexpired|Stolen",
EXPSTEALCNT "# Expired|Reused",
SSOLDERRCNT "ORA-1555|Error",
NOSPACEERRCNT "Out-Of-space|Error",
MAXQUERYLEN "Max Query|Length"
from gv$undostat
where begin_time between
to_date('','MM/DD/YYYY HH24:MI:SS')
and
to_date('
How can we logically determine and resolve what has occurred to cause the ORA-1555?
1) Determine if UNDO_MANAGEMENT is MANUAL or AUTO
If set to MANUAL, it is best to move to AUM. If it is not feasible to switch to AUM see
Note 69464.1 Rollback Segment Configuration & Tips
to attempt to tune around the ORA-1555 using V$ROLLSTAT
If set to AUTO, proceed to #2
2) Gather the basic data
a) Acquire both the error message from the user / client ... and the message in the alert log
User / Client session example:
ORA-01555: snapshot too old: rollback segment number 9 with name "_SYSSMU1$" too small
Alert log example
ORA-01555 caused by SQL statement below (Query Duration=9999 sec, SCN:0x000.008a7c2d)
b) Determine the QUERY DURATION from the message in the alert log
From our example above ... this would be 9999
c) Determine the undo segment name from the user / client message
From our example above ... this would be _SYSSMU1$
d) Determine the UNDO_RETENTION of the undo tablespace
show parameter undo_retention
3) Determine if the ORA-1555 is occurring with an UNDO or a LOB segment
If the undo segment name is null ...
ORA-01555: snapshot too old: rollback segment number with name "" too small
or the undo segment is unknown
ORA-01555: snapshot too old: rollback segment number # with name "???" too small
then this means this is a read consistent failure on a LOB segment
If the segment_name or the undo segment is known the error is occurring with an UNDO segment.
==============================================================================================
What to do if an ORA-1555 is occurring with an UNDO segment
-------------------------------------------------------------------------------------------------
1) QUERY DURATION > UNDO_RETENTION
There are no guarantees that read consistency can be maintained after the transaction slot for the
committed row has expired (exceeded UNDO_RETENTION)
Why would one think that the transaction slot's time has exceeded UNDO_RETENTION?
Lets answer this with an example
If UNDO_RETENTION = 900 seconds ... but our QUERY DURATION is 2000 seconds ...
This says that our query has most likely encountered a row that was committed more than 900
seconds ago ... and has been overwritten as we KNOW that the transaction slot being examined
no longer matches the row we are looking for
The reason we say "most likely" is that it is possible that an unexpired committed transaction slot was
overwritten due to either space pressure on the undo segment or this is a bug
SOLUTION:
The best solution is to tune the query can to reduce its duration. If that cannot be done then increase
UNDO_RETENTION based on QUERY DURATION to allow it to protect the committed
transaction slots for a longer period of time
NOTE: Increasing UNDO_RETENTION requires additional space in the UNDO tablespace. Make
sure to accommodate for this space. One method of doing this is to set AUTOEXTEND on one or
more of the UNDO tablespace datafiles for a period of time to allow for the increased space. Once the
size has stabilized, AUTOEXTEND can be removed.
See the solution for #2 below for more options
2) QUERY DURATION <= UNDO_RETENTION
This case is most often due to the UNDO tablespace becoming full sometime during the time when the
query was running
How do we tell if the UNDO tablespace has become full during the query?
Examine V$UNDOSTAT.UNXPSTEALCNT for the period while the query that generated the
ORA-1555 occurred.
This column shows committed transaction slots that have not exceeded UNDO_RETENTION but
were overwritten due to space pressure on the undo tablespace (IE became full).
If UNEXPSTEACNT > 0 for the time period during which the query was running then this shows
that the undo tablespace was too small to be able to maintain UNDO_RETENTION. Unexpired
blocks were over written, thus ending read consistency for those blocks for that time period.
set pagesize 25
set linesize 120
select inst_id,
to_char(begin_time,'MM/DD/YYYY HH24:MI') begin_time,
UNXPSTEALCNT "# Unexpired|Stolen",
EXPSTEALCNT "# Expired|Reused",
SSOLDERRCNT "ORA-1555|Error",
NOSPACEERRCNT "Out-Of-space|Error",
MAXQUERYLEN "Max Query|Length"
from gv$undostat
where begin_time between
to_date('
and
to_date('
Tuesday, September 14, 2010
Points_2_Resolve the ORA-12705 error
Below are the points to fix the issue on your oracle client machine.
Cause: There are two possible causes: Either an attempt was made to issue an ALTER SESSION statement with an invalid NLS parameter or value; or the NLS_LANG environment variable contains an invalid language, territory, or character set.
Action: Check the syntax of the ALTER SESSION command and the NLS parameter, correct the syntax and retry the statement, or specify correct values in the NLS_LANG environment variable.
Points to fix the issue:
1.simply set it with the below command
C:>set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252. (if not fix,try with below procedure)
2.From start-->Run--->Type regedit--->HKEY_LOCAL_MACHINE-->SOFTWARE-->ORACLE-->HOME folder has a key
NLS_LANG as AMERICAN_AMERICA.WE8MSWIN1252.
change to AMERICAN_AMERICA.WE8ISO8859P15 may fix your connectivity issue. (Permanent fix, even if not fix try with below procedure)
3.Try this...
check if exist into windows registry (regedit) the oracle_home
Example
[HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE]
ORACLE_HOME= (for ex: D:\Appls\Oracle)
if not create one.
and add the path into the windows variable PATH adding bin folder
example D:\Appls\Oracle\bin
Control Panel -> System -> Advanced Options -> Environment variables - > system variables -> path
4. Still not resolve
Just go regedit -->Oracle Home--and delete the NLS entries from there..You should be fine.
5. Final point if not solve with above points, uninstall and install Oracle client software.
Cause: There are two possible causes: Either an attempt was made to issue an ALTER SESSION statement with an invalid NLS parameter or value; or the NLS_LANG environment variable contains an invalid language, territory, or character set.
Action: Check the syntax of the ALTER SESSION command and the NLS parameter, correct the syntax and retry the statement, or specify correct values in the NLS_LANG environment variable.
Points to fix the issue:
1.simply set it with the below command
C:>set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252. (if not fix,try with below procedure)
2.From start-->Run--->Type regedit--->HKEY_LOCAL_MACHINE-->SOFTWARE-->ORACLE-->HOME folder has a key
NLS_LANG as AMERICAN_AMERICA.WE8MSWIN1252.
change to AMERICAN_AMERICA.WE8ISO8859P15 may fix your connectivity issue. (Permanent fix, even if not fix try with below procedure)
3.Try this...
check if exist into windows registry (regedit) the oracle_home
Example
[HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE]
ORACLE_HOME=
if not create one.
and add the path into the windows variable PATH adding bin folder
example D:\Appls\Oracle\bin
Control Panel -> System -> Advanced Options -> Environment variables - > system variables -> path
4. Still not resolve
Just go regedit -->Oracle Home--and delete the NLS entries from there..You should be fine.
5. Final point if not solve with above points, uninstall and install Oracle client software.
Sunday, August 29, 2010
WHEN TO REORGANIZE TABLES AND REBUILD INDEXES.
When to reorganize tables and rebuild indexes:
Table fragmentation:When rows are not stored contiguously or if rows are split auto more than one block,performance decrease because these rows required additional block accesses.
Note that table fragmentation is different from file fragmentation.When a lot of DML operations are applied on a table,the table will become fragmentation because DML does not release free space from the table below the HWM.
HWM is an indicator of used blocks in the database.Blocks below the high water mark (used blocks) have at least once contained data.This data might have been deleted.Since oracle knows that blocks before the high water mark didn't have data,it only reads block up to the high water when doing a full table scan.
*DDL statements always resets the HWM.
Table size (with fragmentation)
Sql>exec dbms_stat.gather_table_stats('SCOTT','BIG1');
Sql>select table_name,round((blocks*8),2)||'kb' "size" from user_tables where table_name='BIG1'
output of the command:
table_name size
BIG1 72952 kb
Actual data in table
Sql>select table_name,round((num_rows*avg_row_len/1024),||'kb' "size" from user_tables where table_name='BIG1';
output
table_name size
BIG1 30604.2 kb
72952-30604=42348 kb is wasted space in table
The difference between two values is 60% and pct free 10%(default)-so,the table has 50% extra space which is wasted becuase there is no data.
How to reset HWM/remove fragmentation ?
4 options:
1)alter table .. move to another tablespace.
2)export,truncate or drop import.
3)CTAS method
4)dbms_redifinition
To check indexes
sql>select status,index_name from user_indexes where table_name='BIG1';
output
status index_name
unusable bigidx
sql>alter index bigidx rebuild;
select del_lf_rows*100/decode(lf_rows,0,1,lf_rows) from index_stats where name='';
you may decide that index should be rebuilt if more than 20% of its rows are deleted.
How can you determine if an index needs to be dropped and rebuilt?
Level: Intermediate
Expected answer: Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3
To check the compress or not compress mode:
Sql>select compression from dba_tables where table_name in <'tablename'>;
If some times show actual size is greater than the table size it is due to in compress mode of table
If table is compress make this to no compress mode
Sql>alter table move nocompress;
Table fragmentation:When rows are not stored contiguously or if rows are split auto more than one block,performance decrease because these rows required additional block accesses.
Note that table fragmentation is different from file fragmentation.When a lot of DML operations are applied on a table,the table will become fragmentation because DML does not release free space from the table below the HWM.
HWM is an indicator of used blocks in the database.Blocks below the high water mark (used blocks) have at least once contained data.This data might have been deleted.Since oracle knows that blocks before the high water mark didn't have data,it only reads block up to the high water when doing a full table scan.
*DDL statements always resets the HWM.
Table size (with fragmentation)
Sql>exec dbms_stat.gather_table_stats('SCOTT','BIG1');
Sql>select table_name,round((blocks*8),2)||'kb' "size" from user_tables where table_name='BIG1'
output of the command:
table_name size
BIG1 72952 kb
Actual data in table
Sql>select table_name,round((num_rows*avg_row_len/1024),||'kb' "size" from user_tables where table_name='BIG1';
output
table_name size
BIG1 30604.2 kb
72952-30604=42348 kb is wasted space in table
The difference between two values is 60% and pct free 10%(default)-so,the table has 50% extra space which is wasted becuase there is no data.
How to reset HWM/remove fragmentation ?
4 options:
1)alter table .. move to another tablespace.
2)export,truncate or drop import.
3)CTAS method
4)dbms_redifinition
To check indexes
sql>select status,index_name from user_indexes where table_name='BIG1';
output
status index_name
unusable bigidx
sql>alter index bigidx rebuild;
select del_lf_rows*100/decode(lf_rows,0,1,lf_rows) from index_stats where name='
you may decide that index should be rebuilt if more than 20% of its rows are deleted.
How can you determine if an index needs to be dropped and rebuilt?
Level: Intermediate
Expected answer: Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3
To check the compress or not compress mode:
Sql>select compression from dba_tables where table_name in <'tablename'>;
If some times show actual size is greater than the table size it is due to in compress mode of table
If table is compress make this to no compress mode
Sql>alter table move nocompress;
MYSQL_DBA_BEGINNER.
MYSQL DOCUMENTATION
To install Mysql
#rpm -ivh mysql-server-community_x86-64.rpm
After installing immediately give password
#/usr/bin/mysqladmin -u root -p password "root123"
To start and stop mysql server
#/etc/init.d/mysql start
#/etc/init.d/mysql stop
To connect mysql
#mysql -u root -p
To check databases and use database
Mysql>show databases;
Mysql>use;
To check tables and its contents and its use
Mysql>show tables;
Mysql>desc;
Mysql>select * from;
To create user
Mysql>create user 'khan'@'localhost' identified by 'khan';
To give Privileges
Mysql>grant select,insert,update,delete on *.* to 'khan';
To drop user
Mysql>drop user 'khan'@'localhost';
To check which database to connected
Mysql>select database ();
To check which user is connected
Mysql>select user ();
To check how many users have
Mysql>select distinct grantee from user_privileges;
Global privileges are administrative or apply to all databases on a given server. To assign global privileges, use ON *.* syntax:
GRANT ALL ON *.* TO 'someuser'@'somehost';
GRANT SELECT, INSERT ON *.* TO 'someuser'@'somehost';
Only two rows information need give limit 2 in your query
In mysql by default database create in /var/lib/mysql
To create table
Mysql>create table oolaala(name varchar(20));
To check mysql version
#rpm -qa|grep -i mysql
Try this after relocating files if errors getting
#setsebool -p mysqld_disable_trans=1
Note:If not available my.cnf file or removed or '/home/oracle/data/three/redo01a.log' size 20m,lost we can copy the same file available in /usr/share/mysql (my_large.cnf)
MYISAM INNODB (engines of mysql)
By default tables create in MYISAM
To create tables in INNODB
set in my.cnf (uncomment#innodb parameter)
Mysql>create table pepsi(name varchar(10)) engine=innodb;
MYISAM is for OLAP and INNODB is for OLTP
To check connection errors or any errors
#/var/log/messages or /var/log/sys/logs of /var/lib/mysql/mysqld.log
How to rename and relocate on datafiles
1.Stop service
2.copy data directory on another mount point
3.vi /etc/my.cnf
#The MySQL server
[mysqld]
datadir=/home/mysql/data (five here different mount point)
user=mysql
To migrate from Oracle to Mysql
1.PhpAdmin tool use or
2.$mysql -u -p < abc.sql
3.mysql>source abc.sql
It helps to migrate from oracle to mysql
To create tables in oracle
set echo off
set heading off
spool t1_insert.txt
create table t1 (c1 number, c2 varchar2(10), c3 date);
insert into t1 values (1,'one', sysdate);
insert into t1 values (2,'two', sysdate);
commit;
select 'insert into t1 (c1, c2, c3) values (' || c1 || ', ' || c2 || ', ' || c3 || ');' from t1;
select 'insert into t1 (c1, c2, c3) values (' || c1 || ', ''' || c2 || ''', ''' || to_char(c3,'yyyy-mm-dd hh24:mi:ss') || ''');' from t1;
spool off
To create tables in Mysql
create table t1 (c1 int, c2 varchar(10), c3 datetime);
select '' || c1 || ', ''' || c2 || ''', ''' || to_char(c3,'yyyy-mm-dd hh24:mi:ss') || '''' from t1;
make t1_insert.txt to t1_insert.sql
to migrate
mysql>source t1_insert.sql
To take logical backup dump of mysql
#mysqldump -uroot -padmin --all-database >testmysql.sql
it generates file that we can read for import on mysql or oracle. For oracle change the data format and import by running sql file.
site to download mysql software
http://dev.mysql.com/
To install Mysql
#rpm -ivh mysql-server-community_x86-64.rpm
After installing immediately give password
#/usr/bin/mysqladmin -u root -p password "root123"
To start and stop mysql server
#/etc/init.d/mysql start
#/etc/init.d/mysql stop
To connect mysql
#mysql -u root -p
To check databases and use database
Mysql>show databases;
Mysql>use
To check tables and its contents and its use
Mysql>show tables;
Mysql>desc
Mysql>select * from
To create user
Mysql>create user 'khan'@'localhost' identified by 'khan';
To give Privileges
Mysql>grant select,insert,update,delete on *.* to 'khan';
To drop user
Mysql>drop user 'khan'@'localhost';
To check which database to connected
Mysql>select database ();
To check which user is connected
Mysql>select user ();
To check how many users have
Mysql>select distinct grantee from user_privileges;
Global privileges are administrative or apply to all databases on a given server. To assign global privileges, use ON *.* syntax:
GRANT ALL ON *.* TO 'someuser'@'somehost';
GRANT SELECT, INSERT ON *.* TO 'someuser'@'somehost';
Only two rows information need give limit 2 in your query
In mysql by default database create in /var/lib/mysql
To create table
Mysql>create table oolaala(name varchar(20));
To check mysql version
#rpm -qa|grep -i mysql
Try this after relocating files if errors getting
#setsebool -p mysqld_disable_trans=1
Note:If not available my.cnf file or removed or '/home/oracle/data/three/redo01a.log' size 20m,lost we can copy the same file available in /usr/share/mysql (my_large.cnf)
MYISAM INNODB (engines of mysql)
By default tables create in MYISAM
To create tables in INNODB
set in my.cnf (uncomment#innodb parameter)
Mysql>create table pepsi(name varchar(10)) engine=innodb;
MYISAM is for OLAP and INNODB is for OLTP
To check connection errors or any errors
#/var/log/messages or /var/log/sys/logs of /var/lib/mysql/mysqld.log
How to rename and relocate on datafiles
1.Stop service
2.copy data directory on another mount point
3.vi /etc/my.cnf
#The MySQL server
[mysqld]
datadir=/home/mysql/data (five here different mount point)
user=mysql
To migrate from Oracle to Mysql
1.PhpAdmin tool use or
2.$mysql -u
It helps to migrate from oracle to mysql
To create tables in oracle
set echo off
set heading off
spool t1_insert.txt
create table t1 (c1 number, c2 varchar2(10), c3 date);
insert into t1 values (1,'one', sysdate);
insert into t1 values (2,'two', sysdate);
commit;
select 'insert into t1 (c1, c2, c3) values (' || c1 || ', ' || c2 || ', ' || c3 || ');' from t1;
select 'insert into t1 (c1, c2, c3) values (' || c1 || ', ''' || c2 || ''', ''' || to_char(c3,'yyyy-mm-dd hh24:mi:ss') || ''');' from t1;
spool off
To create tables in Mysql
create table t1 (c1 int, c2 varchar(10), c3 datetime);
select '' || c1 || ', ''' || c2 || ''', ''' || to_char(c3,'yyyy-mm-dd hh24:mi:ss') || '''' from t1;
make t1_insert.txt to t1_insert.sql
to migrate
mysql>source t1_insert.sql
To take logical backup dump of mysql
#mysqldump -uroot -padmin --all-database >testmysql.sql
it generates file that we can read for import on mysql or oracle. For oracle change the data format and import by running sql file.
site to download mysql software
http://dev.mysql.com/
Sunday, June 6, 2010
ORACLE_11G_NEW_FEATURES
ORACLE 11G NEW FEATURES:
Installation, Database Upgrades and Change Management
Installation New Features Support
Role and Privilege Changes
Deprecated Components
New Initialization Parameters Affecting Database Creation
DBCA Enhancements
Upgrading to Oracle Database 11g
Database Replay
The SQL Performance Analyzer
Patching in Oracle Database Control
Database Diagnosis and Repair
Introducing Automatic Diagnostic Repository (ADR)
Configuring the ADR
Using adrci Tool
Using The Support Workbench in the OEM
Database Health Monitor
Data Recovery Advisor
SQL Test Case Builder
Data Block Corruption Parameters
Database Administration
Automatic Memory Management
Automatic Maintenance Tasks
Oracle Flashback-Related New Features
LogMiner Interface in Oracle Enterprise Manager
Oracle Flashback Transaction Backout
Flashback Data Archive
Virtual Columns
New Data Partitioning Schemes
DDL Lock Timeout
Explicit Locking of Tables
Invisible Indexes
Read-Only Tables
Shrinking Temporary Tablespaces and Tempfiles
Creating an Initialization Parameter File from Memory
Restore Point Enhancements
Database Resident Connection Pooling
Comparing and Synchronizing Database Objects
SQL*Plus New Features
Oracle 11g New Features for Administrators:-
Online Application Maintenance
Oracle Advanced Compression Option
Oracle Scheduler New Features
Lightweight Jobs
Remote External Jobs
Finer-grained Dependency Management
Enhancements in Oracle Database Resource Manager
Performance Tuning
PL/SQL Native Compilation
Server Result Cache
Client Side Result Cache
Enhanced Oracle Process Monitoring
Subprogram Inlining
SQL Tuning Automation
SQL Access Advisor Enhancements
Changing Statistics Preferences
Enhanced Statistics Maintenance
SQL Plan Management
ADDM New Features
AWR New Features
Setting Metric Thresholds for Baselines
Performance-Related Changes in Database Control
Miscellaneous New Performance Tuning Features
Real-Time SQL Monitoring
Adaptive Cursor Sharing
Database Security
Stronger Password Hash Algorithm
Security Out of the Box
Anti Network Attacks Parameters
Tablespace Encryption
Fine-Grained Access Control for UTL_* Packages
Further Security New Features
Backup and Recovery New Features
Enhanced Block Media Recovery
RMAN Substitution Variables
New RMAN Configuration Parameters
The Multisection Backups
Creating Archival Backups
VALIDATE Command
Configuring an Archived Redo Log Deletion Policy
Oracle 11g New Features for Administrators:-
Active Database Duplication
Importing and Moving Recovery Catalogs
Virtual Private Catalogs
Miscellaneous New Features in RMAN
Data Pump Utilities
Compression Enhancement
Encryption Enhancements
Reusing a Dump File
Remapping Data
Renaming Tables During Export or Import
Data Pump and Partitioned Tables
Ignoring Nondeferred Constraints
External Tables Based on Data Pump Driver
Enhancement in the Transportable Parameter
Automatic Storage Management (ASM)
SYSASM Privilege and OSASM Group
Upgrading ASM using DBUA
Upgrading ASM Manually
ASM Restricted Mode
Diskgroup Attributes
Checking Diskgroup
asmcmd Utility Commands
Fast Rebalance
The FORCE option with Drop Diskgroup Command
Miscellaneous ASM New Features
PL/SQL New Features
PL/SQL New Features
Data Warehousing
SecureFiles
Accessing a LOB Using SQL and PL/SQL
Online Redefinition
Partition Change Tracking (PCT)
Generating SQL Crosstab Report using PIVOT Operator
Partitioning Improvements
Below Topics Not covered:-
Oracle Streams
Data Guard
Oracle RAC
Oracle XML DB
Installation, Database Upgrades and Change Management
Installation New Features Support
Role and Privilege Changes
Deprecated Components
New Initialization Parameters Affecting Database Creation
DBCA Enhancements
Upgrading to Oracle Database 11g
Database Replay
The SQL Performance Analyzer
Patching in Oracle Database Control
Database Diagnosis and Repair
Introducing Automatic Diagnostic Repository (ADR)
Configuring the ADR
Using adrci Tool
Using The Support Workbench in the OEM
Database Health Monitor
Data Recovery Advisor
SQL Test Case Builder
Data Block Corruption Parameters
Database Administration
Automatic Memory Management
Automatic Maintenance Tasks
Oracle Flashback-Related New Features
LogMiner Interface in Oracle Enterprise Manager
Oracle Flashback Transaction Backout
Flashback Data Archive
Virtual Columns
New Data Partitioning Schemes
DDL Lock Timeout
Explicit Locking of Tables
Invisible Indexes
Read-Only Tables
Shrinking Temporary Tablespaces and Tempfiles
Creating an Initialization Parameter File from Memory
Restore Point Enhancements
Database Resident Connection Pooling
Comparing and Synchronizing Database Objects
SQL*Plus New Features
Oracle 11g New Features for Administrators:-
Online Application Maintenance
Oracle Advanced Compression Option
Oracle Scheduler New Features
Lightweight Jobs
Remote External Jobs
Finer-grained Dependency Management
Enhancements in Oracle Database Resource Manager
Performance Tuning
PL/SQL Native Compilation
Server Result Cache
Client Side Result Cache
Enhanced Oracle Process Monitoring
Subprogram Inlining
SQL Tuning Automation
SQL Access Advisor Enhancements
Changing Statistics Preferences
Enhanced Statistics Maintenance
SQL Plan Management
ADDM New Features
AWR New Features
Setting Metric Thresholds for Baselines
Performance-Related Changes in Database Control
Miscellaneous New Performance Tuning Features
Real-Time SQL Monitoring
Adaptive Cursor Sharing
Database Security
Stronger Password Hash Algorithm
Security Out of the Box
Anti Network Attacks Parameters
Tablespace Encryption
Fine-Grained Access Control for UTL_* Packages
Further Security New Features
Backup and Recovery New Features
Enhanced Block Media Recovery
RMAN Substitution Variables
New RMAN Configuration Parameters
The Multisection Backups
Creating Archival Backups
VALIDATE Command
Configuring an Archived Redo Log Deletion Policy
Oracle 11g New Features for Administrators:-
Active Database Duplication
Importing and Moving Recovery Catalogs
Virtual Private Catalogs
Miscellaneous New Features in RMAN
Data Pump Utilities
Compression Enhancement
Encryption Enhancements
Reusing a Dump File
Remapping Data
Renaming Tables During Export or Import
Data Pump and Partitioned Tables
Ignoring Nondeferred Constraints
External Tables Based on Data Pump Driver
Enhancement in the Transportable Parameter
Automatic Storage Management (ASM)
SYSASM Privilege and OSASM Group
Upgrading ASM using DBUA
Upgrading ASM Manually
ASM Restricted Mode
Diskgroup Attributes
Checking Diskgroup
asmcmd Utility Commands
Fast Rebalance
The FORCE option with Drop Diskgroup Command
Miscellaneous ASM New Features
PL/SQL New Features
PL/SQL New Features
Data Warehousing
SecureFiles
Accessing a LOB Using SQL and PL/SQL
Online Redefinition
Partition Change Tracking (PCT)
Generating SQL Crosstab Report using PIVOT Operator
Partitioning Improvements
Below Topics Not covered:-
Oracle Streams
Data Guard
Oracle RAC
Oracle XML DB
Wednesday, December 23, 2009
PARALLEL PROCESS
PARALLEL PROCESS:
DEFINITION - In computers, parallel processing is the processing of program instructions by dividing them among multiple processors with the objective of running a program in less time. In the earliest computers, only one program ran at a time. A computation-intensive program that took one hour to run and a tape copying program that took one hour to run would take a total of two hours to run. An early form of parallel processing allowed the interleaved execution of both programs together. The computer would start an I/O operation, and while it was waiting for the operation to complete, it would execute the processor-intensive program. The total execution time for the two jobs would be a little over one hour.
The Oracle Parallel Query Option
Introduced in later versions of Oracle7 the parallel query option (PQO) allows multiple processes to simultaneously fetch records and perform sorting operations. This parallelization of operations can lead to impressive speed improvements in a properly set up parallel environment.
The most important item to specify in a parallel environment is the number of parallel query slaves. Too few and you don’t get the full benefits, too many and they end up competing with each other for resources. Of course parallel operations are of little or no benefit if your system doesn’t have parallel processors and your tables aren’t spread across multiple disks in a stripe set or partitioned. Along with the number of parallel query slaves the degree of parallel (DOP) for the tables and indexes needs to be set properly.
The maximum number of parallel query slaves should generally be set to at least twice the number of CPUs or to twice the number of disks that he object was spread across. The DOP can be determined by forcing a full table scan for tables (use a where 1=2 in a select count(*) from the table) and then timing the response for different DOP settings. These numbers are then adjusted up or down depending on performance.
Parallel query settings
There are several initialization parameters that pertain to parallel query:
parallel_adaptive_multi_user
TRUE or FALSE, defaults to FALSE, when set to TRUE, enables an adaptive algorithm designed to improve performance in multi-user environments that use Parallel Query(PQ). It does this by automatically reducing the requested degree of parallelism based on the current number of active PQ users on the system. The effective degree of parallelism will be based on the degree of parallelism from the table or hint divided by the total number of PQ users. The algorithm assumes that the degree of parallelism provided has been tuned for optimal performance in a single user environment.
At Oracle Openworld 2007, Oracle recommends never to turn-on the parallel_adaptive_multi_user parameter.
optimizer_percent_parallel
Specifies the amount of parallelism that the optimizer uses in its cost functions. The default of 0 means that the optimizer chooses the best serial plan. A value of 100 means that the optimizer uses each object's degree of parallelism in computing the cost of a full table scan operation. Low values favor indexes, and high values favor table scans.
Cost-based optimization will always be used for any query that references an object with a nonzero degree of parallelism. For such queries a RULE hint or optimizer mode or goal will be ignored. Use of a FIRST_ROWS hint or optimizer mode will override a nonzero setting of OPTIMIZER_PERCENT_PARALLEL.
parallel_min_percent
This specifies the minimum percent of threads required for parallel query. Setting this parameter ensures that a parallel query will not be executed sequentially if adequate resources are not available. The default value of 0 means that this parameter is not used.
If too few query slaves are available, an error message is displayed and the query is not executed. Consider the following settings:
PARALLEL_MIN_PERCENT = 50
PARALLEL_MIN_SERVERS = 5
PARALLEL_MAX_SERVERS = 10
In a system with 20 instances up and running, the system would have a maximum of 200 query slaves available. If 190 slaves are already in use and a new user wants to run a query with 40 slaves (for example, degree 2 instances 20), an error message would be returned because 20 instances (that is, 50% of 40) are not available.
parallel_min_servers
This specifies the minimum number of query server processes for an instance. This is also the number of query server processes Oracle creates when the instance is started.
parallel_max_servers
Parallel_max_servers specifies the maximum number of parallel query servers or parallel recovery processes for an instance. Oracle will increase the number of query servers as demand requires from the number created at instance startup up to this value. The same value should be used for all instances in a parallel server environment.
Proper setting of the PARALLEL_MAX_SERVERS parameter ensures that the number of query servers in use will not cause a memory resource shortage during periods of peak database use.
If PARALLEL_MAX_SERVERS is set too low, some queries may not have a query server available to them during query processing.
Setting PARALLEL_MAX_SERVERS too high leads to memory resource shortages during peak periods, which can degrade performance. For each instance to which you do not want to apply the parallel query option, set this initialization parameter to zero.
If you have reached the limit of PARALLEL_MAX_SERVERS on an instance and you attempt to query a GV$ view, one additional parallel server process will be spawned for this purpose. This extra process will serve any subsequent GV$ queries until expiration of the PARALLEL_SERVER_IDLE_TIME, at which point the process will terminate. The extra process is not available for any parallel operation other than GV$ queries.
Note that if PARALLEL_MAX_SERVERS is set to zero for an instance, then no additional parallel server process will be allocated to accommodate a GV$ query.
parallel_server_idle_time
Specifies the amount of idle time after which Oracle terminates a process for parallel operations (parallel query, parallel DML, or parallel DDL). This value is expressed in minutes. The parameter must be set to 1 or greater for the query processes to terminate. 0 means the processes are never terminated.
parallel_execution_message_size
Specifies the size of messages for parallel execution (Parallel Query, PDML, Parallel Recovery, replication). The default value should be adequate for most applications. Typical values are 2148 or 4096 bytes. Larger values would require a larger shared pool.
parallel_min_message_pool
The parallel_min_message_pool parameter defaults to (cpus*parallel_max_servers*1.5*(OS message buffer size) or cpus*5*1.5*(OS message size)). Specifies the minimum permanent amount of memory which will be allocated from the SHARED POOL, to be used for messages in parallel execution.
This memory is allocated at startup time if PARALLEL_MIN_SERVERS is set to a non-zero value, or when the server is first allocated. Setting this parameter is most effective when PARALLEL_MIN_SERVERS is set to a non-zero value, because the memory will be allocated in a contiguous section.
This parameter should only be set if the default formula is known to be significantly inaccurate. setting this parameter too high will lead to a shortage of memory for the shared pool; setting it too low will lead to costlier memory allocation when doing parallel execution. This parameter cannot be set to a number higher than 90% of the shared pool.
parallel_broadcast_enabled
This defaults to FALSE and allows you to improve performance in certain cases involving hash and merge joins. When set to TRUE, if you are joining a very large join result set with a very small result set (size being measured in bytes, rather than number of rows), the optimizer has the option of broadcasting the row sources of the small result set, such that a single table queue will send all of the small set's rows to each of the parallel servers which are processing the rows of the larger set. The result is enhanced performance.
shared_pool_size
The shared pool will have to be increased in size to accommodate the parallel query message areas and IO queues. I suggest that the LARGE POOL be designated to prevent PQO from causing shared pool problems.
large_pool_size
The large pool will automatically be configured at a minimum size of 600k if certain initialization parameters are set in Oracle8. I suggest manually setting the size.
Oracle Parallel Automatic tuning parameter:
Oracle parallel query (OPQ) is a great way to speed full full-scan operations, but Oracle parallelism can be problematic if it is not implemented properly.
Oracle provides a general method for implementing parallelism with the parallel_automatic_tuning=true parameter setting, but there are cases when using PAT can actually degrade your Oracle performance. The Oracle docs note:
"With parallel automatic tuning enabled, Oracle determines parameter settings for each environment based on the number of CPUs on your system and the value set for PARALLEL_THREADS_PER_CPU.
The default values Oracle sets for parallel execution processing when PARALLEL_AUTOMATIC_TUNING is TRUE are usually optimal for most environments. In most cases, Oracle's automatically derived settings are at least as effective as manually derived settings."
I disagree.
The parallel_automatic_tuning parameter feature was created for DSS and Data Warehouse environments using the all_rows optimizer mode on servers with many CPU processors to ensure that the common full table scans are parallelized to an optimal DEGREE.
However, parallel_automatic_tuning is not always appropriate for OLTP and online systems, where setting parallel_automatic_tuning may change the SQL optimizers perception of the costs of full scan operations, causing indexes not to be used.
For non-warehouse environments, I do not recommend setting parallel_automatic_tuning, or turning on parallel query at the system or table level. I get the best performance my manually adding the "parallel" hint to query where I want the full can to be done in parallel.
PARALLEL_THREADS_PER_CPU specifies the default degree of parallelism for the instance and determines the parallel adaptive and load balancing algorithms. The parameter describes the number of parallel execution processes or threads that a CPU can handle during parallel execution.
The default is platform-dependent and is adequate in most cases. You should decrease the value of this parameter if the machine appears to be overloaded when a representative parallel query is executed. You should increase the value if the system is I/O bound.
* Parallel query. The ability to break up the execution of a SELECT statement into multiple tasks, and then to execute those tasks in parallel using multiple processors.
* Parallel data loading. The ability to run multiple SQL*Loader sessions in parallel, which all load data into the same table.
* Parallel DML (Data Manipulation Language). The ability to parallelize INSERT, UPDATE, and DELETE statements.
* Parallel DDL (object creation). The ability to parallelize DDL statements such as CREATE TABLE, CREATE INDEX, and ALTER INDEX.
* Parallel recovery. The ability to use multiple processes to perform instance and media recovery.
* Parallel replication propagation. The ability to propagate changes from one database to another using multiple processes working together in parallel.
DEFINITION - In computers, parallel processing is the processing of program instructions by dividing them among multiple processors with the objective of running a program in less time. In the earliest computers, only one program ran at a time. A computation-intensive program that took one hour to run and a tape copying program that took one hour to run would take a total of two hours to run. An early form of parallel processing allowed the interleaved execution of both programs together. The computer would start an I/O operation, and while it was waiting for the operation to complete, it would execute the processor-intensive program. The total execution time for the two jobs would be a little over one hour.
The Oracle Parallel Query Option
Introduced in later versions of Oracle7 the parallel query option (PQO) allows multiple processes to simultaneously fetch records and perform sorting operations. This parallelization of operations can lead to impressive speed improvements in a properly set up parallel environment.
The most important item to specify in a parallel environment is the number of parallel query slaves. Too few and you don’t get the full benefits, too many and they end up competing with each other for resources. Of course parallel operations are of little or no benefit if your system doesn’t have parallel processors and your tables aren’t spread across multiple disks in a stripe set or partitioned. Along with the number of parallel query slaves the degree of parallel (DOP) for the tables and indexes needs to be set properly.
The maximum number of parallel query slaves should generally be set to at least twice the number of CPUs or to twice the number of disks that he object was spread across. The DOP can be determined by forcing a full table scan for tables (use a where 1=2 in a select count(*) from the table) and then timing the response for different DOP settings. These numbers are then adjusted up or down depending on performance.
Parallel query settings
There are several initialization parameters that pertain to parallel query:
parallel_adaptive_multi_user
TRUE or FALSE, defaults to FALSE, when set to TRUE, enables an adaptive algorithm designed to improve performance in multi-user environments that use Parallel Query(PQ). It does this by automatically reducing the requested degree of parallelism based on the current number of active PQ users on the system. The effective degree of parallelism will be based on the degree of parallelism from the table or hint divided by the total number of PQ users. The algorithm assumes that the degree of parallelism provided has been tuned for optimal performance in a single user environment.
At Oracle Openworld 2007, Oracle recommends never to turn-on the parallel_adaptive_multi_user parameter.
optimizer_percent_parallel
Specifies the amount of parallelism that the optimizer uses in its cost functions. The default of 0 means that the optimizer chooses the best serial plan. A value of 100 means that the optimizer uses each object's degree of parallelism in computing the cost of a full table scan operation. Low values favor indexes, and high values favor table scans.
Cost-based optimization will always be used for any query that references an object with a nonzero degree of parallelism. For such queries a RULE hint or optimizer mode or goal will be ignored. Use of a FIRST_ROWS hint or optimizer mode will override a nonzero setting of OPTIMIZER_PERCENT_PARALLEL.
parallel_min_percent
This specifies the minimum percent of threads required for parallel query. Setting this parameter ensures that a parallel query will not be executed sequentially if adequate resources are not available. The default value of 0 means that this parameter is not used.
If too few query slaves are available, an error message is displayed and the query is not executed. Consider the following settings:
PARALLEL_MIN_PERCENT = 50
PARALLEL_MIN_SERVERS = 5
PARALLEL_MAX_SERVERS = 10
In a system with 20 instances up and running, the system would have a maximum of 200 query slaves available. If 190 slaves are already in use and a new user wants to run a query with 40 slaves (for example, degree 2 instances 20), an error message would be returned because 20 instances (that is, 50% of 40) are not available.
parallel_min_servers
This specifies the minimum number of query server processes for an instance. This is also the number of query server processes Oracle creates when the instance is started.
parallel_max_servers
Parallel_max_servers specifies the maximum number of parallel query servers or parallel recovery processes for an instance. Oracle will increase the number of query servers as demand requires from the number created at instance startup up to this value. The same value should be used for all instances in a parallel server environment.
Proper setting of the PARALLEL_MAX_SERVERS parameter ensures that the number of query servers in use will not cause a memory resource shortage during periods of peak database use.
If PARALLEL_MAX_SERVERS is set too low, some queries may not have a query server available to them during query processing.
Setting PARALLEL_MAX_SERVERS too high leads to memory resource shortages during peak periods, which can degrade performance. For each instance to which you do not want to apply the parallel query option, set this initialization parameter to zero.
If you have reached the limit of PARALLEL_MAX_SERVERS on an instance and you attempt to query a GV$ view, one additional parallel server process will be spawned for this purpose. This extra process will serve any subsequent GV$ queries until expiration of the PARALLEL_SERVER_IDLE_TIME, at which point the process will terminate. The extra process is not available for any parallel operation other than GV$ queries.
Note that if PARALLEL_MAX_SERVERS is set to zero for an instance, then no additional parallel server process will be allocated to accommodate a GV$ query.
parallel_server_idle_time
Specifies the amount of idle time after which Oracle terminates a process for parallel operations (parallel query, parallel DML, or parallel DDL). This value is expressed in minutes. The parameter must be set to 1 or greater for the query processes to terminate. 0 means the processes are never terminated.
parallel_execution_message_size
Specifies the size of messages for parallel execution (Parallel Query, PDML, Parallel Recovery, replication). The default value should be adequate for most applications. Typical values are 2148 or 4096 bytes. Larger values would require a larger shared pool.
parallel_min_message_pool
The parallel_min_message_pool parameter defaults to (cpus*parallel_max_servers*1.5*(OS message buffer size) or cpus*5*1.5*(OS message size)). Specifies the minimum permanent amount of memory which will be allocated from the SHARED POOL, to be used for messages in parallel execution.
This memory is allocated at startup time if PARALLEL_MIN_SERVERS is set to a non-zero value, or when the server is first allocated. Setting this parameter is most effective when PARALLEL_MIN_SERVERS is set to a non-zero value, because the memory will be allocated in a contiguous section.
This parameter should only be set if the default formula is known to be significantly inaccurate. setting this parameter too high will lead to a shortage of memory for the shared pool; setting it too low will lead to costlier memory allocation when doing parallel execution. This parameter cannot be set to a number higher than 90% of the shared pool.
parallel_broadcast_enabled
This defaults to FALSE and allows you to improve performance in certain cases involving hash and merge joins. When set to TRUE, if you are joining a very large join result set with a very small result set (size being measured in bytes, rather than number of rows), the optimizer has the option of broadcasting the row sources of the small result set, such that a single table queue will send all of the small set's rows to each of the parallel servers which are processing the rows of the larger set. The result is enhanced performance.
shared_pool_size
The shared pool will have to be increased in size to accommodate the parallel query message areas and IO queues. I suggest that the LARGE POOL be designated to prevent PQO from causing shared pool problems.
large_pool_size
The large pool will automatically be configured at a minimum size of 600k if certain initialization parameters are set in Oracle8. I suggest manually setting the size.
Oracle Parallel Automatic tuning parameter:
Oracle parallel query (OPQ) is a great way to speed full full-scan operations, but Oracle parallelism can be problematic if it is not implemented properly.
Oracle provides a general method for implementing parallelism with the parallel_automatic_tuning=true parameter setting, but there are cases when using PAT can actually degrade your Oracle performance. The Oracle docs note:
"With parallel automatic tuning enabled, Oracle determines parameter settings for each environment based on the number of CPUs on your system and the value set for PARALLEL_THREADS_PER_CPU.
The default values Oracle sets for parallel execution processing when PARALLEL_AUTOMATIC_TUNING is TRUE are usually optimal for most environments. In most cases, Oracle's automatically derived settings are at least as effective as manually derived settings."
I disagree.
The parallel_automatic_tuning parameter feature was created for DSS and Data Warehouse environments using the all_rows optimizer mode on servers with many CPU processors to ensure that the common full table scans are parallelized to an optimal DEGREE.
However, parallel_automatic_tuning is not always appropriate for OLTP and online systems, where setting parallel_automatic_tuning may change the SQL optimizers perception of the costs of full scan operations, causing indexes not to be used.
For non-warehouse environments, I do not recommend setting parallel_automatic_tuning, or turning on parallel query at the system or table level. I get the best performance my manually adding the "parallel" hint to query where I want the full can to be done in parallel.
PARALLEL_THREADS_PER_CPU specifies the default degree of parallelism for the instance and determines the parallel adaptive and load balancing algorithms. The parameter describes the number of parallel execution processes or threads that a CPU can handle during parallel execution.
The default is platform-dependent and is adequate in most cases. You should decrease the value of this parameter if the machine appears to be overloaded when a representative parallel query is executed. You should increase the value if the system is I/O bound.
* Parallel query. The ability to break up the execution of a SELECT statement into multiple tasks, and then to execute those tasks in parallel using multiple processors.
* Parallel data loading. The ability to run multiple SQL*Loader sessions in parallel, which all load data into the same table.
* Parallel DML (Data Manipulation Language). The ability to parallelize INSERT, UPDATE, and DELETE statements.
* Parallel DDL (object creation). The ability to parallelize DDL statements such as CREATE TABLE, CREATE INDEX, and ALTER INDEX.
* Parallel recovery. The ability to use multiple processes to perform instance and media recovery.
* Parallel replication propagation. The ability to propagate changes from one database to another using multiple processes working together in parallel.
Subscribe to:
Posts (Atom)

