- 浏览: 336751 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
lovebegar:
很有价值,之前自己写都是第一种,学习了~
Oracle 多行合并一行 方法 -
zuodang:
我尝试在windows中搭环境编译 curl-java-mas ...
有强大的cURL,忘掉httpclient的吧! -
buildhappy:
同求http://www.gknw.de/mirror/cur ...
有强大的cURL,忘掉httpclient的吧! -
zgf_091:
好早的文章,现在才看到,就是这个链接http://www.gk ...
有强大的cURL,忘掉httpclient的吧! -
huchuhan:
LZ应该贴个例子出来, 网上这方面的东西太少了.
有强大的cURL,忘掉httpclient的吧!
--- 创建view --- 百分比 create view tablespace_used_percent as select useage from ( select a.tablespace_name, a.file_name, a.total "Total(MB)", round(a.total-b.Free_Space) "Used(MB)", round(((a.total-b.Free_Space)/a.total)*100,2) as useage, a.auto_extend from (select FILE_ID, tablespace_name, file_name, bytes/(1024*1024) Total, AUTOEXTENSIBLE auto_extend from dba_data_files ddf) a, (select file_id, sum(bytes)/(1024*1024) Free_Space from dba_free_space group by file_id) b where a.file_id=b.file_id ) where tablespace_name = 'YOUR TABLESPACE NAME'; --- deails create view TABLESPACE_USAGE as select a.tablespace_name, a.file_name, a.total "Total(MB)", round(a.total-b.Free_Space) "Used(MB)", round(((a.total-b.Free_Space)/a.total)*100,2) "Used(%)", a.auto_extend from (select FILE_ID, tablespace_name, file_name, bytes/(1024*1024) Total, AUTOEXTENSIBLE auto_extend from dba_data_files ddf) a, (select file_id, sum(bytes)/(1024*1024) Free_Space from dba_free_space group by file_id) b where a.file_id=b.file_id;
Linux 脚本
##################################################################### ## checkTabsp.sh ## ## This Script will add the new datafile if Tablespace's data ## file, which is greater than the 80% of one datafiles size ##################################################################### #!/bin/bash usedPercentNO=(`sqlplus -s '/as sysdba' <<\EOF SET heading OFF; SET verify OFF; SELECT * FROM tablespace_used_percent; EOF` ) #get the length of array len=${#usedPercentNO[*]} echo "The array has $len members." i=0 while [ $i -lt $len ]; do echo "$i: ${usedPercentNO[$i]}" arrNo=`echo "${usedPercentNO[$i]}" | awk -F. '{print $1}'` if [ -z $arrNo ] then arrNo=1 fi # if usedPercentNo >= 80 then we add new data file,which will have 8G size if [ $arrNo -gt 80 ] then let sigNo=$i+1 sqlplus -s "/ as sysdba" <<EOF ALTER TABLESPACE DB_TABLESPACE ADD DATAFILE '/opt/oracle/oradata/DB/DB_DATA$sigNo.dbf' SIZE 2G AUTOEXTEND ON MAXSIZE 8G; EOF # we need send email to report the tablespace stats info sqlplus -s "/as sysdba" <<\EOF col tablespace_name for a30 col file_name for a60 col auto_extend for a12 col tablespace_name justify center col file_name justify center col autoextend justify right set linesize 200 set pagesize 500 SPOOL tablespace.alert SELECT * FROM TABLESPACE_USAGE; SPOOL OFF; EXIT EOF fi let i++ done #we needn't send email from there the crontab will do if [ `cat tablespace.alert|wc -l` -gt 0 ] then cat tablespace.alert >tablespace.tmp mailx -s "TABLESPACE ALERT for DB" EMAIL-ADDRESS < tablespace.alert fi
上面这个脚本会导致如果有一个文件超过80%的话,脚本会不停添加数据文件....
更新修改后的,而且把sql直接用文本文件来代替了以前使用的view
#!/bin/bash # Managed by Puppet ##################################################################### ## checkTabsp.sh ## ## This Script will add the new datafile if BOCC Tablespace's data ## file, which is greater than the 80% of one datafiles size ##################################################################### # Avoid have the script run if already running source /opt/app/inc/some_functions.sh pgrpfile=/tmp/checkTabsp.pgrp check_if_running # end source /home/oracle/.profile usedDatafileNO=(`sqlplus -s '/as sysdba' <<\EOF SET heading OFF; SET verify OFF; @/opt/app/sql/chktabspused.sql EOF` ) # check whether it needs add data file if [ $usedDatafileNO -eq 0 ] then usedDatNO=(`sqlplus -s '/as sysdba' <<\EOF SET heading OFF; SET verify OFF; @/opt/app/sql/chkdatno.sql EOF` ) let sigNO=$usedDatNO+1 sigNO=`printf "%03d" $sigNO` sqlplus -s "/ as sysdba" <<EOF ALTER TABLESPACE DB_TABLESPACE ADD DATAFILE '/opt/oracle/oradata/DB/DB_DATA$sigNO.dbf' SIZE 500M AUTOEXTEND ON NEXT 50M; EOF # we need send email to report the tablespace stats info to check whether add data file successful sqlplus -s "/as sysdba" <<\EOF col tablespace_name for a30 col file_name for a60 col auto_extend for a12 col tablespace_name justify center col file_name justify center col autoextend justify right set linesize 200 set pagesize 500 @/opt/bocc/sql/chktabspstats.sql EXIT EOF # out put the disk space useage df -h fi #we will don't send email from there the crontab will do # if [ `cat tablespace.alert|wc -l` -gt 0 ] # then # cat tablespace.alert >tablespace.tmp # mailx -s "TABLESPACE ALERT for DB" YOUR_EMAIL_ADDRESS t < tablespace.alert # fi
发表评论
-
PostgreSQL函数:用以查询某表的详细 包含表字段的注释信息
2011-09-07 15:24 15399感谢PostgreSQL论坛阿弟 CREATE OR RE ... -
PostgreSQL 系统表查看系统信息
2011-09-07 15:21 7554摘自http://www.alberton.info/post ... -
Postgresql SQL 使用变量
2010-12-23 17:33 2240begin; select 5::int as var ... -
h2数据库timestamp格式化
2010-10-09 16:17 2497select * from foo2 where FORM ... -
关于设置Postgresql Increment的备份方式
2009-10-19 17:26 1496参考链接: http://hi.baidu.com/top2 ... -
Oracle drop user
2009-09-02 15:26 2493SQL> drop user test cascad ... -
再说Oracle long字段的恢复
2009-09-01 11:38 1518维护的客户系统因为误操作删除了数据,立即进行rman恢复数据到 ... -
Oracle expdp/impdp 导出导出<二>
2009-08-26 16:03 2619由于需要在本地做一下测试,但是由于本地创建oracle和服务器 ... -
Oracle RMAN 增量备份
2009-07-22 10:15 2472在rman增量备份中,有差异增量和累积增量的概念 1、概念 ... -
Oracle执行SQL时遭遇特殊字符&
2009-07-20 14:53 2046转自http://blog.csdn.net/sfdev/ar ... -
Oracle 多行合并一行 方法
2009-06-23 17:59 26440NOTE:特别声明一下内容转自网络 http://www.ni ... -
Oracle Data Dump 导出 --- 很快,很强大
2009-06-23 10:32 8626--- 创建目录,这是必须的 CREATE DIRE ... -
Oracle 10.2.0.1 升级 10.2.0.4失败后处理
2009-06-23 09:21 2266今天将由Oracle 10.2.0.1.0升级为10.2.0. ... -
Oracle查询long字段
2009-06-15 12:49 3493仅供对一些历史表中的long字段的 查询,生成应用还是像ORA ... -
Oracle 函数返回calendar
2009-05-26 17:44 884转自:http://www.planet-source-cod ... -
简单的Postgresql RETURN NEXT 应用
2009-05-26 17:26 2195一个简单的Postgresql的函数,只是简单的列出用户输入时 ... -
Oracle 归档日志
2009-04-28 16:51 1825-- if it cann't be startup norm ... -
Oracle CPU 占用
2009-04-28 16:38 13901. top PID USER PR ... -
Postgresql 更新备忘
2009-02-26 10:52 940关于Postgresql很好用的联合查询更新 BEGIN; ... -
Oracle sqlplus 和 Linux Shell的相互传值
2009-02-04 09:28 3206首先,写一个简单的PLSQL函数,就是简单返回一个拼凑的URL ...
相关推荐
Oracle 应 用进行文件 I/O操作的目录为任意目录 因此 只要空间允许 可以将备份数 据存放到任意目录下 <br>1.2.4 监听配置文件 为了使得外部进程 如 CAMS后台程序 能够访问 Oracle 数据库 必须配 ...
(三)表空间和数据文件 57 (四)什么是自动存储管理 58 七、数据的并发处理 60 (一)锁定的机制 60 (三)锁的队列 60 (四)死锁 62 (五)手动加锁 64 (方式一)lock 语句 64 八、管理还原数据 65 (一)什么...
§1.1.2 表空间与数据文件 24 §1.1.3 Oracle实例(Instance) 24 §1.2 Oracle文件 26 §1.2.1 数据文件 26 §1.2.2 控制文件 26 §1.2.3 重做日志文件 26 §1.2.4 其它支持文件 26 §1.3 数据块、区间和段 28 §...
5.1 了解表空间和数据文件 140 5.1.1 Oracle数据存储模型 140 5.1.2 段、区间、块和行 142 5.1.3 文件存储技术 144 5.2 创建和管理表空间 146 5.2.1 创建表空间 146 5.2.2 更改表空间 150 5.2.3 删除表空间 ...
执行“nomount”,然后打开控制文件,确认数据文件和联机日志文件的位置, 但此时不对数据文件和日志文件进行校验检查。 3、startup open dbname 先执行“nomount”,然后执行“mount”,再打开包括Redo log文件...
表空间和数据文件 1-17 SYSTEM 和 SYSAUX 表空间 1-18 段、区和块 1-19 逻辑和物理数据库结构 1-20 课程示例: HR 方案 1-22 数据库体系结构:结构化组件概要 1-23 小结 1-24 2 安装 Oracle 数据库软件 ...
5.1 了解表空间和数据文件 140 5.1.1 Oracle数据存储模型 140 5.1.2 段、区间、块和行 142 5.1.3 文件存储技术 144 5.2 创建和管理表空间 146 5.2.1 创建表空间 146 5.2.2 更改表空间 150 5.2.3 删除表空间 ...
并确保在同一事务处理种对相同数据的两次查询看到的是相同的值。 值范围: TRUE | FALSE 默认值: FALSE row_locking: 说明: 指定在表已更新或正在更新时是否获取行锁。如果设置为 ALWAYS, 只有在表被更新后才获取...
7. tablespace 表空间:一个或多个数据文件的逻辑组成。 ..... 8. redo log file 重做日志文件............................. 9. control file 控制文件 ................................. 10. parameter file 初始...
实例003 根据表中数据动态生成菜单 实例004 浮动的菜单 1.2 弹出菜单应用实例 实例005 在控件上单击右键弹出菜单 实例006 个性化的弹出菜单 实例007 任务栏托盘弹出菜单 1.3 工具栏应用实例 实例008 带背景...
实例003 根据表中数据动态生成菜单 实例004 浮动的菜单 1.2 弹出菜单应用实例 实例005 在控件上单击右键弹出菜单 实例006 个性化的弹出菜单 实例007 任务栏托盘弹出菜单 1.3 工具栏应用实例 实例008 带背景...
实例005 下载并安装JRE执行环境 8 实例006 编程输出星号组成的等腰三角形 9 1.2 开发工具 11 实例007 下载最新的Eclipse 11 实例008 为最新的Eclipse安装中文语言包 12 实例009 活用Eclipse的工作空间 14 实例010 在...
用JAVA开发的一个小型的目录监视系统,系统会每5秒自动扫描一次需要监视的目录,可以用来监视目录中文件大小及文件增减数目的变化。 Java日期选择控件完整源代码 14个目标文件 内容索引:JAVA源码,系统相关,日历,...
cc实例003 根据表中数据动态生成菜单 cc实例004 浮动的菜单 1.2 弹出菜单应用实例 cc实例005 在控件上单击右键弹出菜单 cc实例006 个性化的弹出菜单 cc实例007 任务栏托盘弹出菜单 ...