Oracle 11g RAC 远程登录数据库时间和os时间相差16小时解决方案

    一个月前帮同事安装11.2.0.4的RAC数据库用于项目压力测试,操作系统为red flag server 3版本。
    今天同事突然来电话说数据库时间和os时间相差16个小时,遇到的问题是,2个节点从本地登陆,查看sysdate和os时间一致,但是远程登陆其他节点,数据库时间和os时间相差16个小时,马上怀疑是数据库时区有问题。
   经查,数据库时区确实不是东八区,然后停掉应用程序,着手修改数据库时区。

  1. alter database set time_zone='+8:00';
   然后重新启动实例,再次查询,数据库时区已经修改,但远程登陆其他节点,数据库时间和os时间依然相差16小时。
   然后执行以下SQL:
    
  1. select systimezone from dual;
发现显示的时区为  “-8:00”,为西八区,到这里,问题终于知道出在哪里了。
应该是安装数据库时没有选择好正确的时区,导致数据库时间和os时间相差了16个小时,回想当时安装时选择的是“一般事物用途”,在配置数据库参数的时候没过过多关注数据库时区的问题,才出现这种错误。
那怎么解决呢,多方查找,用以下命令解决:

  1. srvctl setenv database -d <dbname> -t TZ=EAT-8
之后重启数据库实例,再次远程登陆其他节点,数据库时间和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 ; -t TZ=;' to define the correct TZ.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26705770/viewspace-1201877/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26705770/viewspace-1201877/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值