1,开发人员报错
报错现象:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does notexist
进程 ID: 0
会话 ID: 0 序列号: 0
2,原因分析
大概是昨天做的配置修改引起的,因为原来将oracle数据库从idc机房迁移到azure云上,为了保持迁移的稳定性,在云上采用了和idc一样的配置,大概有ds14系列2台、ds13系列 3台、ds12系列3台、A7系列3台、A6系列3台,系统稳定使用了2个月后,老板说费用超支了,让我们酌情需要考虑下是否可以减少开支不然国庆后没得玩了?
其实对于我们dba来说,一般服务器越好故障越少,那么半夜打我们电话也越少啊,也不会因为各种小问题来折腾了,不过老板为了成本考虑,只能降低配置了,在zabbix平台看到两台db的load其实也不是特别高之外,就决定降低配置,将现在所有oracle db的配置都降低一半。由于当时sga和pga没有设置特别大,而且配置降低一半后,sga和pga也够用,oracle都可以正常起来,可以正常使用,后台alert日志也没用报错信息。
结果意外的是,ds12降到ds11的这3台出故障了,应用连接不上,报错。看目前的sga和pga配置基本用完了内存的90%了,看来需要降低sga和pga了。
3,在线调整sga、pga
3.1先调整主库
#(1)在主库上操作,先备份一个pfile sql> create pfile='/oracle/pfile_4.ora' from spfile; File created. #(2)开始在线调整sga、pga sql> alter system set sga_max_size=8192M scope=spfile; System altered. sql> ALTER system SET sga_target=3072M scope=spfile; System altered. sql> #(3)将调整过的保存到启动参数里面 sql> create pfile from spfile; File created. sql> #(4)查看主库的sga、pga配置,调整已经生效了 sql> show parameter sga; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 8G sga_target big integer 3G sql> show parameter pga; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pga_aggregate_target big integer 4940M sql> sql> #(5)这里其实也不用shutdown、startup已经生效了,不过为了验证下,所以我这里做了这个操作 sql> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. sql> startup ORACLE instance started. Total System Global Area 8551575552 bytes Fixed Size 2270360 bytes Variable Size 8120175464 bytes Database Buffers 419430400 bytes Redo Buffers 9699328 bytes Database mounted. Database opened. sql> sql> sql> #(6)再次查看主库的sga、pga配置,重启后,仍然生效 sql> show parameter sga; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 8G sga_target big integer 3G sql> show parameter pga; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pga_aggregate_target big integer 4940M sql> |
3.2再调整备库
# (1)在备库上操作,先备份参数文件 sql> create pfile='/oracle/pfile_4.ora' from spfile; File created. sql> #(2)开始在线调整 sql> alter system set sga_max_size=8192M scope=spfile; System altered. sql> ALTER system SET sga_target=2048M scope=spfile; System altered. sql> sql> create pfile from spfile; File created. sql> #(4)重启备库,验证配置,其实在线生效也不用做shutdown、startup,这里只是验证下 sql> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. sql> sql> sql> startup ORACLE instance started. Total System Global Area 8551575552 bytes Fixed Size 2270360 bytes Variable Size 7247760232 bytes Database Buffers 1291845632 bytes Redo Buffers 9699328 bytes Database mounted. Database opened. sql> # (5)开启备库日志应用 sql> alter database recover managed standby database using current logfile disconnect from session; Database altered. sql> #(6)查看备库的sga、pga配置已经生效 sql> show parameter sga; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 8G sga_target big integer 2G sql> show parameter gpa sql> show parameter pga NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pga_aggregate_target big integer 4940M sql> |
4,验证主库备库数据一致性
4.1在主库上录入测试数据
#(1)在主库创建临时表 sql> create table z_tim(id number); Table created. sql> insert into z_tim values(1); 1 row created. sql> commit; Commit complete. sql> #(2)切换日志 sql> alter system switch logfile; System altered. sql> |
4.2在备库上验证数据
在备库上验证:
# 在备库上查询这个临时表,看到数据存在 sql> select * from z_tim; ID ---------- 1 sql> |
在看归档日志应用情况,已经及时应用过来了:
sql> select sequence#,applied from v$archived_log order by sequence# asc; ………. SEQUENCE# APPLIED ---------- --------- 934 YES 935 YES 936 YES 937 YES 938 IN-MEMORY 918 rows selected. sql> |