Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3672493
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

分类: Oracle

2020-07-17 16:51:59


来自真实世界的生产环境。

准备介质:

Oracle software

LINUX.X64_193000_db_home.zip

Oracle RU

p30783543_190000_Linux-x86-64.zip

(COMBO OF OJVM RU COMPONENT 19.7.0.0.200414 DB RU 19.7.0.0.200414)

Oracle OPatch

p6880880_190000_Linux-x86-64.zip

compat-libstdc++软件

compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

OS WATCHER服务包

oswatcher-8.3.0-1.el7.noarch.rpm

RHEL7.4光盘

rhel-server-7.7-x86_64-dvd.iso


挂载os光盘
mount -r /dev/sr0 /mnt

cat > /etc/yum.repos.d/yum.repo<

[RHEL77]

name=RHEL77

baseurl=file:///mnt

gpgcheck=0

EOF


yum makecache

yum install -y  elfutils* gcc* glibc* libaio* libgcc* libgomp* libstdc* libstdc++-devel* sysstat unixODBC* *libcap* libXp* dstat* compat-* bc unzip smartmontools* mlocate* psmisc* -y


cd /u01/media

rpm -e compat-libstdc++

rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

设置主机名
hostnamectl set-hostname o19c

cat >> /etc/hosts <


XX.XX.1.20         o19c

EOF

设置os参数

cat >> /etc/sysctl.conf <

kernel.shmmax = 137438953472

kernel.shmall = 33554432

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

kernel.panic_on_oops = 1

kernel.randomize_va_space = 0

fs.file-max = 6815744

fs.aio-max-nr = 4194304

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.ipfrag_high_thresh = 16777216

net.ipv4.ipfrag_low_thresh = 15728640

net.ipv4.ipfrag_time = 60

vm.min_free_kbytes = 524288

vm.swappiness = 0

# vm.nr_hugepages = 43008

EOF


sysctl -p

echo "NOZEROCONF=yes" >> /etc/sysconfig/network

setenforce 0

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux

打开用户限制

cat >> /etc/security/limits.conf <


#ORACLE SETTING

* soft memlock unlimited  

* hard memlock unlimited 

 oracle soft nproc   16384

oracle hard nproc   16384

oracle soft nofile  65536

oracle hard nofile  65536

oracle soft stack   10240

EOF

禁用服务

systemctl stop postfix

systemctl stop smartd

systemctl disable firewalld

systemctl disable postfix

systemctl disable smartd
systemctl stop firewalld

systemctl disable firewalld

cat >> /etc/pam.d/login <


#ORACLE SETTING

session required pam_limits.so

EOF

关闭透明大页

sed -i '/GRUB_CMDLINE_LINUX=/ s/"$/ transparent_hugepage=never"/' /etc/default/grub

grub2-mkconfig > /boot/grub2/grub.cfg

groupadd -g 1001 oinstall

groupadd -g 1002 dba

useradd -u 1100 -g oinstall -G dba,oinstall oracle

echo "oracle"|passwd --stdin oracle


mkdir -p /u01/app/oracle

mkdir -p /u01/app/oracle/product/19.3/db_1

chown -R oracle:oinstall /u01

chmod -R 775 /u01

设置用户概要文件

vi ~/.bash_profile


# Oracle 19c oracle Environment                                                                                           

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/19.3/db_1

export ORACLE_SID=ORCL

export TMP=/tmp

export NLS_LANG=american_america.AL32UTF8

export LIBPATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32

export LD_LIBRARY_PATH=$LD_LIBARY_PATH:$ORACLE_HOME/jdk/jre/lib:$ORACLE_HOME/network/lib:$ORACLE_HOME/rdbms/lib

export LD_LIBRARY_PATH=$LD_LIBARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME/lib32

export CLASS_PATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib

export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$HOME/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:.


umask 022

if [ $USER = "oracle" ]; then

if [ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

fi


alias sql='sqlplus / as sysdba'

stty erase ^H

以下用oracle执行

cd /u01/media/

unzip LINUX.X64_193000_db_home.zip -d $ORACLE_HOME/

用root执行
cd /u01/app/oracle/product/19.3/db_1/cv/rpm

rpm -ivh cvuqdisk-1.0.10-1.rpm


静默配置
以oracle执行

vi db.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=oinstall

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=

开始安装
cd $ORACLE_HOME/

./runInstaller -ignorePrereq -silent -force -responseFile /home/oracle/db.rsp 

大概10分钟...

用root执行:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.3/db_1/root.sh

升级psu补丁
mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch_bak

cd /u01/media

unzip p6880880_*.zip -d $ORACLE_HOME/

$ORACLE_HOME/OPatch/opatch version

db的RU:

cd /u01/media/30783543/30869156

$ORACLE_HOME/OPatch/opatch apply

ojvm的RU:
cd /u01/media/30783543/30805684
$ORACLE_HOME/OPatch/opatch apply

检查:
$ORACLE_HOME/OPatch/opatch lspatches

30805684;OJVM RELEASE UPDATE: 19.7.0.0.200414 (30805684)

30869156;Database Release Update : 19.7.0.0.200414 (30869156)

29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399)


