oracle19静默安装

1.安装软件包

yum install -y unixODBC gcc- gcc-c++ ksh  compat-libstdc++-33 e2fsprogs e2fsprogs-libs net-tools bc binutils compat-libcap1  elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make net-tools nfs-utils python python-configshell python-rtslib python-six targetcli smartmontools sysstat unzip vim psmisc
rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

2.用户及目录

groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
useradd -u 1002 -g oinstall -G dba,oper oracle 
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/
chmod -R 775 /u01/
rpm -ivh cvuqdisk-1.0.10-1.rpm

3.系统参数配置

cat >>/etc/hosts<<EOF
x.x.x.x  oadb
x.x.x.x  oadg
EOF

cat >> /etc/rc.d/rc.local <<EOF
modprobe hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
EOF

cat >> /etc/sysconfig/network <<EOF
HOSTNAME=oadb
NOZEROCONF=yes GRUB_TIMEOUT=5
EOF

cat >> /etc/security/limits.conf <<EOF
oracle    soft    nproc   16384
oracle    hard    nproc   16384
oracle    soft    nofile  65536
oracle    hard    nofile  65536
oracle    soft    stack   10240
EOF

vim /home/oracle/.bash_profile
export PATH
unset USERNAME
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/db
export ORACLE_SID=oadb
export ORACLE_TERM=xterm
export ORACLE_OWNER=oracle
export ORACLE_UNQNAME=oadb
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:ORACLE_HOME/network/lib:/lib:/usr/lib:/usr/local/lib:$OGG_HOME:.
export PATH=$PATH:/sbin:/usr/lbin:/usr/sbin:$JAVA_HOME/bin:$ORACLE_HOME/bin:$GRID_HOME/bin:$OGG_HOME:$ORACLE_HOME/lib:$HOME/bin:.

### 修改/etc/sysctl.conf
获取分页大小
getconf PAGE_SIZE
4096为4kb

shmmax用于定义单个共享内存段的最大值。设置应该足够大,能在一个共享内存段下容纳下整个的 SGA,建议值为多于物理内存的一半,一般取值大于 SGA_MAX_SIZE 即可
shmmax=32*1024*1024*1024*.64+(1G*1024*1024)=23063974389
vm.nr_hugepages=(32*1024*0.8*0.8)/2+10=10500   此值应略大于SGA

shmall 该参数控制可以使用的共享内存的总页数。 Linux 共享内存页大小为 4KB, 共享内存段的大小都是共享内存页大小的整数倍
shmall=shmmax(KB)/4  或shmmax(byte)/4096
shmall=23063974389/4096=5630852

vm.hugetlb_shm_group= oracle用户的组id
cat >> /etc/sysctl.conf <<EOF
fs.file-max = 6815744
kernel.sem = 5010 641280 5010 128
kernel.shmmni = 4096
kernel.shmmax = 23063974389
kernel.shmall = 5630852
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
vm.nr_hugepages = 10500
vm.hugetlb_shm_group = 54321
EOF

memlock=vm.nr_hugepages * 页的大小=10500*2048=21504000
cat >> /etc/security/limits.conf <<EOF
oralce    soft    memlock   21504000
oracle    hard    memlock   21504000
EOF

关闭透明大页
[root@rac1 boot]# uname -a
Linux rac1 5.4.17-2011.6.2.el7uek.x86_64 #2 SMP Thu Sep 3 14:09:14 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@rac1 ]# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"
重新生成grub配置文件
On BIOS-based machines, issue the following  command  as root:
# grub2-mkconfig -o /boot/grub2/grub.cfg
On UEFI-based machines, issue the following  command  as root:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

4.编辑oracle配置文件

1.软件配置文件

more db_soft.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oper
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
oracle.install.db.rootconfig.executeRootScript=false
oracle.install.db.rootconfig.configMethod=
oracle.install.db.rootconfig.sudoPath=
oracle.install.db.rootconfig.sudoUserName=
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.ConfigureAsContainerDB=false
oracle.install.db.config.PDBName=
oracle.install.db.config.starterdb.characterSet=
oracle.install.db.config.starterdb.memoryOption=false
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.password.PDBADMIN=
oracle.install.db.config.starterdb.managementOption=DEFAULT
oracle.install.db.config.starterdb.omsHost=
oracle.install.db.config.starterdb.omsPort=0
oracle.install.db.config.starterdb.emAdminUser=
oracle.install.db.config.starterdb.emAdminPassword=
oracle.install.db.config.starterdb.enableRecovery=false
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=

2.监听及tns配置文件

more listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = oadb)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME = /u01/app/oracle/product/19.3.0/db)
      (SID_NAME = oadb)
    )
  )
INBOUND_CONNECT_TIMEOUT_LISTENER=2400

more  tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.3.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_OADB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = oadb)(PORT = 1521))


oadb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oadb)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = oadb)
    )
  )

dgdb1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dgdb)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dgdb1)
    )
  )

grep -v "#" sqlnet.ora
sqlnet.expire_time = 10
sqlnet.inbound_connect_timeout = 3600
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
TCP.INVITED_NODES=(oadg,oadb)

3.建库配置文件

more dbca.rsp
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0
gdbName=oadb
sid=oadb
redoLogFileSize=800
databaseConfigType=SI
RACOneNodeServiceName=
policyManaged=false
createServerPool=false
serverPoolName=
cardinality=
force=false
pqPoolName=
pqCardinality=
createAsContainerDatabase=false
numberOfPDBs=0
pdbName=
useLocalUndoForPDBs=true
pdbAdminPassword=
nodelist=
templateName=/u01/app/oracle/product/19.3.0/db/assistants/dbca/templates/General_Purpose.dbc
sysPassword=Oracle_2021%
systemPassword=Oracle_2021%
serviceUserPassword=
emConfiguration=
emExpressPort=5500
runCVUChecks=FALSE
dbsnmpPassword=
omsHost=
omsPort=0
emUser=
emPassword=
dvConfiguration=false
dvUserName=
dvUserPassword=
dvAccountManagerName=
dvAccountManagerPassword=
olsConfiguration=false
datafileJarLocation={ORACLE_HOME}/assistants/dbca/templates/
datafileDestination=/oradata/{DB_UNIQUE_NAME}/datafile/
recoveryAreaDestination=
storageType=FS
diskGroupName=
asmsnmpPassword=
recoveryGroupName=
characterSet=AL32UTF8
nationalCharacterSet=AL16UTF16
registerWithDirService=false
dirServiceUserName=
dirServicePassword=
walletPassword=
listeners=
variablesFile=
variables=ORACLE_BASE_HOME=/u01/app/oracle/product/19.3.0/db,DB_UNIQUE_NAME=oadb,ORACLE_BASE=/u01/app/oracle,PDB_NAME=,DB_NAME=oadb,ORACLE_HOME=/u01/app/oracle/product/19.3.0/db,SID=oadb
initParams=undo_tablespace=UNDOTBS1,sga_target=20972MB,db_block_size=8192BYTES,log_archive_dest_1='LOCATION=/oradata/arch',nls_language=AMERICAN,dispatchers=(PROTOCOL=TCP) (SERVICE=oadbXDB),diagnostic_dest={ORACLE_BASE},control_files=("/oradata/{DB_UNIQUE_NAME}/controlfile/control01.ctl", "{ORACLE_HOME}/dbs/control02.ctl"),remote_login_passwordfile=EXCLUSIVE,audit_file_dest={ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump,processes=3000,pga_aggregate_target=5243MB,nls_territory=AMERICA,local_listener=LISTENER_OADB,open_cursors=1000,log_archive_format=%t_%s_%r.dbf,compatible=19.0.0,db_name=oadb,audit_trail=db
sampleSchema=false
memoryPercentage=
databaseType=OLTP    按需要选择MULTIPURPOSE|DATA_WAREHOUSING|OLTP
automaticMemoryManagement=false
totalMemory=

5.安装软件

mkdir -p $ORACLE_HOME
unzip LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
/u01/app/oracle/product/19.3.0/db/runInstaller -silent -responsefile /soft/db_soft.rsp

Launching Oracle Database Setup Wizard...

The response file for this session can be found at:
 /u01/app/oracle/product/19.3.0/db/install/response/db_2021-08-18_04-12-36PM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2021-08-18_04-12-36PM/installActions2021-08-18_04-12-36PM.log

As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/19.3.0/db/root.sh

Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[oadb]
Execute /u01/app/oracle/product/19.3.0/db/root.sh on the following nodes:
[oadb]


Successfully Setup Software.
Moved the install session logs to:
 /u01/app/oraInventory/logs/InstallActions2021-08-18_04-12-36PM
 
注意已root用户执行上面的脚本

6.静默建库

mkdir -p /oradata/oadb/{datafile,tempfile,onlinelog,controlfile}

/u01/app/oracle/product/19.3.0/db/bin/dbca -silent  -createDatabase -responseFile /soft/dbca.rsp

7.建库后参数调整

参数建议一项一项的调整,防止一下修改多个参数出问题混乱不好定位
1.开启归档
	设置归档路径alter system set log_archive_dest_1='location=/oradata/arch';
	正常关库,shutdown immediate;
	启动至mount,开启归档alter database archivelog;
	启动至open
2.调整内存SGA,PGA
	https://blog.csdn.net/coco3600/article/details/100232524
	pga_aggregate_limit PGA自动管理情况下,限制PGA的最大值,此数值must be between 9000M and 100000G,在自动 PGA 内存管理模式下, Oracle DB 尝试通过动态控制分配给工作区的 PGA 内存量遵从 PGA_AGGREGATE_TARGET 中指定的值。但是,有时候 PGA 内存使用量可能会因为以下原因超过 PGA_AGGREGATE_TARGET 指定的值
	PGA_AGGREGATE_TARGET是一个目标,而不是一个限制
	这里需要注意(SGA+PGA)小于80%的物理内存,不然在启动时会报下面的错误
	PGA_AGGREGATE_TARGET specified is high
	Errors in file /u01/app/oracle/diag/rdbms/oadb/oadb/trace/oadb_ora_25429.trc  (incident=576025):
	ORA-00700: soft internal error, arguments: [pga physmem limit], [5368709120], [4443344691], [], [], [], [], [], [], [], [], []
	Incident details in: /u01/app/oracle/diag/rdbms/oadb/oadb/incident/incdir_576025/oadb_ora_25429_i576025.trc
	
	alter system reset memory_max_target scope=spfile sid='*';
	alter system reset memory_target scope=spfile sid='*';

	alter system set memory_max_target=0 scope=spfile sid='*';
	alter system set memory_target=0 scope=spfile sid='*';
	
	alter system set sga_max_size=16G scope=spfile sid='*';
	alter system set sga_target=16G scope=spfile sid='*';
	alter system set pga_aggregate_target=4G scope=spfile sid='*';

3.按需要调整控制文件,数据文件,redo,template文件的位置(注意权限问题)
	--控制文件
	mkdir -p /oradata/oadb/{controlfile,datafile,onlinelog,tempfile}
	此时数据库状态为open
	alter system set control_files='/oradata/oadb/controlfile/control01.ctl','/u01/app/oracle/product/19.3.0/db/dbs/control02.ctl' scope=spfile;
	shutdown immediate;
	mv /oradata/OADB/datafile/OADB/control01.ctl /oradata/oadb/controlfile/
	mv /oradata/OADB/datafile/OADB/control02.ctl /u01/app/oracle/product/19.3.0/db/dbs/
	启动数据库,startup;
	查看控制文件新路径select name from v$controlfile;
	
	--数据文件
	查看当前文件位置select name from v$datafile;
	正常关闭数据库,shutdown immediate;
	移动数据文件
	mv /oradata/OADB/datafile/OADB/users01.dbf /oradata/oadb/datafile/users01.dbf
	mv /oradata/OADB/datafile/OADB/undotbs01.dbf /oradata/oadb/datafile/undotbs01.dbf
	mv /oradata/OADB/datafile/OADB/system01.dbf  /oradata/oadb/datafile/system01.dbf
	mv /oradata/OADB/datafile/OADB/sysaux01.dbf  /oradata/oadb/datafile/sysaux01.dbf
	mv /oradata/OADB/datafile/OADB/temp01.dbf /oradata/oadb/tempfile/temp01.dbf
	启动至mount,startup mount;
	alter database rename file '/oradata/OADB/datafile/OADB/users01.dbf'   to '/oradata/oadb/datafile/users01.dbf';
    alter database rename file '/oradata/OADB/datafile/OADB/undotbs01.dbf' to '/oradata/oadb/datafile/undotbs01.dbf';
	alter database rename file '/oradata/OADB/datafile/OADB/system01.dbf'  to '/oradata/oadb/datafile/system01.dbf';
	alter database rename file '/oradata/OADB/datafile/OADB/sysaux01.dbf'  to '/oradata/oadb/datafile/sysaux01.dbf';
	alter database rename file '/oradata/OADB/datafile/OADB/temp01.dbf' to '/oradata/oadb/tempfile/temp01.dbf';
	
	--redo文件
	查看当前文件位置
	col MEMBER for a50
	select GROUP#,MEMBER from v$logfile
	正常关库,shutdown immeiate
	移动文件
	mv /oradata/OADB/datafile/OADB/redo*.log /oradata/oadb/onlinelog/
	启动至mount,startup mount;
	alter database rename file '/oradata/OADB/datafile/OADB/redo03.log' to '/oradata/oadb/onlinelog/redo03.log';
	alter database rename file '/oradata/OADB/datafile/OADB/redo02.log' to '/oradata/oadb/onlinelog/redo02.log';
	alter database rename file '/oradata/OADB/datafile/OADB/redo01.log' to '/oradata/oadb/onlinelog/redo01.log';

8.打补丁

以下均为oracle用户操作
--p32399816_190000补丁
	可能会有这个Prerequisite check "CheckSystemCommandAvailable" failed.报错
	root安装软件包即可yum search fuser,yum -y install psmisc.x86_64
	查看补丁信息
	/u01/app/oracle/product/19.3.0/db/OPatch/opatch lsinventory
	关库后备份当前软件目录,shutdown immediate
		tar -czvf /home/oracle/u01.tar.gz /u01/
	解压Opatch包
		mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch.old
		unzip /soft/p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME
	解压补丁包
		 unzip /soft/p32399816_190000_Linux-x86-64.zip -d /soft/    
	打补丁
		正常关闭数据库,shutdown immediate
		cd /soft/32399816
		/u01/app/oracle/product/19.3.0/db/OPatch/opatch apply 期间需要键入的一直输入y
		
Verifying environment and performing prerequisite checks...
Prerequisite check "CheckSystemCommandAvailable" failed.
The details are:
Missing command :fuser
UtilSession failed:
Prerequisite check "CheckSystemCommandAvailable" failed.
这个错误,安装psmic包即可
		
		以upgrage模式启动数据库,startup upgrade
		cd $ORACLE_HOME/OPatch
		./datapatch -verbose
		待此项结束
		cd $ORACLE_HOME/rdbms/admin
		sqlplus / as sysdba
		@utlrp.sql
		shutdown
--p32545008_190000补丁
	解压补丁
		unzip /soft/p32545008_190000_Linux-x86-64.zip -d /soft/
	打补丁
		cd /soft/32545008/32545013
		/u01/app/oracle/product/19.3.0/db/OPatch/opatch apply 期间需要键入的一直输入y
		以upgrage模式启动数据库,startup upgrade
		cd $ORACLE_HOME/OPatch
		./datapatch -verbose
		待此项结束
		cd $ORACLE_HOME/rdbms/admin
		sqlplus / as sysdba
		@utlrp.sql
		shutdown

9.修改其他参数

执行19alterprofile.sh脚本

sqlplus / as sysdba <<!
spool 19c_profile.log
alter system set "_b_tree_bitmap_plans"=false scope=spfile sid='*';
alter system set "_bloom_filter_enabled"=FALSE scope=spfile sid='*';
alter system set "_cleanup_rollback_entries"=5000 scope=spfile sid='*';
alter system set "_datafile_open_errors_crash_instance"=false scope=spfile sid='*';
alter system set "_datafile_write_errors_crash_instance"=false scope=spfile sid='*';
alter system set "_cursor_obsolete_threshold" =1024 scope=spfile sid='*';
alter system set "_drop_stat_segment" =1 scope=spfile sid='*';
alter system set "_keep_remote_column_size"=TRUE scope=spfile sid='*';
alter system set "_optimizer_ads_use_result_cache" = FALSE scope=spfile sid='*';
alter system set "_optimizer_extended_cursor_sharing"='NONE' scope=spfile sid='*';
alter system set "_optimizer_extended_cursor_sharing_rel"='NONE' scope=spfile sid='*';
alter system set "_optimizer_adaptive_cursor_sharing"=FALSE  scope=spfile sid='*';
alter system set "_optimizer_mjc_enabled"=FALSE scope=spfile sid='*';
alter system set "_optimizer_unnest_scalar_sq"=false scope=spfile sid='*';
alter system set "_optimizer_use_feedback"=false scope=spfile sid='*';
alter system set "_partition_large_extents"=FALSE scope=spfile sid='*';
alter system set "_PX_use_large_pool"=TRUE scope=spfile sid='*';
alter system set "_rollback_segment_count"=2000 scope=spfile sid='*';
alter system set "_sql_plan_directive_mgmt_control"=0 scope=spfile sid='*';
alter system set "_undo_autotune"=FALSE scope=spfile sid='*';
alter system set "_use_adaptive_log_file_sync"=FALSE scope=spfile sid='*';
alter system set "_shared_pool_reserved_pct"=20 scope=spfile sid='*';
alter system set "_clusterwide_global_transactions"=FALSE scope=spfile sid='*';
alter system set "_gc_policy_time"=0 scope=spfile sid='*';
alter system set "_gc_undo_affinity"=FALSE scope=spfile sid='*';
alter system set result_cache_max_size= 0  scope=spfile sid='*'; 
alter system set control_file_record_keep_time=31 scope=spfile sid='*';
alter system set db_cache_advice=off scope=spfile sid='*';
alter system set db_files=5000 scope=spfile sid='*';
alter system set deferred_segment_creation=false scope=spfile sid='*';
alter system set enable_ddl_logging=true scope=spfile sid='*';
alter system set event='10949 trace name context forever:28401 trace name context forever, level 1:10849 trace name context forever, level 1:19823 trace name context forever, level 90' scope=spfile sid='*';
alter system set parallel_force_local=true scope=spfile sid='*';
alter system set resource_manager_plan='force:' scope=spfile sid='*';
alter system set sec_max_failed_login_attempts=100 scope=spfile sid='*';
alter system set parallel_execution_message_size=32768 scope=spfile sid='*';
alter system set archive_lag_target=1800 scope=spfile sid='*';
alter system set "_securefiles_concurrency_estimate"=50 scope=spfile sid='*';
alter system set "_smu_debug_mode"=134217728 scope=spfile sid='*';
alter system set "_optimizer_enhanced_join_elimination"=false scope=spfile sid='*';
alter system set "_and_pruning_enabled"=false scope=spfile sid='*';
alter system set "_optimizer_partial_join_eval"=false  scope=spfile sid='*';
alter system set "_optimizer_cartesian_enabled"=FALSE  scope=spfile sid='*';
alter system set "_use_single_log_writer"=FALSE scope=spfile sid='*';
ALTER SYSTEM SET optimizer_adaptive_plans=FALSE scope=spfile sid='*';
alter system set audit_trail=none scope=spfile sid='*';
alter system set session_cached_cursors=200 scope=spfile sid='*';
alter system set undo_retention=10800 scope=spfile sid='*';
alter system set use_large_pages=only scope=spfile sid='*';
alter system set parallel_max_servers=128 scope=spfile sid='*';
alter system set "_serial_direct_read"=never scope=spfile sid='*';
alter system set "_ges_direct_free_res_type" =CTARAHDXBB scope=spfile sid='*';
alter system set "_ksmg_granule_size"=33554432 scope=spfile sid='*';
alter system set "_optimizer_dsdir_usage_control" =0 scope=spfile sid='*';
alter system set "_enable_numa_optimization"=false scope=spfile sid='*';
alter system set "_enable_pdb_close_abort"=true scope=spfile sid='*';
alter system set "_enable_pdb_close_noarchivelog"=false scope=spfile sid='*';
alter system set "_index_partition_large_extents"=true scope=spfile sid='*';
alter system set "_optimizer_aggr_groupby_elim"=false scope=spfile sid='*';
alter system set "_optimizer_reduce_groupby_key"=false scope=spfile sid='*';
alter system set "_part_access_version_by_number"=true scope=spfile sid='*';
alter system set "_report_capture_cycle_time"=0 scope=spfile sid='*';
alter system set autotask_max_active_pdbs=40 scope=spfile sid='*';
alter system set "_lm_sync_timeout"=1200 scope=spfile sid='*';
alter system set "_lm_tickets"=5000 scope=spfile sid='*';
alter system set shared_servers=30 scope=spfile sid='*';
alter system set max_shared_servers=300 scope=spfile sid='*';
----
alter profile default limit PASSWORD_LIFE_TIME UNLIMITED;
alter profile default limit IDLE_TIME UNLIMITED;
alter profile ORA_STIG_PROFILE limit PASSWORD_LIFE_TIME UNLIMITED;
alter profile ORA_STIG_PROFILE limit IDLE_TIME UNLIMITED;
alter profile GSM_PROF limit PASSWORD_LIFE_TIME UNLIMITED;
alter profile GSM_PROF limit IDLE_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;
alter profile ORA_STIG_PROFILE limit PASSWORD_LOCK_TIME UNLIMITED;
alter profile ORA_STIG_PROFILE limit PASSWORD_GRACE_TIME UNLIMITED;
alter profile ORA_STIG_PROFILE limit FAILED_LOGIN_ATTEMPTS UNLIMITED;
alter profile GSM_PROF limit PASSWORD_LOCK_TIME UNLIMITED;
alter profile GSM_PROF limit PASSWORD_GRACE_TIME UNLIMITED;
alter profile GSM_PROF limit FAILED_LOGIN_ATTEMPTS UNLIMITED;
----
exec dbms_auto_task_admin.disable(client_name=>'sql tuning advisor',operation=>NULL,window_name=>NULL);
exec dbms_auto_task_admin.disable(client_name=>'auto space advisor',operation=>NULL,window_name=>NULL);
--
spool off;
exit
!

10.巡检及备份脚本

备份

[oracle@oadb ~]$ crontab -l

20 00 * * * /home/oracle/scripts/rman_increbackup.sh

mkdir -p /backup/rman/ctlbak

rman target /

show all;

CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/rman/%F';

PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
unset USERNAME
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/db
export ORACLE_SID=oadb
export ORACLE_TERM=xterm
export ORACLE_OWNER=oracle
export ORACLE_UNQNAME=oadb
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:ORACLE_HOME/network/lib:/lib:/usr/lib:/usr/local/lib:$OGG_HOME:.
export PATH=$PATH:/sbin:/usr/lbin:/usr/sbin:$JAVA_HOME/bin:$ORACLE_HOME/bin:$GRID_HOME/bin:$OGG_HOME:$ORACLE_HOME/lib:$HOME/bin:.
export PATH

#incremental backup
dorman()
{
RMAN_LEVEL=$1
LOG=rman_`date +%Y%m%d`.log
#rman target sys/oracle@oadb log $LOG<<EOF
rman target /  log $LOG<<EOF
run {
allocate channel c1 type disk;
sql 'alter system archive log current';
backup
 as compressed backupset incremental level ${RMAN_LEVEL}
     skip inaccessible filesperset 5
       Database format='${BAK_PATH}/oadb_lev${RMAN_LEVEL}_%U_%T' tag='oadb_lev${RMAN_LEVEL}' ;
sql 'alter system archive log current';
backup format '${BAK_PATH}/arch_%s_%p_%t.bak'
  filesperset 5
    archivelog UNTIL TIME 'sysdate' not backed up 1 times;
delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-1' backed up 1 times to device type disk;
backup current controlfile tag='bak_ctlfile' format='${BAK_PATH}/ctl_file_${MY_DATE}%U.ctl';
backup spfile tag='spfile' format='${BAK_PATH}/oadb_spfile_%U_%T';

crosscheck backup;
delete noprompt obsolete;
delete noprompt expired backup;
crosscheck archivelog all;
delete noprompt expired archivelog all;
release channel c1;
}
exit
EOF
}

cd /backup/rman
find /backup/rman -type d -name "20*" -mtime +3 -exec rm -rf {} \;
MY_DATE=`date +%Y%m%d`
if [ ! -d "${MY_DATE}" ];then
  mkdir ${MY_DATE}
fi
cd /backup/rman/${MY_DATE}
touch rman_time.log
begin_time=`date "+%Y-%m-%d %H:%M:%S"`
echo "begin rman time:" $begin_time>>rman_time.log
current_week=`date +%w`
BAK_PATH=`pwd`
export BAK_PATH

case $current_week in
0)
dorman 0
;;
1|2|4|5|6)
dorman 2
;;
3)
dorman 1
;;
esac
cp /backup/rman/c-* /backup/rman/${MY_DATE}
mv /backup/rman/c-* /backup/rman/ctlbak/
end_time=`date "+%Y-%m-%d %H:%M:%S"`
echo "end rman time:"+ $end_time>>rman_time.log
#/bin/bash /home/oracle/scripts/scpFile.sh

