os: centos 7.4
db: oracle 12.2.0.1
SQL> alter system set "_allow_level_without_connect_by"=true scope=spfile;
-- linux 内存太大需要使用 hugepage 时,就需要禁用 AMM,降级到 ASMM
-- = integer [K | M | G]
alter system set memory_max_target=0 scope=spfile;
alter system set memory_target=0 scope=spfile;
alter system set sga_max_size=2G scope=spfile;
alter system set sga_target=2G scope=spfile;
alter system set pga_aggregate_limit=2G scope=spfile;
alter system set pga_aggregate_target=2G scope=spfile;
alter system set processes=800 scope=spfile;
alter system set sessions=1500 scope=spfile;
alter system set session_cached_cursors=1000 scope=spfile;
alter system set open_cursors=1000 scope=spfile;
alter system set open_links=100 scope=spfile;
alter system set open_links_per_instance=200 scope=spfile;
alter system set statistics_level=all scope=spfile;
alter system set timed_statistics=true scope=spfile;
alter system set db_block_checking=full scope=spfile;
alter system set db_block_checksum=full scope=spfile;
alter system set db_lost_write_protect=typical scope=spfile;
-- alter system set db_ultra_safe=off scope=spfile;
alter system set db_ultra_safe=DATA_AND_INDEX scope=spfile;
alter system set undo_retention=1440 scope=spfile;
alter system set remote_login_passwordfile='EXCLUSIVE' scope=spfile;
alter system set disk_asynch_io=true scope=spfile;
alter system set db_create_file_dest='+DG_DATA01' scope=spfile;
alter system set db_recovery_file_dest='+DG_FRA' scope=spfile;
alter system set db_recovery_file_dest_size=10G scope=spfile;
-- alter system set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' scope=spfile;
-- alter system set db_recovery_file_dest_size=10G scope=spfile;
alter system set archive_lag_target=600 scope=spfile;
alter system set log_archive_max_processes=10 scope=spfile;
alter system set control_file_record_keep_time=100 scope=spfile;
alter system set db_securefile='ALWAYS' scope=spfile;
alter system set job_queue_processes=1000 scope=spfile;
alter system set dg_broker_start = true scope=spfile;
alter system set dg_broker_config_file1='+dg_fra/dr1orcl.dat' scope=spfile;
alter system set dg_broker_config_file2='+dg_fra/dr2orcl.dat' scope=spfile;
alter system set standby_file_management='AUTO' scope=spfile;
alter system set db_file_name_convert='+dg_data01','+dg_data01','+dg_fra','+dg_fra' scope=spfile;
alter system set log_file_name_convert='+dg_data01','+dg_data01','+dg_fra','+dg_fra' scope=spfile;
alter database enable block change tracking;
SQL> begin
dbms_workload_repository.modify_snapshot_settings(
retention => 30*24*60,
interval => 60
);
end;
/
SQL> col snap_interval format a20;
col retension format a20;
SQL> select * from dba_hist_wr_control;
-- select * from v$log;
-- select * from v$logfile;
-- 每个节点4组,每组两个成员,大小为 512M,分别于 +DG_DATA01 +DG_FRA
-- 文件系统的话需要修改为文件路径
alter database add logfile thread 1 group 5('+DG_DATA01','+DG_FRA') size 512M;
alter database add logfile thread 1 group 6('+DG_DATA01','+DG_FRA') size 512M;
alter database add logfile thread 2 group 7('+DG_DATA01','+DG_FRA') size 512M;
alter database add logfile thread 2 group 8('+DG_DATA01','+DG_FRA') size 512M;
-- 日志切换
alter system switch logfile;
-- active 的日志变为 inactive
alter system checkpoint ;
-- 删除旧的日志组(两节点情况下,默认50M,太小),需要多次循环操作
alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;
alter database drop logfile group 4;
-- 再次添加之前删除的日志组
alter database add logfile thread 1 group 1('+DG_DATA01','+DG_FRA') size 512M;
alter database add logfile thread 1 group 2('+DG_DATA01','+DG_FRA') size 512M;
alter database add logfile thread 2 group 3('+DG_DATA01','+DG_FRA') size 512M;
alter database add logfile thread 2 group 4('+DG_DATA01','+DG_FRA') size 512M;
修改 user profile,防止用户被锁定,无法登陆
SQL> col username format a20;
col ACCOUNT_STATUS format a20;
col PROFILE format a20;
select username,ACCOUNT_STATUS,PROFILE from dba_users where username like '%TEST%';
SQL> col PROFILE format a20;
col RESOURCE_NAME format a30;
col RESOURCE_TYPE format a8;
col LIMIT format a20;
col COMMON format a20;
select * from dba_profiles order by PROFILE,RESOURCE_NAME;
SQL> alter profile default limit FAILED_LOGIN_ATTEMPTS UNLIMITED;
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 password_verify_function null;
SQL> alter session set container=pdb1;
alter profile default limit FAILED_LOGIN_ATTEMPTS UNLIMITED;
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 password_verify_function null;
rman 的一些优化
$ rman target /
RMAN> configure backup optimization on;
configure snapshot controlfile name to '+dg_fra/snapcf_orcl.f';
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '+dg_fra';
RMAN> show all;
RMAN> show snapshot controlfile name;
数据库的调整(RAC需要先关闭一台实例)
# su – oracle
$ sqlplus / as sysdba
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog ;
alter database force logging;
alter database add supplemental log data;
alter database add supplemental log data (all,primary key,unique index,foreign key) columns ;
alter database add supplemental log data for procedural replication;
SQL> alter database open;
alter database flashback on;
# su - grid
$ sqlplus / as sysasm
-- asm 一般都使用AMM,设置为1.5G满足大部分场合,可以适当设置大些
-- = integer [K | M | G]
SQL> alter system set memory_max_target=4G scope=spfile;
alter system set memory_target=4G scope=spfile;
一定要先关闭 rdbms 实例,再重启 asm 实例
asm 磁盘组上存放的备份(如果需要两份备份的话)
# su - grid
$ asmcmd
ASMCMD> cd dg_fra
ASMCMD> mkdir oraclebackup
Controlling Logon Storms
# su - grid
$ vi $ORACLE_HOME/network/admin/sqlnet.ora
TCP.QUEUESIZE=6000