1.基础环境配置
关闭防火墙:systemctl disable firewalld
关闭selinux:/etc/selinux/config
更改主机名:
/ect/hosts
192.168.80.148(写自己的ip) oracle19c
1.2.yum安装oracle需要的依赖包
yum install -y bc
yum install -y compat-libcap1*
yum install -y compat-libcap*
yum install -y binutils
yum install -y compat-libstdc+±33
yum install -y elfutils-libelf
yum install -y elfutils-libelf-devel
yum install -y gcc
yum install -y gcc-c++
yum install -y glibc-2.5
yum install -y glibc-common
yum install -y glibc-devel
yum install -y glibc-headers
yum install -y ksh libaio
yum install -y libaio-devel
yum install -y libgcc
yum install -y libstdc++
yum install -y libstdc+±devel
yum install -y make
yum install -y sysstat
yum install -y unixODBC
yum install -y unixODBC-devel
yum install -y binutils*
yum install -y compat-libstdc*
yum install -y elfutils-libelf*
yum install -y gcc*
yum install -y glibc*
yum install -y ksh*
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y make*
yum install -y sysstat*
yum install -y libXp*
yum install -y glibc-kernheaders
yum install -y net-tools-*
1.3.修改linux的内核文件
cat << EOF >> /etc/sysctl.conf
kernel.shmmax = 277495689510912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
fs.file-max = 6815744
kernel.shmall = 67747971072
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
#net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
fs.aio-max-nr = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
EOF
sysctl -p 生效
1.4. 修改limits.conf
cat << 'EOF' >> /etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
EOF
1.5.添加下列条目到/etc/pam.d/login
cat << 'EOF' >> /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF
1.6.在/etc/profil添加下列语句
cat << 'EOF' >> /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
#使环境变量生效
source /etc/profile
2.创建文件和相应的目录
groupadd dba
groupadd oper
groupadd oinstall
useradd -g oinstall -G dba,oper oracle
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/oradata
mkdir -p /u01/oraInventory
chown -R oracle.oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
mkdir -p /u01/app/oracle/product/19c/db_1 #ORACLE的HOME目录
chown -R oracle:oinstall /u01/app/oracle/product/
passwd oracle #增加密码
2.1配置oracle用户环境变量
su - oracle
cat << 'EOF' >> .bash_profile
export EDITOR=vi #默认的编辑器是vi
export TMP=/tmp #ORACLE默认的临时目录是/tmp
export TMPDIR=$TMP #临时目录生成
export ORACLE_SID=orcl #ORACLE实例名称是orcl
export ORACLE_BASE=/u01/app/oracle #ORACLE的基本目录
export ORACLE_HOME=$ORACLE_BASE/product/19c/db_1 #ORACLE数据库的HOME目录
export INVENTORY_LOCATION=/u01/oraInventory #ORACLE安装时的inventory
export TNS_ADMIN=$ORACLE_HOME/network/admin #ORACLE的网络主目录
export LD_LIBRARY_PATH=$ORACLE_HOME/lib # ORACLE的库文件目录
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8" #ORACLE的字符集 不过我们弃用 因为我们使用UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS" #ORACLE的日期格式 我们使用会话的方式修改 弃用
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
umask 022
EOF
source .bash_profile #使环境变量生效
2.2.上传数据库安装包到$ORACLE_HOME
cd /u01/app/oracle/product/19c/db_1/
chown -R oracle:oinstall /u01/app/oracle/product/19c/db_1/LINUX.X64_193000_db_home.zip
解压:
su - oracle
cd /u01/app/oracle/product/19c/db_1/
unzip LINUX.X64_193000_db_home.zip
2.3静默安装配置执行这个db_install.rsp脚本文件
su - oracle
cd /u01/app/oracle/product/19c/db_1/install/response
vim db_install.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_HOME=/u01/app/oracle/product/19c/db_1
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=ROOT
修改完毕之后执行:
cd /u01/app/oracle/product/19c/db_1
./runInstaller -silent -force -noconfig -ignorePrereq -responseFile /u01/app/oracle/product/19c/db_1/install/response/db_install.rsp
注意: 出现两个 orainstRoot.sh 和 root.sh 在开启一个终端进行执行这两个脚本必须在root用户下,直接复制就可以
2.4配置监听netca.rsp
直接执行:
cd /u01/app/oracle/product/19c/db_1/bin
./netca -silent -responsefile /u01/app/oracle/product/19c/db_1/assistants/netca/netca.rsp
lsnrctl start
2.5配置dbca.rsp
##############################################################################
## ##
## DBCA response file ##
## ------------------ ##
## Copyright(c) Oracle Corporation 1998,2019. All rights reserved. ##
## ##
## Specify values for the variables listed below to customize ##
## your installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## can help to populate the variables with the appropriate ##
## values. ##
## ##
## IMPORTANT NOTE: This file contains plain text passwords and ##
## should be secured to have read permission only by oracle user ##
## or db administrator who owns this installation. ##
##############################################################################
#-------------------------------------------------------------------------------
# Do not change the following system generated value.
#-------------------------------------------------------------------------------
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0
#-----------------------------------------------------------------------------
# Name : gdbName
# Datatype : String
# Description : Global database name of the database
# Valid values : <db_name>.<db_domain> - when database domain isn't NULL
# <db_name> - when database domain is NULL
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
gdbName=orcl
#-----------------------------------------------------------------------------
# Name : sid
# Datatype : String
# Description : System identifier (SID) of the database
# Valid values : Check Oracle19c Administrator's Guide
# Default value : <db_name> specified in GDBNAME
# Mandatory : No
#-----------------------------------------------------------------------------
sid=orcl
#-----------------------------------------------------------------------------
# Name : databaseConfigType
# Datatype : String
# Description : database conf type as Single Instance, Real Application Cluster or Real Application Cluster One Nodes database
# Valid values : SI\RAC\RACONENODE
# Default value : SI
# Mandatory : No
#-----------------------------------------------------------------------------
databaseConfigType=SI
templateName=General_Purpose.dbc
#-----------------------------------------------------------------------------
# Name : createAsContainerDatabase
# Datatype : boolean
# Description : flag to create database as container database
# Valid values : Check Oracle19c Administrator's Guide
# Default value : false
# Mandatory : No
#-----------------------------------------------------------------------------
createAsContainerDatabase=false
#-----------------------------------------------------------------------------
# Name : sysPassword
# Datatype : String
# Description : Password for SYS user
# Valid values : Check Oracle19c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
sysPassword=oracle
#-----------------------------------------------------------------------------
# Name : systemPassword
# Datatype : String
# Description : Password for SYSTEM user
# Valid values : Check Oracle19c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
systemPassword=oracle
#-----------------------------------------------------------------------------
# Name : datafileDestination
# Datatype : String
# Description : Location of the data file's
# Valid values : Directory for all the database files
# Default value : $ORACLE_BASE/oradata
# Mandatory : No
#-----------------------------------------------------------------------------
datafileDestination=/u01/app/oracle/oradata
#-----------------------------------------------------------------------------
# Name : storageType
# Datatype : String
# Description : Specifies the storage on which the database is to be created
# Valid values : FS (CFS for RAC), ASM
# Default value : FS
# Mandatory : No
#-----------------------------------------------------------------------------
storageType=FS
#-----------------------------------------------------------------------------
# Name : sampleSchema
# Datatype : Boolean
# Description : Specifies whether or not to add the Sample Schemas to your database
# Valid values : TRUE \ FALSE
# Default value : FASLE
# Mandatory : No
#-----------------------------------------------------------------------------
sampleSchema=TRUE
#-----------------------------------------------------------------------------
# Name : databaseType
# Datatype : String
# Description : used for memory distribution when memoryPercentage specified
# Valid values : MULTIPURPOSE|DATA_WAREHOUSING|OLTP
# Default value : MULTIPURPOSE
# Mandatory : NO
#-----------------------------------------------------------------------------
databaseType=MULTIPURPOSE
#-----------------------------------------------------------------------------
# Name : automaticMemoryManagement
# Datatype : Boolean
# Description : flag to indicate Automatic Memory Management is used
# Valid values : TRUE/FALSE
# Default value : TRUE
# Mandatory : NO
#-----------------------------------------------------------------------------
automaticMemoryManagement=FALSE
#-----------------------------------------------------------------------------
# Name : totalMemory
# Datatype : String
# Description : total memory in MB to allocate to Oracle
# Valid values :
# Default value :
# Mandatory : NO
#-----------------------------------------------------------------------------
totalMemory=4096
执行
cd /u01/app/oracle/product/19c/db_1/bin
./dbca -silent -createDatabase -responseFile /u01/app/oracle/product/19c/db_1/assistants/dbca/dbca.rsp
3.配置完成
sqlplus / as sysdba