温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

12c 修改操作系统时间会数据库有哪些影响?

发布时间:2020-07-20 18:44:16 来源:网络 阅读:2723 作者:roidba 栏目:关系型数据库

有些时候可能会因为安装数据库不够规范,导致系统时间设置的不正确,我们需要调整系统时间。但是调整系统时间到底会对数据库造成什么影响呢。我们来做几个小实验。

1.测试带有日期字段的表插入操作。

--session 1

SQL> create table t1 (id int,dt date);

Table created.

SQL> insert into t1 values(1,sysdate);

1 row created.

SQL> select * from t1;

        ID DT
---------- -----------------------
         1 09-DEC-2017 10:21:16

--session 2
[root@roidb01 ~]# date
Sat Dec  9 10:21:40 CST 2017
[root@roidb01 ~]# date -s 20:00:00
Sat Dec  9 20:00:00 CST 2017
[root@roidb01 ~]# date
Sat Dec  9 20:00:02 CST 2017

--返回session1
SQL> insert into t1 values(1,sysdate);

1 row created.

SQL> select * from t1;

        ID DT
---------- -----------------------
         1 09-DEC-2017 10:21:16
         1 09-DEC-2017 20:00:09

SQL> 
SQL> insert into t1 values(1,sysdate);

1 row created.

SQL> select * from t1;

        ID DT
---------- -----------------------
         1 09-DEC-2017 10:21:16
         1 09-DEC-2017 20:00:09
         1 09-DEC-2017 19:00:10

这里某些表日期字段使用的sysdate时间的话,时间会根据操作系统时间来插入数据,日期肯定是会变化的,这样很可能造成业务逻辑出现问题,需要注意。

2.测试AWR报告

--修改时间为前一天
[root@roidb01 ~]# date -s 01:00:00
Sat Dec  9 01:00:00 CST 2017
[root@roidb01 ~]# 
[root@roidb01 ~]# date -s "2017-12-08 11:00:00"
Fri Dec  8 11:00:00 CST 2017
[root@roidb01 ~]# date
Fri Dec  8 11:00:01 CST 2017
--AWR报告异常
SQL> @?/rdbms/admin/awrrpt.sql

Current Instance
~~~~~~~~~~~~~~~~

   DB Id    DB Name      Inst Num Instance
----------- ------------ -------- ------------
 1489897299 ORCL                1 orcl

Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
AWR reports can be generated in the following formats.  Please enter the
name of the format at the prompt.  Default value is 'html'.

'html'          HTML format (default)
'text'          Text format
'active-html'   Includes Performance Hub active report

Enter value for report_type: 

Type Specified:                  html

Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   DB Id     Inst Num DB Name      Instance     Host
------------ -------- ------------ ------------ ------------
* 1489897299        1 ORCL         orcl         roidb01

Using 1489897299 for database Id
Using          1 for instance number

Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed.  Pressing <return> without
specifying a number lists all completed snapshots.

Enter value for num_days: 2

Listing the last 2 days of Completed Snapshots

                                                        Snap
Instance     DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
orcl         ORCL                 1 09 Dec 2017 10:14      1
                                  2 09 Dec 2017 10:14      1
                                  3 09 Dec 2017 10:14      1
                                  4 09 Dec 2017 10:14      1
                                  5 09 Dec 2017 19:00      1
                                  6 09 Dec 2017 19:01      1
                                  7 09 Dec 2017 01:02      1
                                  8 09 Dec 2017 01:02      1
                                  9 08 Dec 2017 11:00      1  --变成前一天,时间乱了
                                 10 08 Dec 2017 11:00      1

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 

这里也说明了,修改时间对AWR会有一定影响,尽量时间往后调整。

3.对数据库集群影响
对于Oracle RAC数据库需要各实例时间一致,时间不一致会造成节点down机。

小结:在安装数据库的时候一定要调整好数据库的时间和时区,这个也是必须检查的项目,要按照规范安装数据库,避免不必要的麻烦。如果还有其他影响,大家可以留言,一起交流。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI