linux shell與sqlplus批量獲取邏輯卷lv大小並開啟datafile自動擴充套件

wisdomone1發表於2013-06-26

-bash-3.2$ more gene.sh
sqlplus  '/ as sysdba'<set pagesize 200 heading off  feedback off
spool /oracle/test.sh
select 'sudo -u root /usr/sbin/lvdisplay '||file_name||'|'||'grep '||''''||'LV Size'||''''||'|'||'awk {'||''''||'print '||'$'||'3'||
''''||'}' from dba_data_files where autoextensible='NO';
spool off
exit
EOF
more test.sh|sed '/^$/d'|sed '/SQL>/d'|sed '/auto/d'>test1.sh&&mv test1.sh test.sh
chmod u+x test.sh
. ./test.sh>rawsize.sql
more rawsize.sql|awk {'print $1-1'}>rawsize1.sql&&mv rawsize1.sql rawsize.sql&&sed -i 's/$/m/g' rawsize.sql

sqlplus '/as sysdba'<set pagesize 200 heading off  feedback off
spool /oracle/alter.sh
select 'alter database datafile '||''''||file_name||''''|| ' autoextend on maxsize  ' from dba_data_files where autoextensible='NO';
spool off
exit
EOF
more alter.sh|sed '/^$/d'|sed '/SQL>/d'>alter1.sh&&mv alter1.sh alter.sh
chmod u+x alter.sh
paste -d '' alter.sh rawsize.sql>final.sql
sed -i 's/$/;/g' final.sql
sqlplus '/as sysdba'<@final.sql
exit
EOF

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-764855/,如需轉載,請註明出處,否則將追究法律責任。

相關文章