前期工作:在安装centos7.9的时候,网卡名称为eth0,修改内核选项:net.ifnames=0 biosdevname=0

安装常用工具和依赖

yum -y install vim tar net-tools wget perl python3 readline* deltarpm python-deltarpm \

zip unzip bc compat-libcap1* compat-libcap* binutils compat-libstdc++-33 \

elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc-2.5 glibc-common glibc-devel \

glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat \

unixODBC unixODBC-devel binutils* compat-libstdc* elfutils-libelf* \

gcc* glibc* ksh* libaio* libgcc* libstdc* make* sysstat* libXp* glibc-kernheaders

绑定主机名和IP映射

修改主机名

hostnamectl set-hostname oracle

绑定主机名和IP映射

vim /etc/hosts

192.168.136.141 oracle

vim /etc/sysctl.conf

fs.file-max = 6815744

fs.aio-max-nr = 1048576

kernel.shmall = 67747971072

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

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.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

net.ipv4.conf.all.rp_filter = 2

net.ipv4.conf.default.rp_filter = 2

net.core.somaxconn = 262144

生效  sysctl  -p 

vim /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

vim /etc/pam.d/login 追加

session required /lib/security/pam_limits.so

session required pam_limits.so

vim /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

生效  source /etc/profile

groupadd oinstall

groupadd dba

groupadd oper

useradd -g oinstall -G dba,oper oracle

passwd oracle

mkdir -p /u01/app/oracle /u01/oraInventory /u01/app/oracle/product/19c/db_1  

chown -R oracle:oinstall /u01

chmod -R 775 /u01/app/oracle

su - oracle

vim .bash_profile 追加

export EDITOR=vim

export TMP=/tmp  

export TMPDIR=$TMP

export ORACLE_SID=orcl

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/19c/db_1

export INVENTORY_LOCATION=/u01/oraInventory

export TNS_ADMIN=$ORACLE_HOME/network/admin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"

export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin

umask 022

生效  source .bash_profile

Oracle安装包下载地址

https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html

CentOS7.9 静默方式安装 Oracle19C_oracle

Oracle安装包上传至$ORACLE_HOME路径下

chown -R oracle:oinstall LINUX.X64_193000_db_home.zip

su - oracle

cd $ORACLE_HOME

cd /u01/app/oracle/product/19c/db_1

unzip LINUX.X64_193000_db_home.zip

静默安装分为3步:

  1. 安装软件
  2. 创建监听
  3. DBCA创建数据库

以上3步分别需要三个配置文件,创建存放该3个文件的目录

mkdir /home/oracle/rsp

chown -R oracle:oinstall /home/oracle/rsp

vim /home/oracle/rsp/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/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=dba

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

以上是db_install.rsp文件

chown -R oracle:oinstall /home/oracle/rsp/db_install.rsp

cd $ORACLE_HOME

./runInstaller -silent -force -noconfig -ignorePrereq -responseFile /home/oracle/rsp/db_install.rsp

需要使用root用户依次执行以下两个脚本

/u01/oraInventory/orainstRoot.sh

/u01/app/oracle/product/19c/db_1/root.sh

根据提示检查日志文件

more /u01/app/oracle/product/19c/db_1/install/root_oracle_2023-07-02_20-31-10-709893947.log

vim /home/oracle/rsp/netca.rsp

[GENERAL]

RESPONSEFILE_VERSION="19.0"

CREATE_TYPE="CUSTOM"

[oracle.net.ca]

INSTALLED_COMPONENTS={"server","net8","javavm"}

INSTALL_TYPE=""typical""

LISTENER_NUMBER=1

LISTENER_NAMES={"LISTENER"}

LISTENER_PROTOCOLS={"TCP;1521"}

LISTENER_START=""LISTENER""

NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}

NSN_NUMBER=1

NSN_NAMES={"EXTPROC_CONNECTION_DATA"}

NSN_SERVICE={"PLSExtProc"}

NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}


chown -R oracle:oinstall /home/oracle/rsp/netca.rsp

netca -silent -responsefile /home/oracle/rsp/netca.rsp

lsnrctl status

静默创建数据库

vim /home/oracle/rsp/dbca.rsp

responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0

gdbName=orcl

sid=orcl

databaseConfigType=SI

templateName=General_Purpose.dbc

createAsContainerDatabase=false

sysPassword=oracle

systemPassword=oracle

datafileDestination=/u01/app/oracle/oradata

storageType=FS

sampleSchema=TRUE

databaseType=OLTP

automaticMemoryManagement=FALSE

totalMemory=4096


chown -R oracle:oinstall /home/oracle/rsp/dbca.rsp

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

安装完成可以查看/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log文件,检查安装细节

安装rlwrap

tar -zxvf rlwrap-0.45.2.tar.gz

cd rlwrap-0.45.2

./configure

make -j8

make install

su - oracle

vim /home/oracle/.bash_profile 追加

alias sqlplus='rlwrap sqlplus'

alias rman='rlwrap rman'

alias lsnrctl='rlwrap lsnrctl'

生效: source /home/oracle/.bash_profile

sqlplus连接数据库 使用oracle用户操作

sqlplus / as sysdba 1 conn / as sysdba; 1 select userenv('language') from dual; 1 select * from nls_database_parameters; 1 select * from VCentOS7.9 静默方式安装 Oracle19C_oracle_02instance; 1 alter user hr account unlock; 1 alter user hr identified by hr; 1 conn hr/hr; 1 set linesize 300; 1 set pagesize 300; 1 conn sys/oracle@orcl as sysdba; 1 conn hr/hr@orcl; 1 select tname from tab; 1

关闭监听

lsnrctl stop 1 2 -- 关闭数据库 shutdown immediate; 1 2 -- 开启数据库 startup; 1 2

关闭监听

lsnrctl start 1 2 开发防火墙端口 使用root用户

firewall-cmd --zone=public --add-port=1521/tcp --permanent 1 firewall-cmd --reload 1 –zone #作用域 –add-port=1521/tcp #添加端口,格式为:端口/通讯协议 –permanent #永久生效,没有此参数重启后失效

sql-developer连接oracle 使用sys账户连接orcl实例