巡检

unset USERNAME
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/db
export ORACLE_SID=oadb
export ORACLE_TERM=xterm
export ORACLE_OWNER=oracle
export ORACLE_UNQNAME=oadb
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:ORACLE_HOME/network/lib:/lib:/usr/lib:/usr/local/lib:$OGG_HOME:.
export PATH=$PATH:/sbin:/usr/lbin:/usr/sbin:$JAVA_HOME/bin:$ORACLE_HOME/bin:$GRID_HOME/bin:$OGG_HOME:$ORACLE_HOME/lib:$HOME/bin:.

echo "********************xunjian begin time is  `date '+%Y%m%d%H%M%S'`********************"
echo "****************************server info**********************************************"
hostname
df -h
echo "**************************** DATABASE info****************************************"
tail -200 /u01/app/oracle/diag/rdbms/oadb/oadb/trace/al*


sqlplus / as sysdba <<!
set linesize 200
col file_name for a60
col tablespace_name for a20
col member for a50
col name for a50
col default for a20
select a.tablespace_name tbsname,total summb,(total-free) usedmb,free freemb,
    round((total-free)*100/total) pctused,round(free*100/total) pctfreed,
case
when a.maxmb = 0
then a.total
else a.maxmb
end "MAXBYTES"
                       from (select tablespace_name,round(sum(bytes)/1024/1024) total,round(sum(MAXBYTES)/1024/1024) maxmb from dba_data_files   group by tablespace_name
 ) a,
                            (select tablespace_name,round(sum(bytes)/1024/1024) free from dba_free_space  group by tablespace_name )
 b
