--开启强制归档
ALTER DATABASE FORCE LOGGING;
--设置 30分钟 强制归档
ALTER SYSTEM SET ARCHIVE_LAG_TARGET=1800 SCOPE=BOTH SID='*';
--设置期望undo保持时间3h
ALTER SYSTEM SET UNDO_RETENTION=21600 SCOPE=BOTH SID='*';
--关闭UNDO_RETENTION的自动调整
ALTER SYSTEM SET "_undo_autotune"=FALSE SCOPE=BOTH SID='*';
--调整session最大打开cursor数量
ALTER SYSTEM SET OPEN_CURSORS=2000 SCOPE=BOTH SID='*';
--调整trace、alert日志最大为2048m
ALTER SYSTEM SET MAX_DUMP_FILE_SIZE='2048m' SCOPE=BOTH SID='*';
--设置standby file自动管理,DG环境用处大
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO SCOPE=BOTH SID='*';
--db_cache_advice,建议采用手工内存管理,避免系统性能下降
ALTER SYSTEM SET DB_CACHE_ADVICE='off' SCOPE=BOTH SID='*';
--关闭初始化extent的延迟创建功能
ALTER SYSTEM SET DEFERRED_SEGMENT_CREATION=FALSE SCOPE=BOTH SID='*';
--将DDL操作写入alert文件
ALTER SYSTEM SET ENABLE_DDL_LOGGING=TRUE SCOPE=BOTH SID='*';
--db_block_checksum 是对 block 做物理性检查,用于 DBWn 和 direct loader 数据块写入到磁盘时,基于块内的所有字节计算得出一个校验值并将其写入块头.
ALTER SYSTEM SET DB_BLOCK_CHECKSUM=FULL SCOPE=BOTH SID='*';
--启用profile 的 RESOURCE_LIMIT
ALTER SYSTEM SET RESOURCE_LIMIT=TRUE SCOPE=BOTH SID='*';
--禁用资源计划resource_manager_plan
ALTER SYSTEM SET RESOURCE_MANAGER_PLAN='force:' SCOPE=BOTH SID='*';
ALTER SYSTEM SET "_resource_manager_always_off"=TRUE SCOPE=SPFILE SID='*';
--设置控制文件保留1个月信息
ALTER SYSTEM SET CONTROL_FILE_RECORD_KEEP_TIME=31 SCOPE=BOTH SID='*';
--调整job作业能够使用的总进程数
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=100 SCOPE=BOTH SID='*';
--关闭merge join connection
ALTER SYSTEM SET "_optimizer_mjc_enabled"=FALSE SCOPE=BOTH SID='*';
--关闭result_cache查询结果缓存,场景更适用OLAT环境
ALTER SYSTEM SET RESULT_CACHE_MAX_SIZE=0 SCOPE=BOTH SID='*';
--关闭result cache功能启用情况下优化器自适应功能
ALTER SYSTEM SET "_optimizer_ads_use_result_cache" = FALSE SCOPE=BOTH SID='*';
ALTER SYSTEM SET "_optimizer_cartesian_enabled"=FALSE SCOPE=BOTH SID='*';
-- 关闭自适应游标共享参数,12c版本的自适应游标共享(隐藏参数)会带来过多子游标和ORA-04031的问题,为了避免19c遇到同样问题,建议先将其关闭(重启库后生效)。整合考虑建议保持默认值,即:开启自适应游标(默认也开启绑定变量窥探及cursor_sharing=EXACT)
--ALTER SYSTEM SET "_optimizer_adaptive_cursor_sharing"=FALSE SID='*' SCOPE=BOTH;
--ALTER SYSTEM SET "_optimizer_extended_cursor_sharing"=NONE SID='*' SCOPE=BOTH;
--ALTER SYSTEM SET "_optimizer_extended_cursor_sharing_rel"=NONE SID='*' SCOPE=BOTH;
--关闭RAC隐藏参数"_gc_bypass_reader"和 "_gc_read_mostly_lock",为了避免RAC的用户进程卡死在"gc current request"这个数据库内部等待,大多与隐藏参数"_gc_bypass_reader"和 "_gc_read_mostly_lock", 在参数关闭后会发现RAC稳定性提升明显(不会影响性能),同时还发现这两个参数也有其他不少bug,因此建议关闭:
ALTER SYSTEM SET "_gc_bypass_readers"=FALSE SCOPE=BOTH SID='*';
ALTER SYSTEM SET "_gc_read_mostly_locking"=FALSE SCOPE=SPFILE SID='*';
--关闭RAC全局事务支持隐藏参数
ALTER SYSTEM SET "_clusterwide_global_transactions"=FALSE SID='*' SCOPE=SPFILE;
--关闭跨实例并行参数
ALTER SYSTEM SET PARALLEL_FORCE_LOCAL=TRUE SCOPE=BOTH SID='*';
--关闭Cardinality feedback,12c版本的Cardinality feedback可能会导致执行计划的不稳定,为了避免19c发生,建议关闭
ALTER SYSTEM SET "_optimizer_use_feedback"=FALSE SCOPE=BOTH SID='*';
ALTER SYSTEM SET "_partition_large_extents"=FALSE SCOPE=BOTH SID='*';
--alter system set "_optimizer_adaptive_plans"=FALSE scope=spfile sid='*';
ALTER SYSTEM SET OPTIMIZER_ADAPTIVE_PLANS=FALSE SCOPE=BOTH SID='*';
--禁止polling模式和post/wait切换,只使用post/wait模式,否则可能造成CPU占用高
ALTER SYSTEM SET "_use_adaptive_log_file_sync"=FALSE SCOPE=BOTH SID='*';
--加快回滚速度
ALTER SYSTEM SET "_cleanup_rollback_entries"=5000 SCOPE=SPFILE SID='*';
ALTER SYSTEM SET "_rollback_segment_count"=4000 SCOPE=BOTH SID='*';
ALTER SYSTEM SET "_cursor_obsolete_threshold"=1024 SCOPE=SPFILE SID='*';
ALTER SYSTEM SET "_keep_remote_column_size"=TRUE SCOPE=SPFILE SID='*';
--建议启用大池(Large Pool)分配并行进程内存,减少对共享池(Shared Pool)的争用。
ALTER SYSTEM SET "_PX_use_large_pool"=TRUE SCOPE=SPFILE SID='*';
--适当增加shared pool保留比率 5 --> 20
ALTER SYSTEM SET "_shared_pool_reserved_pct"=20 SCOPE=SPFILE SID='*';
--设置审计日志级别,记录SQL语句,禁用设置为none,启用设置为DB或'db,extended'
-- ALTER SYSTEM SET AUDIT_TRAIL=NONE SCOPE=SPFILE SID='*';
-- alter system set audit_trail=db,extended scope=spfile;
--调大数据文件数量上线--RAC要求必须所有节点参数设置一致
ALTER SYSTEM SET DB_FILES=2000 SCOPE=SPFILE SID='*';
-- 28401:使用错误密码登陆尝试会导致很高的Library Cache Locks或row cache lock。
-- 10949:事件用于关闭11g的自动serial direct path read特性,避免出现过多的直接路径读,消耗过多的IO资源。
-- 19823:With Oracle 11.2 and onwards, Oracle will start to purge the files in the FRA when the SPACE_USED reaches 80% of SPACE_LIMIT as specified by the db_recovery_file_dest_size parameter,快速恢复区空间使用率达到90%以后开始删除文件(归档日志),默认80%,调大延迟Oracle删除归档日志
ALTER SYSTEM SET EVENT='10949 trace name context forever, level 1:28401 trace name context forever, level 1:10849 trace name context forever, level 1:19823 trace name context forever, level 90:60025 trace name context forever:10943 trace name context level 2097152' SCOPE=SPFILE SID='*';
--指定并行执行 (并行查询、PDML、并行恢复和复制) 消息的大小,RAC要求必须所有节点参数设置一致
ALTER SYSTEM SET PARALLEL_EXECUTION_MESSAGE_SIZE=32768 SCOPE=SPFILE SID='*';
--调整会话进程上限
ALTER SYSTEM SET PROCESSES=8000 SCOPE=SPFILE SID='*';
--调整每个session 最多可以缓存关闭掉的 cursor 数量
ALTER SYSTEM SET SESSION_CACHED_CURSORS=500 SCOPE=SPFILE SID='*';
--设置异步IO,存在IO性能时建议启用,重启生效
ALTER SYSTEM SET FILESYSTEMIO_OPTIONS=SETALL SCOPE=SPFILE SID='*';
--关闭RAC的DRM(dynamic remastering)特性,避免频繁的DRM使系统性能不稳定、严重的时候使数据库挂起。同时也关闭关闭集群 Undo Affinity,降低集群交互,Read-mostly Locking新特性,这个特性目前会触发大量的BUG,严重时使数据库实例宕掉
ALTER SYSTEM SET "_gc_undo_affinity"=FALSE SCOPE=SPFILE SID='*';
ALTER SYSTEM SET "_gc_policy_time"=0 SCOPE=SPFILE SID='*';
--调整归档日志文件格式
ALTER SYSTEM SET LOG_ARCHIVE_FORMAT = 'arch_%t_%s_%r.arc' SCOPE=SPFILE SID='*';
alter system set "_serial_direct_read"=never scope=both sid='*';
--启用块跟踪,优化增量备份速度
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '+DATA' REUSE;
--回退命令
alter system set "_cleanup_rollback_entries"=100 scope=spfile sid='*';
alter system set "_cursor_obsolete_threshold"=8192 scope=spfile sid='*';
alter system set "_keep_remote_column_size"=true scope=spfile sid='*';
alter system set "_PX_use_large_pool"=FALSE scope=spfile sid='*';
alter system set "_shared_pool_reserved_pct"=5 scope=SPFILE sid='*';
alter system set audit_trail=DB scope=SPFILE sid='*';
ALTER SYSTEM RESET EVENT SCOPE=SPFILE SID='*';
alter system set parallel_execution_message_size=16384 scope=spfile sid='*';
alter system set db_files=200 scope=spfile sid='*';
alter system set processes=6400 scope=spfile sid='*';
alter system set sec_max_failed_login_attempts=3 scope=spfile sid='*';
alter system set session_cached_cursors=50 scope=SPFILE sid='*';
alter system set "_resource_manager_always_off"=FALSE scope=spfile sid='*';
alter system set filesystemio_options=none scope=spfile sid='*';
alter system set LOG_ARCHIVE_FORMAT = '%t_%s_%r.dbf' scope=spfile sid='*';
alter system set "_gc_undo_affinity"=TRUE scope=spfile sid='*';
alter system set "_gc_policy_time"=20 scope=spfile sid='*';
1.crsctl:
查看集群中所有资源状态
crsctl status res -t
守护进程状态:
crsctl status res -t -init
启动/关闭 集群服务:
crsctl start/stop crs
独占模式启动集群:
crsctl start crs -excl -nocrs
检查集群服务状态:
crsctl check crs
集群自启动:
crsctl enable/disable crs
关闭启动指定资源:
crsctl start/stop res res_name //有的无法单独关闭,因为存在资源依赖关系
查看资源属性:
crsctl status res res_name -f
修改资源属性 :
crsctl modify resource res_name -attr
从12c开始crsctl start/stop resource 与 crsctl modify resource 不再支持
但是可以添加-unsupported使用
crsctl modify resource res_name -attr <> -unsupported
crsctl start/stop res res_name -unsupported
----
crsctl start cluster 可以对集群的所有节点资源进行操作。(前提是目标节点OHASD进程必须已经启动)
crsctl start crs 对当前节点的资源进行操作,包含OHAS。
[grid@node1 ~]$ crsctl check cluster
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
[grid@node1 ~]$ crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
----
创建磁盘组:
create diskgroup FLASH_DISK external redundancy disk '/dev/oracleasm/disks/ASMDISK1' ;
查看磁盘组状态:
select name,state from v$asm_diskgroup;
磁盘组挂载与卸载:
alter diskgroup FLASH_DISK mount/dismount;
查看磁盘名与设备的关系:
select name,path from v$asm_disk_stat;
查看每个磁盘组可用大小:
select name,allocation_unit_size,free_mb,total_mb from v$asm_diskgroup;
向磁盘组中增加一个磁盘:
ALTER DISKGROUP ARCH_DISK ADD DISK '/dev/oracleasm/disks/ASMDISK3' (name ARCHDISK2);
从磁盘组中删除一个磁盘:
ALTER DISKGROUP ARCH_DISK DROP DISK ARCHDISK2;
删除一个磁盘组:(确保该磁盘被所有实例所卸载dismount)
drop diskgroup FLASH_DISK;
删除一个有内容的磁盘组:
drop diskgroup ocr2 including contents;
手动重新平衡磁盘组:
ALTER DISKGROUP data2 REBALANCE
ALTER DISKGROUP data2 REBALANCE power 5
如果不指定power,以初始化参数值ASM_POWER_LIMIT为默认值
对于ASM磁盘组兼容性设定为11.2.0.2或更高,值的操作范围是0到1024用于重新平衡能力。
对于ASM磁盘组兼容性设定为小于11.2.0.2,该值的操作范围是0到11。如果ASM_POWER_LIMIT大于11,则使用11.
关闭ASM:
(需要与crs一起关闭) srvctl stop crs