幫同事安裝Oracle 11.2.0.4的RAC數據庫用于項目壓力測試,操作系統為red flag server 3版本。今天同事突然來電話說數據庫時間和o
幫同事安裝Oracle 11.2.0.4的RAC數據庫用于項目壓力測試,操作系統為red flag server 3版本。
今天同事突然來電話說數據庫時間和os時間相差16個小時,遇到的問題是,2個節點從本地登陸,查看sysdate和os時間一致,,但是遠程登陸其他節點,數據庫時間和os時間相差16個小時,馬上懷疑是數據庫時區有問題。
經查,數據庫時區確實不是東八區,然后停掉應用程序,著手修改數據庫時區。
alter database set time_zone='+8:00';
然后重新啟動實例,再次查詢,數據庫時區已經修改,但遠程登陸其他節點,數據庫時間和os時間依然相差16小時。
然后執行以下SQL:
select systimezone from dual;
發現顯示的時區為 “-8:00”,為西八區,到這里,問題終于知道出在哪里了。
應該是安裝數據庫時沒有選擇好正確的時區,導致數據庫時間和os時間相差了16個小時,回想當時安裝時選擇的是“一般事物用途”,在配置數據庫參數的時候沒過過多關注數據庫時區的問題,才出現這種錯誤。
那怎么解決呢,多方查找,用以下命令解決:
srvctl setenv database -d
之后重啟數據庫實例,再次遠程登陸其他節點,數據庫時間和os時間已經一致,到此,問題已經解決。同時希望大家不要犯這種類似的錯誤。
下面摘錄網上的一些數據庫時區相關的解釋,以備參考
Dates & Calendars - Frequently AskedQuestions [ID 227334.1]
Why is my SYSDATE time not the same as my system clock on Unix? Sysdate is just a system call to the OS to get the time (a "gettimeofday" call).
Sysdate does NOT use timezones in the database (select dbtimezone, sessiontimezone from dual . But OS (unix level) TZ settings DO alter the time that the OS will pass on to Oracle.
To debug:
telnet to the unix box and connect using sqlplus in the telnet session:
1) once trought the listener using a tnsnames alias
select to_char(sysdate,'DD-MON-YY HH24:MI:SS') from dual;
2) once trough a "local" ORACLE_SID connection
select to_char(sysdate,'DD-MON-YY HH24:MI:SS') from dual;
if the result is different then it means that the listener is started with a different TZ
then you current user env ->; stop and start listener with the TZ you want .
If you are using RAC then use 'srvctl setenv database -d
Oracle 11g RAC 本地時間和通過listener連接時間不相同的問題
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com