where a.tablespace_name=b.tablespace_name order by 5 desc;
select tablespace_name,file_id,file_name,bytes/1024/1024,autoextensible,maxbytes/1024/1024,increment_by from dba_data_files;
select tablespace_name,file_id,file_name,bytes/1024/1024,autoextensible,maxbytes/1024/1024,increment_by from dba_temp_files;
select * from v\$logfile;
select name,block_size,file_size_blks from v\$controlfile;
select sum(bytes)/1024/1024/1024 Gb from dba_segments;
select instance_name,status from gv\$instance;
select db_unique_name,database_role,switchover_status,protection_mode,open_mode from v\$database;
select thread#,instance_name from gv\$instance;
select thread#,dest_id,max(sequence#) from v\$archived_log group by thread#,dest_id order by thread#;
select name,physical_reads,db_block_gets,consistent_gets,
(1-round((physical_reads/(db_block_gets+consistent_gets)),4))*100||'%' "HIT RATIO"
from v\$buffer_pool_statistics where name='DEFAULT';

select segment_name,SEGMENT_GB from (select segment_name,sum(bytes)/1024/1024/1024 SEGMENT_GB from dba_segments where owner='PAYMENT' and segment_type='TABLE' group by segment_name order by 2) where SEGMENT_GB >=1;
--select count(*) as "FUNDIN201804 sumrows" from payment.FUNDIN201804;
exit
!
相关推荐
学Linux的语莫10 分钟前
搭建服务器VPN,Linux客户端连接WireGuard,Windows客户端连接WireGuard
linux·运维·服务器
legend_jz14 分钟前
【Linux】线程控制
linux·服务器·开发语言·c++·笔记·学习·学习方法
Komorebi.py15 分钟前
【Linux】-学习笔记04
linux·笔记·学习
黑牛先生17 分钟前
【Linux】进程-PCB
linux·运维·服务器
友友马35 分钟前
『 Linux 』网络层 - IP协议(一)
linux·网络·tcp/ip
猿java1 小时前
Linux Shell和Shell脚本详解!
java·linux·shell
安迁岚2 小时前
【SQL Server】华中农业大学空间数据库实验报告 实验九 触发器
数据库·sql·mysql·oracle·实验报告
A.A呐2 小时前
【Linux第一章】Linux介绍与指令
linux
Gui林2 小时前
【GL004】Linux
linux
ö Constancy2 小时前
Linux 使用gdb调试core文件
linux·c语言·vim