从事ORACLE DBA工作很多年了,也使用过很多ORACLE的管理工具,有收费的OEM、TOAD、PLsql Developer,免费的EM,sql developer, 但日常我用的最多的是shell脚本DB。
这个脚本是以前Ebay的同事推荐的,把一些常用的查询封装成函数放在一个shell脚本里,使用起来很方便。由于都是查询语句,不需要安装也不对目标数据库做任何改动,所有很安全,可以在生产环境上任意执行。
在使用过程中发现功能较少,不断地对其进行功能扩展,到现在已经是非常完善功能非常强大了,碰到性能问题基本上马上就可以分析出系统问题根源。就只有一个脚本不需要任何安装,通过简单的loop就可以管理任意多的数据库,减轻了大量的日常维护压力,可以说是DBA的必备利器。
改进的功能介绍:
支持连接本地数据库和远程数据库: 本地执行方法:db / sessions 远程执行方法:db tnsname sessions
自带帮助功能: 使用db help 功能名会打印出执行该功能将执行的SQL
自动生成数据库对象相关DDL语句,并生成相关的变更语句。如对表空间大小查询时会生成增加数据文件及收缩数据文件语句。
支持ASM实例 可以管理ASM存储和数据文件
支持RAC多实例查询: 对RAC视图查询时都带了instance id,清晰地查看到每个实例的状况
支持PDB: 可以查看CDB和PDB信息
支持DG状态查询: 可以查看DG实例角色,复制状态,是否有延时等常用信息
支持各种等待事件查看和历史记录查询: 快速查看历史等待事件信息和瓶颈发生的时间段,帮助找出问题原因
性能调优利器: SQL执行计划查看和SQL plan profile及SQL plan baseline查看 生成表、字段列、索引统计信息列表,秒级时间内找出有问题的索引
如果有感兴趣的朋友请留言联系。
功能列表:
Query Utility for oracle dba
-------------------------------------------
alert [hour] show error in alert.log in hours
active show session sid,serial#,username,sqlid with sqltext from running v$session, sql_id,event, count(*), sql to kill session
aio enable oralce disk async io support, improve IO performance tunning
as [hour] show active session history blocking event from gv$active_session_history ASH in hours, with blocking_session IS NOT NULL
ash [hour] show active session count, top event count peak time by minute from dba_hist_active_sess_history in hours, blocking_session IS NOT NULL in show_histblock
asm show asm diskgroup and disk IO speed, disk related operation
audit show audit info from sys.aud$, unified_audit_trail
awr show awrrpt tunning hint
awrbaseline show awr baseline setting
block_tracking show database block tracking to speed up rman backup job
db show database role info
dblinks show database link info
ddl [owner].[name] show DDL of an user/object : [db ddl sys.V_\$DIAG_ALERT_EXT]
ddl user/priv grants(role), TABLE/INDEX/SEQUENCE/DATABASE LINK/DIRECTORY/FUNCTION/JOB/PACKAGE/PROCEDURE/TRIGGER/SYNONYM/TYPE/VIEW
ddlall [owner].[name] show DDL, dependent DDL and dependent objects of an object
ddl_all type lists show tablespace/user/profile/quota/role sequence definition by given users list
ddldep [owner].[name] show dependent DDL of an object
depobj [owner].[name] show dependent objects of an object(e.g, foreign key)
df [tablespace] *show datafile info, include temp tablespace
desc [owner].[name] show description of an object
dg show dataguard adg information
dir show ORACLE directory objects
estsize [owner].[name] [numrows] show estimated size of a table;
enq show active enq event
event [event_name] show event description by event name
segment_wait [owner/event_name] show waits on segment, like ITL waits when event enq: TX - allocate ITL entry
fk show fk constraints without index
fulltext show sql_id full text
fulltablescan show sql_id which plan is full table scan
frag_tbs show tablespace fragment
frag_tbl show table fragment
flashback show flashback information
genstat [owner].[name] [noprompt] generate statistics of an table/index
host [sid] show hostname of a database
histblock [hour] show active blocking session history info in hours from dba_hist_active_sess_history, blocking_session is not null
histsqlid [sql_id] show hist sql_id session information by SQL_ID or username
histevent [hour] event_name show forground & background history events stats, health check by event counts within sample time, sql_id tuning
histtext [sql_id]/[sql_text] show SQL session history statement by sql_id or like sql text
histplan [plan_hash_value] show SQL session history execution plan by hash_value
idle [sec] list idle sessions (default 1800)
idxstat [owner].[name] show index statistics
invalid [owner] show invalid object
job show scheduler jobs
rebuild show SQL statement to compile/rebuild invalid object
lockobjs show session locked objects
locksess [owner].[name] show accessed objects and sessions locked them
locktree show session lock wait-for graph in tree structured fashion
block1 show blocked session in RAC and create kill sql
block2 show blocked session in RAC with SQLID
lob owners/name show lob column information
longops show long running session operations
kernel show kernel configuration, tunning
metric show system session performance metric by wait class/event
objlike owner/name *search for objects, show LAST_DDL_TIME and status
objsize owners/name *show table/index/lob segments size by like [owners]/[name], order by bytes
objbyfb [fileid] [blockid] show object name by file# and block#
objbydba [dba] show object name by Data Block Adress
partition [owner] show table partiiton
params [str] show parameter value, show hidden param value need run as sys
path show oracle software directory paths
pdb show cdb pdb info
pe [username] show session parallel execution info
proxy show proxy users
profile show user profile information
pump show datapump jobs(10g)
redo|log show redo logfile group information
archive show session generate much redo and archive size, show archive mode by archive log list
rman show rman backup job logs, archive size
roles show all roles and username by given role name
rollback show session transaction rollback segments
registry show installed ORACLE components
sessions [username] show sessions, s or a
tabinschema [username] show tables in specified schema
ts_objects [tablespace_name] show segments in specified tablespace
scn show timezone and SCN timestamp info
sga show session sga pga info
sharedpool show shared_pool and memory advisor, to avoid ORA-04031 by increase SHARED_POOL_RESERVED_SIZE, SHARED_POOL_SIZE, LARGE_POOL_SIZE.
shrinkfile filename show SQL to shrink datafiles by specific file name
shrinkts [name] show SQL to shrink datafiles in specific tablespace, RESIZE
shrinktemp show SQL to shrink tempfiles
sql [b,c,d,e,s,t] [sql_id] show session SQL_ID SQLTEXT history sort by buffer gets, CPU, Disk, Elapsed time,Sorts, Execution times
sqlbind [SQL_ID] show sql_id bind info
sqlid [b,c,d,e,s,t] [sql_id] show session SQL_ID history in 3 days sort by buffer gets, CPU, Disk, Elapsed time, Sorts, Execution times
sqlid_tune [SQL_ID] show session tuning SQL_ID by sql profile using DBMS_SQLTUNE.execute_tuning_task, and show drop sql plan profile sql by dba_sql_profiles
sqlid_purge [SQL_ID] show session purge/flush SQL execution plan from cache, delete/remove
sqlid_exec_hist SQL_ID show SQL_ID execution history detail, plan_hash_value change, elapsed time
sqlmonitor [SQL_ID] show session sql_id statistics info in sql_monitor run more than 5 seconds CPU/IO by dbms_sqltune
sqllike [patten] show session sql_id SQLTEXT with specified words
sqllikea [patten] show session sql_id SQLTEXT with specified words in current running session
sqltext [SQL_ID] show session SQL statement by sql_id
sqlplan [SQL_ID] show session SQL execution plan by sql_id by dbms_xplan.display_cursor
sqlplan1 [SQL_ID,plan_hash_value] show session SQL execution plan by sql_id or plan_hash_value
sqlplanprofile/sqlbaseline show session SQL_PLAN profile/baseline, fix or drop sql plan from dba_sql_plan_baselines, DBA_AUTOTASK_CLIENT advisor
sorts show session temp sort usage
sql_access_advisor SQLTEXT show session sql access advisor, SQL tunning
source [owner].[name] [line] show specified line of procedure/function/package
sqlldr [owner].[name] show sqlldr control file
sequence show sequence cache info
sysaux show contents in sysaux
synonym owners/name show synonyms
tabidx [owner].[name] show all indexes on a specific table
tabcons [owner].[name] show all constraints on a specific table
tablike owner/name search for tables, show degree, last analyze date
tabstat [owner].[name] show table statistics, and TABLE and INDEX data dictionary for schema
tabsize [owner].[name] [tabonly] show table and its indexes size
trigger [owner].[name] show trigger by given table name
tailalert [line] show tail of alertlog
temp show session max history TEMP_SPACE_ALLOCATED session used by sort
trans show session not commited transaction, undo size info with START_TIME, or dead transaction rollbacking
ts [tablespace_name] show tablespace info
tsddl show tablespace definition
tsspace [tablespace] *show tablespace space info
sqltrace show diag trace path, turn on sql_trace by events 10046
undo show session undo space info
users show user info, audit failed_login_attempts,after logon trigger,LOCK_DATE
waitinfo,w show session detailed wait event info, p1,p2,p3
nodes show rac nodes, services
SYS_CONTEXT('USERENV','INSTANCE_NAME'), USERENV('LANGUAGE') sys_context('USERENV', 'CURRENT_USER')
*: wildcard enabled ( % for 0~* chars, _ for 1 char)
脚本在哪里可以获取。谢谢!
请问大神,主功能脚本从哪里获取?