某客户反馈说,在11.2.0.3的rac下,使用sqlplus连接时查询sysdate返回的时间是正确的,但是使用pl/sql等通过listener方式连接的时候,则返回错误的时间。 其实造成这个问题的原因是11.2.0.2后的新特性: 11.2.0.1的时候tz变量取决于grid和root用户的shell环
某客户反馈说,在11.2.0.3的rac下,使用sqlplus连接时查询sysdate返回的时间是正确的,但是使用pl/sql等通过listener方式连接的时候,则返回错误的时间。
其实造成这个问题的原因是11.2.0.2后的新特性:
11.2.0.1的时候tz变量取决于grid和root用户的shell环境变量tz。
但是从11.2.0.2开始,oracle的集群(gi)开始拥有自己的时区和配置,即tz参数存在$grid_home/crs/install/s_crsconfig__env.txt中设置的time zone。
[grid@11gr2 install]$ cat s_crsconfig_11gr2_env.txt### this file can be used to modify the nls_lang environment variable, which determines the charset to be used for messages.### for example, a new charset can be configured by setting nls_lang=japanese_japan.utf8### do not modify this file except to change nls_lang, or under the direction of oracle support servicestz=asia/shanghainls_lang=american_america.al32utf8tns_admin=oracle_base=
一般集群的时区是在安装gi时从系统获取的。经过沟通后,客户确实在前段时间更改过系统时区,至此造成的sysdate返回错误的原因就是因为当操作系统的时区发生改变时,但是gi的时区未改变。
具体修改可以参考mos:how to change timezone for 11gr2 grid infrastructure (doc id 1209444.1)
原文地址:rac环境下sysdate返回错误时间, 感谢原作者分享。