這篇文章主要介紹Oracle AWR如何實(shí)現(xiàn)數(shù)據(jù)導(dǎo)入/導(dǎo)出,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、昌黎ssl等。為成百上千家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的昌黎網(wǎng)站制作公司
LINUX狀態(tài)下,連接oracle用戶:su - oracle
1.上傳采集快照.dmp文件至服務(wù)器 (dbid:4292035712) 919219826
2.在服務(wù)器端創(chuàng)建目錄 (即文件夾awrtest)
$> mkdir /home/oracle/awrtest
3.把第一步中上傳的.dmp文件,移動(dòng)到第二步中創(chuàng)建的文件夾中:
$> cp /var/ftp/AWR_10107.dmp(如果原文件后綴名是.DMP一定要改成小寫(xiě).dmp) /home/oracle/awrtest
4.切換至sqlplus狀態(tài),并且啟動(dòng)數(shù)據(jù)庫(kù):
$> sqlplus / as sysdba SQL>startup;
5. 創(chuàng)建數(shù)據(jù)庫(kù)目錄便于數(shù)據(jù)庫(kù)查找
SQL> create directory AWRTEST as '/home/oracle/awrtest';
6.加載數(shù)據(jù)文件:
SQL> @?/rdbms/admin/awrload.sql SQL>Enter value for directory_name: AWRTEST ////注意:輸入directory name 時(shí),字母需要大寫(xiě) Enter value for file_name: AWR_10107 ///注意:此處不要加文件后綴名 Enter value for schema_name: AWR_STAGE //(一般默認(rèn)就行) Enter value for default_tablespace: USERS Enter value for temporary_tablespace: //(回車(chē)默認(rèn))
出現(xiàn)一下文字,就說(shuō)明導(dǎo)入成功了!
... Creating AWR_STAGE user | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Loading the AWR data from the following | directory/file: | /home/oracle/awr | AWRDAT_9239_9394.dmp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | *** AWR Load Started ... | | This operation will take a few moments. The | progress of the AWR load operation can be | monitored in the following directory/file: | /home/oracle/awr | AWRDAT_9239_9394.log | ... Dropping AWR_STAGE user End of AWR Load ----------------------------------------------------------------------------------
報(bào)錯(cuò)癥狀:(注意文件夾復(fù)權(quán)的問(wèn)題?。?/p>
[root@localhost ~]# cd /home/oracle/ [root@localhost oracle]# ls -lt total 660 drwxr-xr-x 2 root root 4096 Aug 6 02:07 awr drwxr-xr-x 2 root root 4096 Aug 6 02:04 awrtest2 -rw-r--r-- 1 oracle oinstall 326088 Jul 8 22:13 zhongxing.html -rw-r--r-- 1 oracle oinstall 311525 Jul 1 12:48 HUAYOUSHIJI.html drwxr-xr-x 3 oracle oinstall 4096 Jul 1 11:32 awrtest1 drwxr-xr-x 2 oracle oinstall 4096 Jul 1 01:10 awrtest drwxr-xr-x 2 oracle oinstall 4096 Jun 30 12:47 jishubu drwxr-xr-x 3 oracle oinstall 4096 Jun 22 14:58 Desktop [root@localhost oracle]# chmod -R 777 awr [root@localhost oracle]# ls -lt total 660 drwxrwxrwx 2 root root 4096 Aug 6 02:07 awr drwxr-xr-x 2 root root 4096 Aug 6 02:04 awrtest2 -rw-r--r-- 1 oracle oinstall 326088 Jul 8 22:13 zhongxing.html -rw-r--r-- 1 oracle oinstall 311525 Jul 1 12:48 HUAYOUSHIJI.html drwxr-xr-x 3 oracle oinstall 4096 Jul 1 11:32 awrtest1 drwxr-xr-x 2 oracle oinstall 4096 Jul 1 01:10 awrtest drwxr-xr-x 2 oracle oinstall 4096 Jun 30 12:47 jishubu drwxr-xr-x 3 oracle oinstall 4096 Jun 22 14:58 Desktop [root@localhost oracle]#
其他報(bào)錯(cuò)問(wèn)題 解決參考地址:
http://space.itpub.net/12129601/viewspace-735524 http://www.xifenfei.com/3966.html 惜分飛 http://blog.163.com/jet_it_life/blog/static/205097083201262431444951/directory 創(chuàng)建不正確導(dǎo)致的ORA-39070 http://www.douban.com/note/37656300/oracle impdp/expdp 的權(quán)限問(wèn)題 http://space.itpub.net/519536/viewspace-664406 侯圣文老師
AWR數(shù)據(jù)遷移參考地址:
春風(fēng): http://www.dbdream.org/?p=223
eygle: AWR 與 Statspack 數(shù)據(jù)的導(dǎo)出與遷移 http://www.eygle.com/archives/2010/08/awr_statspack_extract.html
7.執(zhí)行相關(guān)腳本:(如邏輯讀腳本、db-time腳本等)
查看dbid:
SQL> select dbid from v$database; 223805804 SQL> setpagesize 500 # su - oracle $ cd awrtest/ #根據(jù)自己的安裝目錄確認(rèn) $ ls (查看當(dāng)前目錄下文件,確認(rèn)相關(guān)文件名)
生成邏輯讀-語(yǔ)句:
SELECT case when to_number(to_char(c.end_interval_time, 'mi'))<15 or to_number(to_char(c.end_interval_time, 'mi'))>=45
then to_char(round(c.end_interval_time, 'hh34'),'yyyy-mm-dd hh34:mi')
else to_char(c.end_interval_time, 'yyyy-mm-dd hh34')||':30'
end end_time,
case when max(decode(a.instance_number, 1, a.value - b.value, null))<0 then null
else max(decode(a.instance_number, 1, a.value - b.value, null))
end INST1,
case when max(decode(a.instance_number, 2, a.value - b.value, null))<0 then null
else max(decode(a.instance_number, 2, a.value - b.value, null))
end INST2,
case when max(decode(a.instance_number, 3, a.value - b.value, null))<0 then null
else max(decode(a.instance_number, 3, a.value - b.value, null))
end INST3,
case when max(decode(a.instance_number, 4, a.value - b.value, null))<0 then null
else max(decode(a.instance_number, 4, a.value - b.value, null))
end INST4
FROM sys.wrh$_sysstat a, sys.wrh$_sysstat b, sys.wrm$_snapshot c
WHERE a.stat_id =3143187968
AND b.stat_id = a.stat_id
AND a.snap_id = b.snap_id + 1
AND a.snap_id = c.snap_id
and a.dbid =&dbid
and b.dbid = a.dbid
and c.dbid = a.dbid
and a.instance_number = b.instance_number
and a.instance_number = c.instance_number
group by a.snap_id, case when to_number(to_char(c.end_interval_time, 'mi'))<15 or to_number(to_char(c.end_interval_time, 'mi'))>=45
then to_char(round(c.end_interval_time, 'hh34'),'yyyy-mm-dd hh34:mi')
else to_char(c.end_interval_time, 'yyyy-mm-dd hh34')||':30'
end
ORDER BY a.snap_id;
注意:結(jié)尾的分號(hào)不能少。
生成db-time數(shù)據(jù)語(yǔ)句:
SELECT TO_CHAR(b.end_interval_time, 'yyyy-mm-dd hh34:mi:ss') snap_time,
--'DB Time(s)',
CASE
WHEN (ROUND((a.VALUE - lag(a.VALUE, 1) OVER(ORDER BY a.snap_id)) / 1000000))<0
THEN 0
ELSE ROUND((a.VALUE - lag(a.VALUE, 1) OVER(ORDER BY a.snap_id)) / 1000000)
END AS "db time(s)"
FROM
(SELECT snap_id,
VALUE
FROM dba_hist_sys_time_model
WHERE stat_name = 'DB time'
and dbid=&db_id
AND INSTANCE_NUMBER = &instance_id) a,
dba_hist_snapshot b
WHERE b.dbid=&db_id
AND a.snap_id = b.snap_id
AND b.INSTANCE_NUMBER = &instance_id
--AND b.end_interval_time > sysdate-30
ORDER BY 1;
Enter value for db_id: 4292035712
Enter value for instance_id: 1 ///(單實(shí)例輸入1,RAC 的根據(jù)實(shí)際情況輸入相應(yīng)的值)
Enter value for db_id: 4292035712
Enter value for instance_id: 1
8.導(dǎo)入excel表 ,生成趨勢(shì)圖
excel里邊選擇數(shù)據(jù) -導(dǎo)入-自文本
選擇導(dǎo)入的數(shù)據(jù)-生成曲線圖-雙擊橫坐標(biāo)選擇文本格式
9. 觀察趨勢(shì)圖高峰值,導(dǎo)出AWR報(bào)告,Oracle用戶下執(zhí)行如下命令:
@?/rdbms/admin/awrrpti
導(dǎo)出的AWR報(bào)告有兩種類(lèi)型格式: .txt 和 .html
系統(tǒng)默認(rèn)導(dǎo)出是.html 一般輸入時(shí)間間隔天數(shù):7
按照步驟,連續(xù)操作就行。
Enter value for dbid: 4292035712 Using 4292035712 for database Id Enter value for inst_num: 1(輸入實(shí)例個(gè)數(shù)) Using 1 for instance number
例如:導(dǎo)出時(shí)間點(diǎn)為:7月1日 11點(diǎn) 12點(diǎn) 負(fù)載高峰時(shí)段的AWR數(shù)據(jù)。
注意:在導(dǎo)出報(bào)告時(shí),文件起名時(shí)要手動(dòng)添加后綴名.html
以上是“Oracle AWR如何實(shí)現(xiàn)數(shù)據(jù)導(dǎo)入/導(dǎo)出”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!