建库
vi dbca.rsp


responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0
gdbName=ORCL
sid=ORCL
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/db_1/assistants/dbca/templates/General_Purpose.dbc
sysPassword=
systemPassword= 
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}/
recoveryAreaDestination=
storageType=FS
diskGroupName=
asmsnmpPassword=
recoveryGroupName=
characterSet=ZHS16GBK
nationalCharacterSet=AL16UTF16
registerWithDirService=false
dirServiceUserName=
dirServicePassword=
walletPassword=
listeners=
variablesFile=
variables=ORACLE_BASE_HOME=/u01/app/oracle/product/19.3/db_1,DB_UNIQUE_NAME=ORCL,ORACLE_BASE=/u01/app/oracle,PDB_NAME=,DB_NAME=ORCL,ORACLE_HOME=/u01/app/oracle/product/19.3/db_1,SID=ORCL
initParams=undo_tablespace=UNDOTBS1,sga_target=2340MB,db_block_size=8192BYTES,nls_language=AMERICAN,dispatchers=(PROTOCOL=TCP) (SERVICE=ORCLXDB),diagnostic_dest={ORACLE_BASE},control_files=("/oradata/{DB_UNIQUE_NAME}/control01.ctl", "/oradata/{DB_UNIQUE_NAME}/control02.ctl"),remote_login_passwordfile=EXCLUSIVE,audit_file_dest={ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump,processes=3000,pga_aggregate_target=781MB,nls_territory=AMERICA,open_cursors=300,compatible=19.0.0,db_name=ORCL,audit_trail=db
sampleSchema=false
memoryPercentage=40
databaseType=MULTIPURPOSE
automaticMemoryManagement=false
totalMemory=0

dbca -ignorePreReqs -ignorePrereqFailure -silent -createDatabase -responseFile /home/oracle/dbca.rsp


配置侦听
cd $ORACLE_HOME/network/admin
vi listener.ora 


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORCL)
      (ORACLE_HOME = /u01/app/oracle/product/19.3/db_1)
      (SID_NAME = ORCL)
    )
  )


LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = XX.XX.1.20)(PORT = 1521))
  )


ADR_BASE_LISTENER = /u01/app/oracle


lsnrctl  start

优化数据库参数

alter system set processes=1000 scope=spfile; 

alter system set control_file_record_keep_time=60 scope=spfile sid='*';

alter system set deferred_segment_creation=false scope=spfile sid='*';

alter system set event='43822 trace name context forever,level 1','28401 trace name context forever,level 1','10949 trace name context forever,level 1' scope=spfile sid='*'; 

alter system set max_dump_file_size='1024M' scope=spfile sid='*';

alter system set open_cursors=500 scope=spfile sid='*';

alter system set parallel_max_servers=32 scope=spfile sid='*'; 

alter system set recovery_parallelism=10  scope=spfile sid='*';

alter system set result_cache_max_size=0 scope=spfile sid='*';

alter system set session_cached_cursors=100 scope=spfile sid='*';

alter system set large_pool_size=256m  scope=spfile;

alter system set db_files=1000 scope=spfile;

alter system set "_cleanup_rollback_entries"=10000 scope=spfile sid='*';

alter system set "_datafile_write_errors_crash_instance"=false scope=spfile sid='*';

alter system set "_gc_defer_time"=3 scope=spfile sid='*';

alter system set "_optimizer_use_feedback"=false sid ='*' scope=spfile;

alter system set "_partition_large_extents"=false scope=spfile sid='*';

alter system set "_px_use_large_pool"=true sid ='*' scope=spfile;

alter system set "_sys_logon_delay"=0 sid ='*' scope=spfile;

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;

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;

exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>45*24*60);

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);

ALTER DATABASE ADD LOGFILE GROUP 11 '/oradata/ORCL/redo11.log' size 1G reuse;
ALTER DATABASE ADD LOGFILE GROUP 12 '/oradata/ORCL/redo12.log' size 1G reuse;
ALTER DATABASE ADD LOGFILE GROUP 13 '/oradata/ORCL/redo13.log' size 1G reuse;
ALTER SYSTEM SWTICH LOGFILE;
ALTER SYSTEM SWTICH LOGFILE;
ALTER SYSTEM SWTICH LOGFILE;
ALTER SYSTEM CHECKPOINT;
ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE DROP LOGFILE GROUP 2;
ALTER DATABASE DROP LOGFILE GROUP 3;

ALTER DATABASE DATAFILE 1,2,3 RESIZE 4G;

--切换归档模式
alter system set log_archive_dest_1='location=/arch';
shutdown immediate

startup mount

alter database archivelog;

alter database open;


以root配置osw
rpm -ivh oswatcher-8.3.0-1.el7.noarch.rpm

vi /etc/sysconfig/oswatcher

 # The directory where oswatcher logs should be kept

DATADIR=/u01/oswatcher

# The interval (in seconds) between runs runs of statistics collections

INTERVAL=10

# The maximum age (in hours) of the various log files

MAXAGE=72

# Extra options, for example, "-z gzip" to compress files

OPTIONS=-z gzip

激活服务

systemctl start oswatcher

systemctl enable oswatcher
阅读(2689) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~