关闭11g 新特性 开归档
oracle 11g安装完成需修改:
1、关闭审计
alter system set audit_trail=none scope=spfile sid='*';
防止ORA-03113: 通信通道的文件结尾 错误。
alter system set open_cursors=800 scope=both;
truncate table SYS.AUD$;
禁止sql tuning advisor:
BEGIN
dbms_auto_task_admin.disable(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => NULL);
END;
/
session_max_open_files 12c:
alter system set session_max_open_files=200 scope=spfile; 至少200
12c plsql能够登陆:
sqlnet.ora 添加如下
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
2、修改密码180天期限 和 登录失败次数限制
SELECT * FROM dba_profiles WHERE profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';
select profile,limit from dba_profiles where resource_name='FAILED_LOGIN_ATTEMPTS';
alter profile default limit password_life_time unlimited;
alter profile default limit failed_login_attempts unlimited;
3、禁止数据库级直接路径读,当session很多的时候,频繁的FTS会严重影响SQL性能
应考虑在数据库级别关闭这个功能,尤其是投资这样的多用户OLTP系统
可以将隐含参数 _serial_direct_read 设置成 never 或则
alter system set event= '10949 trace name context forever, level 1' scope=spfile;
4、在创建好数据库后,导入数据前,立刻将参数deferred_segment_creation改成FALSE
alter system set deferred_segment_creation=FALSE scope=both;
5、修改默认日期格式
alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=spfile;
6、改归档
alter system set log_archive_dest_1='location=/oracle/archivelog' scope=spfile sid='*';
alter system set log_archive_dest_1='location=D:appAdministratorarch' scope=spfile sid='*';
alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile sid='*';
su - grid
srvctl stop database -d tzjy
srvctl start database -d tzjy -o mount
7.改 db_files(数据库需要进行修改,最大的数据文件)
ALTER SYSTEM SET db_files=2000 SCOPE=SPFILE;
alter database archivelog;
srvctl start database -d tzjy
alter system archive log current
--查看用户默认表空间
select username,default_tablespace from dba_users;
select TYPE,RECORDS_TOTAL from v$controlfile_record_section;
7.临时表空间
alter tablespace TEMP add tempfile '+datadg' size 5000M;
alter tablespace TEMP add tempfile 'D:appAdministratororadataORCLDATAFILE emp02.dbf' size 5000M autoextend on ;
set lin 140
SELECT d.status "Status", d.tablespace_name "Name", d.CONTENTS "Type",
d.extent_management "Extent Management",
TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99,999,990.900') "Size (M)",
TO_CHAR (NVL (t.BYTES, 0) / 1024 / 1024, '99999999.999')
|| '/'
|| TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99999999.999') "Used (M)",
TO_CHAR (NVL (t.BYTES / a.BYTES * 100, 0), '990.00') "Used %"
FROM SYS.dba_tablespaces d,
(SELECT tablespace_name, SUM (BYTES) BYTES
FROM dba_temp_files
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM (bytes_cached) BYTES
FROM v$temp_extent_pool
GROUP BY tablespace_name) t
WHERE d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = t.tablespace_name(+)
AND d.extent_management LIKE 'LOCAL'
AND d.CONTENTS LIKE 'TEMPORARY';
8.undo表空间:
alter tablespace UNDOTBS1 add datafile '+datadg' size 5000M autoextend on;
alter tablespace UNDOTBS1 add datafile 'D:appAdministratororadataORCLDATAFILEundo02.dbf' size 5000M autoextend on;
alter tablespace UNDOTBS2 add datafile '+datadg' size 5000M autoextend on;
alter database datafile '+DATADG/gzdb/datafile/undotbs1.309.913913585' autoextend on;
col tablespace_name for a20
col file_name for a60
set lin 140
set pagesize 50
with
D as (SELECT TABLESPACE_NAME ,
ROUND(SUM(BYTES)/(1024*1024)) SPACE,
SUM(BLOCKS) BLOCKS
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME),
F as (SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024))
FREE_SPACE FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME),
T as (select distinct TABLESPACE_NAME,AUTOEXTENSIBLE from dba_data_files)
SELECT D.TABLESPACE_NAME,
SPACE "SUM_SPACE(M)" ,
SPACE-NVL(FREE_SPACE,0) "USED_SPACE(M)",
FREE_SPACE "FREE_SPACE(M)" ,
ROUND((1-NVL(FREE_SPACE,0)/SPACE) *100) "USED_RATE(%)",t.AUTOEXTENSIBLE
from D,F,T
WHERE T.TABLESPACE_NAME(+)=D.TABLESPACE_NAME AND D.TABLESPACE_NAME=F.TABLESPACE_NAME(+)
ORDER BY "USED_RATE(%)";
9.日志
10.standby_file_management(默认是auto,异构平台要开启)
alter system set standby_file_management=auto scope=both;
11.asm
PROCESSES 参数会影响ASM 实例,该参数的默认值一般都够用。
如果有多个数据库实例使用同一个ASM 实例,那么就需要修改这个参数,计算方法如下:
PROCESSES = 50 + 50*n
11.show parameter standby_file_management 备库自动建表空间数据文件(默认开启的)。
show parameter standby_file_management;
alter system set show parameter standby_file_management=auto scope=spfile;
-----------------------------------------------------------------------------------
12异步IO(缺省none)
归档量大的,db file 顺序读这个等待相应参数建议修改:
alter system set filesystemio_options=setall scope=spfile;
一般说来,异步I/O是和同步I/O相比较来说的,如果是同步I/O,当一个I/O操作执行时,应用程序必须等待,直到此I/O执行完. 相反,异步I/O操作在后台运行,I/O操作和应用程序可以同时运行,提高了系统性能; 使用异步I/O会提高I/O流量,如果应用是对裸设备进行操作,这种优势更加明显, 因此象数据库,文件服务器等应用往往会利用异步I/O,使得多个I/O操作同时执行
-----业务运行一段时间后,UNDO 大小设置。
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL>
SQL> SELECT undoblks / ((end_time - begin_time) * 86400) "Peak Undo Block Generation"
FROM gv$undostat
WHERE undoblks = (SELECT MAX(undoblks) FROM gv$undostat);
Peak Undo Block Generation
--------------------------
.127147766
SQL> select 0.13*900*8192/1024/1024 G from dual;
G
----------
.9140625
需要0.9G undo
SQL> SELECT tablespace_name, retention FROM dba_tablespaces;
TABLESPACE_NAME RETENTION
------------------------------ -----------
SYSTEM NOT APPLY
SYSAUX NOT APPLY
UNDOTBS1 NOGUARANTEE
TEMP NOT APPLY
USERS NOT APPLY
EXAMPLE NOT APPLY
6 rows selected.
RAC 可能需要结果*2.
查看ORACLE 进程的大小:
select USERNAME,SPID, PGA_ALLOC_MEM/1024/1024 m from v$process;
select USERNAME,sum(PGA_ALLOC_MEM)/1024/1024 m from v$process group by USERNAME;
查看后台进程:
desc v$bgprocess;
13、
在oracle10g的R2环境之后,DISTINCT由于其 HASH UNIQUE的算法导致其不会产生排序,其调整的
ALTER SESSION SET "_gby_hash_aggregation_enabled" = FALSE
--参数修改
--关闭密码大小写敏感:
alter system set sec_case_sensitive_logon=false scope=spfile sid='*';
--设置PASSWORD_LIFE_TIME为unlimit:
alter profile default limit PASSWORD_LIFE_TIME unlimited;
alter profile default limit PASSWORD_LOCK_TIME unlimited;
alter profile default limit PASSWORD_GRACE_TIME unlimited;
alter profile default limit FAILED_LOGIN_ATTEMPTS unlimited;
--设置dump文件最大大小,避免异常时出现超过几十个G的trace,将文件系统撑爆:
alter system set max_dump_file_size='4096M' scope=spfile sid='*';
--调整默认分区大小
--11g分区默认分区大小为8M,这个需要关闭,因为这可以避免提前创建很多未来的分区时,即使是空分区,但是整个表的尺寸已经非常大,出现全分区扫描时,逻辑备份或SQL性能低下:
alter system set "_partition_large_extents"=false scope=spfile sid='*';
--关闭undo_retention的自动调整,BUG较多:
alter system set "_undo_autotune"=false scope=spfile sid='*';
alter system set undo_retention=10800 scope=spfile sid='*';
--手工设置并行子进程的数量上限为CPU个数*2,避免数据库自动算的值太大,并行把资源耗光:
alter system set parallel_max_servers=128 scope=spfile sid='*';
--设置控制文件的保留时间,确保可以恢复到1个月以内的任意一天:
alter system set control_file_record_keep_time=31 scope=spfile sid='*';
--关闭DRM(因DRM导致的问题非常多):
alter system set "_gc_policy_time"=0 scope=spfile sid='*';
alter system set "_gc_undo_affinity"=false sid='*' scope=spfile;
--关闭11g的初始化extent的延迟创建:
alter system set deferred_segment_creation=false scope=spfile sid='*';
--不用result_cache:
alter system set result_cache_max_size=0 scope=spfile sid='*';
--增加实例延迟降级锁的时长为3秒,避免遇到一些导致实例crash的bug,rac可以进行调整:
alter system set "_gc_defer_time"=3 scope=spfile sid='*';
--建议调整AWR时间为2周或以上,便于后期维护:
exec DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(RETENTION=>14*24*60,INTERVAL=>60);
--11g的自适应游标共享可能会带来过多子游标的问题,我们将其关闭:
alter system set "_optimizer_adaptive_cursor_sharing"=false sid='*' scope=spfile;
alter system set "_optimizer_extended_cursor_sharing"=none sid='*' scope=spfile;
alter system set "_optimizer_extended_cursor_sharing_rel"=none sid='*' scope=spfile;
--11g的Cardinality feedback可能会导致执行计划的不稳定:
alter system set "_optimizer_use_feedback"=false sid ='*' scope=spfile;
--设置28401和10949事件,关闭密码错误登录延迟,直接路径读
alter system set event='28401 trace name context forever,level 1','10949 trace name context forever,level 1' sid='*' scope=spfile;
--使并行会话改为使用large pool
alter system set "_PX_use_large_pool"=true sid ='*' scope=spfile;
alter system set "_use_adaptive_log_file_sync"=false sid='*' scope=spfile;