Posted by admin on May 14th, 2012
/* ************************************************************* */
/* Index Fragmentation Status (idsfrag.sql): */
/* */
/* This script will report the index fragmentation status */
/* for a schema. */
/* */
/* Note: - Do not run this scrip during peak processing hours!!! */
/* - This script will fail for locked tables. */
/* */
/* ************************************************************* */
prompt -- Drop and create temporary table to hold stats...
drop table my_index_stats
/
create table my_index_stats (
index_name varchar2(30),
height number(8),
del_lf_rows number(8),
if_rows number(8),
distinct_keys number(8),
rows_per_key number(10,2),
blks_gets_per_access number(10,2)
)
/
prompt -- Save script which we will later use to populate the above table...
insert into my_index_stats
select NAME, HEIGHT, DEL_LF_ROWS,LF_ROWS, DISTINCT_KEYS, ROWS_PER_KEY,
BLKS_GETS_PER_ACCESS
from INDEX_STATS
-- Note this open line...
save /tmp/save_index_stats.sql replace
prompt
prompt -- Spool listing with validate commands...
col line1 newline
col line2 newline
col line3 newline
set pagesize 0
set echo off
set termout off
set trimspool on
set feed off
set linesize 200
spool /tmp/validate_indexes.sql
select 'prompt Process table '||owner||'.'||table_name||
', index '||index_name||'...' line1,
'validate index '||owner||'.'||index_name||';' line2,
'@/tmp/save_index_stats.sql' line3
from sys.dba_indexes where owner = 'SCOTT'
order by table_name, index_name
/
spool off
set termout on
set feed on
prompt
prompt -- Run script to validate indexes...
@/tmp/validate_indexes.sql
prompt -- Print nice report...
set pagesize 50000
set trimspool on
col height format 99999
col del_rows format 9999999
col rows/key format 999999.9
spool idxfrag.lst
select INDEX_NAME, HEIGHT, DEL_LF_ROWS "DEL_ROWS",LF_ROWS, DISTINCT_KEYS "DIST KEYS",
ROWS_PER_KEY "ROWS/KEY",
BLKS_GETS_PER_ACCESS "BLKS/ACCESS"
from MY_INDEX_STATS
/
spool off
-- Cleanup
drop table my_index_stats
/
! rm /tmp/validate_indexes.sql
! rm /tmp/save_index_stats.sql
prompt
prompt Report is in idxfrag.lst
prompt Done!!!
An index should be considered for rebuilding under any of the following conditions:
The percentage of deleted rows exceeds 30% of the total, i.e. if
1.del_lf_rows / lf_rows > 0.3.
2.If the ‘HEIGHT’ is greater than 4.
3.If the number of rows in the index (‘LF_ROWS’) is significantly smaller than ‘LF_BLKS’ this can indicate a large 4.number of deletes, indicating that the index should be rebuilt.
Posted in Oracle Experience | No Comments »
Posted by admin on May 11th, 2012
来自pythian mysql project
With this plug-in, a DBA can add a new MySQL target just as they can an Oracle database. Oracle Enterprise Manager Agent doesn’t have to be running on the same host as the monitored MySQL database. I.e., remote monitoring of the MySQL database using one or two agents is[......]
Read more
Posted in MYSQL | No Comments »
Posted by admin on April 27th, 2012
在pub上看到一个不错的帖子 oracle 11g password delay
对这个特性 做如下说明
Failed Logon Delays
A hacker may attempt a brute force hack to break into your Oracle Database. This is where they try constant logons to the database using some form of a word list. To try to make brute force hacking more difficult, Ora[......]
Read more
Tags: 11g new feature
Posted in Oracle Experience | No Comments »
Posted by admin on April 26th, 2012
ASM – ora.asm error
11.2.0.3 RAC CRS 无法启动
[ohasd(25286)]CRS-2112:The OLR service started on node db-41.
2012-04-25 14:46:13.120
[ohasd(25286)]CRS-1301:Oracle High Availability Service started on node db-41.
2012-04-25 14:46:13.120
[ohasd(25286)]CRS-8017:location: /etc/oracle/lastgasp has 2 reboot advisory log files, 0 were announced and 0 errors occurred
2012-04-25 14:46:14.181
[/data/11.2.0/grid/bin/orarootagent.bin(25332)]CRS-5016:Process "/data/11.2.0/grid/bin/acfsload" spawned by agent "/data/11.2.0/grid/bin/orarootagent.bin" for action "check" failed: details at "(:CLSN00010:)" in "/data/11.2.0/grid/log/db-41/agent/ohasd/orarootagent_root/orarootagent_root.log"
2012-04-25 14:46:17.031
[gpnpd(25510)]CRS-2328:GPNPD started on node db-41.
2012-04-25 14:46:20.794
[cssd(25593)]CRS-1713:CSSD daemon is started in clustered mode
2012-04-25 14:46:22.520
[ohasd(25286)]CRS-2767:Resource state recovery not attempted for 'ora.diskmon' as its target state is OFFLINE
2012-04-25 14:46:40.715
[cssd(25593)]CRS-1707:Lease acquisition for node db-41 number 1 completed
2012-04-25 14:46:42.003
[cssd(25593)]CRS-1605:CSSD voting file is online: /dev/mapper/Vote03; details in /data/11.2.0/grid/log/db-41/cssd/ocssd.log.
2012-04-25 14:46:42.008
[cssd(25593)]CRS-1605:CSSD voting file is online: /dev/mapper/Vote02; details in /data/11.2.0/grid/log/db-41/cssd/ocssd.log.
2012-04-25 14:46:42.015
[cssd(25593)]CRS-1605:CSSD voting file is online: /dev/mapper/Vote01; details in /data/11.2.0/grid/log/db-41/cssd/ocssd.log.
2012-04-25 14:46:52.173
[cssd(25593)]CRS-1601:CSSD Reconfiguration complete. Active nodes are db-41 .
2012-04-25 14:46:54.177
[ctssd(25738)]CRS-2407:The new Cluster Time Synchronization Service reference node is host db-41.
2012-04-25 14:46:54.177
[ctssd(25738)]CRS-2401:The Cluster Time Synchronization Service started on host db-41.
[client(25843)]CRS-10001:25-Apr-12 14:46 ACFS-9391: Checking for existing ADVM/ACFS installation.
[client(25848)]CRS-10001:25-Apr-12 14:46 ACFS-9392: Validating ADVM/ACFS installation files for operating system.
[client(25850)]CRS-10001:25-Apr-12 14:46 ACFS-9393: Verifying ASM Administrator setup.
[client(25853)]CRS-10001:25-Apr-12 14:46 ACFS-9308: Loading installed ADVM/ACFS drivers.
[client(25856)]CRS-10001:25-Apr-12 14:46 ACFS-9154: Loading 'oracleoks.ko' driver.
[client(25913)]CRS-10001:25-Apr-12 14:46 ACFS-9154: Loading 'oracleadvm.ko' driver.
[client(25974)]CRS-10001:25-Apr-12 14:46 ACFS-9154: Loading 'oracleacfs.ko' driver.
[client(26099)]CRS-10001:25-Apr-12 14:46 ACFS-9327: Verifying ADVM/ACFS devices.
[client(26103)]CRS-10001:25-Apr-12 14:46 ACFS-9156: Detecting control device '/dev/asm/.asm_ctl_spec'.
[client(26107)]CRS-10001:25-Apr-12 14:46 ACFS-9156: Detecting control device '/dev/ofsctl'.
[client(26113)]CRS-10001:25-Apr-12 14:46 ACFS-9322: completed
2012-04-25 14:47:06.975
[ohasd(25286)]CRS-2807:Resource 'ora.asm' failed to start automatically.
[ctssd(25738)]CRS-2405:The Cluster Time Synchronization Service on host db-41 is shutdown by user
2012-04-25 14:51:25.852
[/data/11.2.0/grid/bin/orarootagent.bin(25523)]CRS-5016:Process "/data/11.2.0/grid/bin/acfsload" spawned by agent "/data/11.2.0/grid/bin/orarootagent.bin" for action "check" failed: details at "(:CLSN00010:)" in "/data/11.2.0/grid/log/db-41/agent/ohasd/orarootagent_root/orarootagent_root.log"
2012-04-25 14:51:35.716
[cssd(25593)]CRS-1603:CSSD on node db-41 shutdown by user.
2012-04-25 14:51:35.725
[ohasd(25286)]CRS-2767:Resource state recovery not attempted for 'ora.cssdmonitor' as its target state is OFFLINE
2012-04-25 14:51:36.224
[cssd(25593)]CRS-1660:The CSS daemon shutdown has completed
2012-04-25 14:51:38.144
[gpnpd(25510)]CRS-2329:GPNPD on node db-41 shutdown.
重建spfile :
+ASM.asm_diskgroups='DATA','ARCH'
*.asm_diskstring='/dev/mapper/*'
*.asm_power_limit=1
*.diagnostic_dest='/data/app/oracle'
*.instance_type='asm'
*.large_pool_size=12M
#*.local_listener='LISTENER_+ASM'
*.remote_login_passwordfile='EXCLUSIVE'
eg: pfile 拉起 ASM instance mount data group
SQL>create spfile='+DATA' from pfile='xxx';
[grid@db-41 ~]$ sqlplus ‘/as sysasm’
SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 26 15:21:33 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected t[......]
Read more
Tags: 11g new feature, asm
Posted in Oracle Experience | No Comments »
Posted by admin on April 25th, 2012
ASM Preferred mirror Read
Introduction
The concept of the Preferred Read is not a new idea, but is now implemented in Oracle’s ASM volume
management in Oracle 11g.The concept is to read from the storage that can present the needed data at a lower
latency. Initially, this was designed for WAN or site-specific storage in order to avoid higher-latency site
connections. By restricting data reads to the local storage, the application would be able to service requests at
nominal read speeds while writes were the only communication needed to traverse the long haul site link. This is
a feature that is available to most Operating Systems with their included volume manager and as a feature to
Symantec/Veritas through the title Preferred Plex. This paper will discuss the merits of using PRG technology with Oracle ASM
eg:
SELECT name, failgroup FROM v$asm_disk;
NAME FAILGROUP
------------------------------ ------------------------------
DATA_0000 DATA_0000
DATA_0001 DATA_0001
DATA_0002 DATA_0002
3 rows selected.
SQL> ALTER SYSTEM SET ASM_PREFERRED_READ_FAILURE_GROUPS = 'data.data_0000', 'data.data_0001', 'data.data_0002';
Allocating ASM Extent Sets
With ASM redundancy, the first file extent allocated is chosen as primary extent, and
the mirrored extent is called the secondary extent. In the case of high redundancy,
there will two secondary extents. This logical grouping of primary and secondary
extents is called an extent set. When a block is read from disk, it is always read from
the primary extent, unless the primary extent cannot be read. In Oracle Database
11g, the preferred read feature allows the database to read the secondary extent first
instead of reading the primary extent. This is especially important for RAC Extended
Cluster implementations.
As stated earlier, ASM in Oracle Database 10g always reads the primary copy of a mirrored extent set. Thus, a read for a specific block may require a read of the primary extent at the remote site across the interconnect. Accessing a remote disk through a metropolitan area or wide area storage network is substantially slower than accessing a local disk. This can tax the interconnect as well as result in high I/ O and network latency. To assuage this, Oracle Database 11g provides a feature called preferred reads. This feature enables ASM administrators to specify a failure group for local reads–– that is, provide preferred reads. In a normal or high-redundancy diskgroup, when a secondary extent is on a preferred disk and the primary extent is remote, the secondary extent is read rather than the primary one on that node. This feature is especially beneficial for extended cluster configurations.
根据上面所说的 “This is especially important for RAC Extended” hellodba 也提出过类似的想法 参见 PRG
另外IOUG的一篇文档也给出了一个很好的利用这个特性配合SSD提高IO效率的方案
Read more
Tags: asm
Posted in Oracle Experience | No Comments »
Posted by admin on April 20th, 2012
Execution Environment:
Access Privileges:
Requires to be run connected as SYS schema
Usage:
$ sqlplus
SQL*Plus: Release 9.2.0.2.0 - Production on Mon Nov 11 12:00:06 2002
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.2.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.2.0 - Production
SQL> set serveroutput on size unlimited
SQL> spool outputfile
SQL> execute hcheck.full
Instructions:
1. Connect as SYS schema in sqlplus
2. Create package hOut as described in Note:101468.1
3. Create package hcheck in SYS schema (Refer the attachments under SCRIPT to Create package hcheck, this is hcheck2.sql and/or hcheck3.sql
4. spool outputfile
5. execute hcheck.full
6. Output will go to the spool file and the session trace file.
The script will report various dictionary related issues
which may or may not be a problem - Any problems reported
should be reviewed by an experienced support analyst as some
reported "problems" may be normal and expected.
PROOFREAD THE SCRIPT BEFORE USING IT! Due to differences in the way text
editors, e-mail packages, and operating systems handle text formatting (spaces,
tabs, and carriage returns), this script may not be in an executable state
when you first receive it. Check over the script to ensure that errors of
this type are corrected.The script will produce an output file named [outputfile].
This file can be viewed in a browser or uploaded for support analysis.
Description
To provide a single package which looks for common data dictionary
problems.
The script can be used with Oracle versions 9i onwards (release 2.00 includes 8.1)
It checks consistency of certain dictionary relationships and looks for certain
known issues - certain reported "problems" will be normal and expected.
This script is for use mainly under the guidance of Oracle Support.
eg:
SQL> exec hcheck.full
H.Check Version 9i+/hc3.45
---------------------------------------
Catalog Version 11.2.0.3.0 (1102000300)
---------------------------------------
Catalog Fixed
Procedure Name Version Vs Release Run
------------------------------ ... ---------- -- ---------- ---
.- SynLastDDLTim ... 1102000300 > 1001000200 : n/a
.- LobNotInObj ... 1102000300 > 1000000200 : n/a
.- MissingOIDOnObjCol ... 1102000300 <= *All Rel* : Ok
.- SourceNotInObj ... 1102000300 > 1002000100 : n/a
.- IndIndparMismatch ... 1102000300 > 1102000100 : n/a
.- InvCorrAudit ... 1102000300 > 1102000100 : n/a
.- OversizedFiles ... 1102000300 <= *All Rel* : Ok
.- TinyFiles ... 1102000300 > 900010000 : n/a
.- PoorDefaultStorage ... 1102000300 <= *All Rel* : Ok
.- PoorStorage ... 1102000300 <= *All Rel* : Ok
.- MissTabSubPart ... 1102000300 > 900010000 : n/a
.- PartSubPartMismatch ... 1102000300 > 1102000100 : n/a
.- TabPartCountMismatch ... 1102000300 <= *All Rel* : Ok
.- OrphanedTabComPart ... 1102000300 > 900010000 : n/a
.- ZeroTabSubPart ... 1102000300 > 902000100 : n/a
.- MissingSum$ ... 1102000300 <= *All Rel* : Ok
.- MissingDir$ ... 1102000300 <= *All Rel* : Ok
.- DuplicateDataobj ... 1102000300 <= *All Rel* : Ok
.- ObjSynMissing ... 1102000300 <= *All Rel* : Ok
.- ObjSeqMissing ... 1102000300 <= *All Rel* : Ok
.- OrphanedUndo ... 1102000300 <= *All Rel* : Ok
.- OrphanedIndex ... 1102000300 <= *All Rel* : Ok
.- OrphanedIndexPartition ... 1102000300 <= *All Rel* : Ok
.- OrphanedIndexSubPartition ... 1102000300 <= *All Rel* : Ok
.- OrphanedTable ... 1102000300 <= *All Rel* : Ok
.- OrphanedTablePartition ... 1102000300 <= *All Rel* : Ok
.- OrphanedTableSubPartition ... 1102000300 <= *All Rel* : Ok
.- MissingPartCol ... 1102000300 <= *All Rel* : Ok
.- OrphanedSeg$ ... 1102000300 <= *All Rel* : Ok
.- OrphanedIndPartObj# ... 1102000300 > 1101000600 : n/a
.- DuplicateBlockUse ... 1102000300 <= *All Rel* : Ok
.- HighObjectIds ... 1102000300 > 801060000 : n/a
.- PQsequence ... 1102000300 > 800060000 : n/a
.- TruncatedCluster ... 1102000300 > 801070000 : n/a
.- FetUet ... 1102000300 <= *All Rel* : Ok
.- Uet0Check ... 1102000300 <= *All Rel* : Ok
.- ExtentlessSeg ... 1102000300 <= *All Rel* : Ok
.- SeglessUET ... 1102000300 <= *All Rel* : Ok
.- BadInd$ ... 1102000300 <= *All Rel* : Ok
.- BadTab$ ... 1102000300 <= *All Rel* : Ok
.- BadIcolDepCnt ... 1102000300 > 1101000700 : n/a
.- WarnIcolDep ... 1102000300 > 1101000700 : n/a
.- OnlineRebuild$ ... 1102000300 <= *All Rel* : Ok
.- DropForceType ... 1102000300 > 1001000200 : n/a
.- TrgAfterUpgrade ... 1102000300 <= *All Rel* : Ok
.- FailedInitJVMRun ... 1102000300 <= *All Rel* : Ok
.- TypeReusedAfterDrop ... 1102000300 > 900010000 : n/a
.- Idgen1$TTS ... 1102000300 > 900010000 : n/a
.- DroppedFuncIdx ... 1102000300 > 902000100 : n/a
.- BadOwner ... 1102000300 > 900010000 : n/a
.- UpgCheckc0801070 ... 1102000300 <= *All Rel* : Ok
.- BadPublicObjects ... 1102000300 <= *All Rel* : Ok
.- BadSegFreelist ... 1102000300 <= *All Rel* : Ok
.- BadCol# ... 1102000300 > 1001000200 : n/a
.- BadDepends ... 1102000300 <= *All Rel* : Ok
.- CheckDual ... 1102000300 <= *All Rel* : Ok
.- ObjectNames ... 1102000300 <= *All Rel* : Ok
.- BadCboHiLo ... 1102000300 <= *All Rel* : Ok
.- ChkIotTs ... 1102000300 <= *All Rel* : Ok
.- NoSegmentIndex ... 1102000300 <= *All Rel* : Ok
.- BadNextObject ... 1102000300 <= *All Rel* : Ok
.- OrphanIndopt ... 1102000300 > 902000800 : n/a
.- UpgFlgBitTmp ... 1102000300 > 1001000100 : n/a
.- RenCharView ... 1102000300 > 1001000100 : n/a
.- Upg9iTab$ ... 1102000300 > 902000400 : n/a
.- Upg9iTsInd ... 1102000300 > 902000500 : n/a
.- Upg10gInd$ ... 1102000300 > 1002000000 : n/a
.- DroppedROTS ... 1102000300 <= *All Rel* : Ok
.- ChrLenSmtcs ... 1102000300 > 1101000600 : n/a
.- FilBlkZero ... 1102000300 <= *All Rel* : Ok
.- DbmsSchemaCopy ... 1102000300 <= *All Rel* : Ok
Found 0 potential problem(s) and 0 warning(s)
PL/SQL procedure successfully completed.
Tags: scripts
Posted in Oracle Experience | No Comments »
Posted by admin on April 16th, 2012
Posted in Oracle Experience | No Comments »
Posted by admin on April 10th, 2012
最近跟同事测试了下MHA 作为mysql 高可用方案的一种 MHA具有很多优点 DeNA目前采用这种架构 支撑2亿+PV的访问
MHA
一.MHA介绍
MHA自动化主服务器故障转移,快速将从服务器晋级为主服务器(通常在10-30s),而不影响复制的一致性,不需要花钱买更多的新服务器,不会有性能损耗,容易安装,不必更改现有的部署环境,适用于任何存储引擎。
MHA提供在线主服务器切换,改变先正运行的主服务器到另外一台上,这个过程只需0.5-2s的时间,这个时间内数据无法写入。
MHA Manager通过ssh连接mysql slave服务器。
虽然MHA试图从挡掉[......]
Read more
Posted in MYSQL | 1 Comment »
Posted by admin on April 8th, 2012
Posted in Life | No Comments »
Posted by admin on April 1st, 2012
Teradata 与 Exadata 的一些对比说明,由于是TD出来的文档 所以有一些片面之词
Tags: architecture
Posted in Unix/Linux | No Comments »