幫同事安裝Oracle 11.2.0.4的RAC數(shù)據(jù)庫(kù)用于項(xiàng)目壓力測(cè)試,操作系統(tǒng)為red flag server 3版本。今天同事突然來電話說數(shù)據(jù)庫(kù)時(shí)間和o
幫同事安裝Oracle 11.2.0.4的RAC數(shù)據(jù)庫(kù)用于項(xiàng)目壓力測(cè)試,操作系統(tǒng)為red flag server 3版本。
今天同事突然來電話說數(shù)據(jù)庫(kù)時(shí)間和os時(shí)間相差16個(gè)小時(shí),遇到的問題是,2個(gè)節(jié)點(diǎn)從本地登陸,查看sysdate和os時(shí)間一致,,但是遠(yuǎn)程登陸其他節(jié)點(diǎn),數(shù)據(jù)庫(kù)時(shí)間和os時(shí)間相差16個(gè)小時(shí),馬上懷疑是數(shù)據(jù)庫(kù)時(shí)區(qū)有問題。
經(jīng)查,數(shù)據(jù)庫(kù)時(shí)區(qū)確實(shí)不是東八區(qū),然后停掉應(yīng)用程序,著手修改數(shù)據(jù)庫(kù)時(shí)區(qū)。
alter database set time_zone='+8:00';
然后重新啟動(dòng)實(shí)例,再次查詢,數(shù)據(jù)庫(kù)時(shí)區(qū)已經(jīng)修改,但遠(yuǎn)程登陸其他節(jié)點(diǎn),數(shù)據(jù)庫(kù)時(shí)間和os時(shí)間依然相差16小時(shí)。
然后執(zhí)行以下SQL:
select systimezone from dual;
發(fā)現(xiàn)顯示的時(shí)區(qū)為 “-8:00”,為西八區(qū),到這里,問題終于知道出在哪里了。
應(yīng)該是安裝數(shù)據(jù)庫(kù)時(shí)沒有選擇好正確的時(shí)區(qū),導(dǎo)致數(shù)據(jù)庫(kù)時(shí)間和os時(shí)間相差了16個(gè)小時(shí),回想當(dāng)時(shí)安裝時(shí)選擇的是“一般事物用途”,在配置數(shù)據(jù)庫(kù)參數(shù)的時(shí)候沒過過多關(guān)注數(shù)據(jù)庫(kù)時(shí)區(qū)的問題,才出現(xiàn)這種錯(cuò)誤。
那怎么解決呢,多方查找,用以下命令解決:
srvctl setenv database -d
之后重啟數(shù)據(jù)庫(kù)實(shí)例,再次遠(yuǎn)程登陸其他節(jié)點(diǎn),數(shù)據(jù)庫(kù)時(shí)間和os時(shí)間已經(jīng)一致,到此,問題已經(jīng)解決。同時(shí)希望大家不要犯這種類似的錯(cuò)誤。
下面摘錄網(wǎng)上的一些數(shù)據(jù)庫(kù)時(shí)區(qū)相關(guān)的解釋,以備參考
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 本地時(shí)間和通過listener連接時(shí)間不相同的問題
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com