环境:Centos7.9
[root@cent7z ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
1、检查主机名和网络并且配置/etc/hosts文件
关闭防火墙
检查防火墙状态
systemctl status firewalld
#暂时关闭防火墙,下次启动时防火墙仍随系统启动而启动
systemctl stop firewalld
#彻底永久关闭防火墙
systemctl disable firewalld
#关闭SELINUX防火墙!
vi /etc/selinux/config
#将内容
SELINUX=enforcing
#更改为
SELINUX=disabled
2、安装依赖包
yum -y install binutils compat-libcap1 gcc gcc-c++ glibc glibc-devel libaio libaio-devel libgcc libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat compat-libstdc++-33 elfutils-libelf-devel net-tools ksh smartmontools unzip
yum.repos.d]# rpm -q binutils compat-libcap1 gcc gcc-c++ glibc glibc-devel libaio libaio-devel libgcc libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat compat-libstdc++-33 elfutils-libelf-devel net-tools ksh smartmontools unzip
binutils-2.27-44.base.el7_9.1.x86_64
compat-libcap1-1.10-7.el7.x86_64
gcc-4.8.5-44.el7.x86_64
gcc-c++-4.8.5-44.el7.x86_64
glibc-2.17-326.el7_9.x86_64
glibc-devel-2.17-326.el7_9.x86_64
libaio-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.x86_64
libgcc-4.8.5-44.el7.x86_64
libgcc-4.8.5-44.el7.x86_64
libstdc++-4.8.5-44.el7.x86_64
libstdc++-devel-4.8.5-44.el7.x86_64
libXi-1.7.9-1.el7.x86_64
libXtst-1.2.3-1.el7.x86_64
make-3.82-24.el7.x86_64
sysstat-10.1.5-20.el7_9.x86_64
compat-libstdc++-33-3.2.3-72.el7.x86_64
elfutils-libelf-devel-0.176-5.el7.x86_64
net-tools-2.0-0.25.20131004git.el7.x86_64
ksh-20120801-144.el7_9.x86_64
smartmontools-7.0-2.el7.x86_64
unzip-6.0-24.el7_9.x86_64
3、修改LINUX的内核文件sysctl.conf
[root@cent7 yum.repos.d]# vim /etc/sysctl.conf
[root@cent7 yum.repos.d]# sysctl -p
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 = 4294967296
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
fs.aio-max-nr = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
参数说明:
fs.file-max //文件句柄数 一次可以打开文件的个数
kernel.shmall //公式:内存大小102410241024/41024 //表示所有内存大小(单位:页=4K)
kernel.shmmax //表示最大共享内存大小,一般为物理内存的3/4 但是常用的就是将所有内存换算成字节后-1(单位:字节)
kernel.shmmni = 4096 //表示最小共享内存固定4096KB 一般是固定值
kernel.sem //4个参数依次是SEMMSL:每个用户拥有信号量最大数,SEMMNS:系统信号量最大数,SEMOPM:每次semopm系统调用操作数,SEMMNI:系统辛苦量集数最大数。这4个参数为固定内容大小
net.ipv4.ip_local_port_range = 9000 65500 //ip_local_port_range表示端口的范围,为指定的内容 一般是固定值
net.core.rmem_default //表示套接字接收缓冲区大小的缺省值
net.core.rmem_max //表示套接字接收缓冲区大小的最大值。
net.core.wmem_default //表示套接字发送缓冲区大小的缺省值。
net.core.wmem_max //表示套接字发送缓冲区大小的最大值。
参数编辑完成后执行下面的命令
sysctl -p 生成系统参数
4、添加下列参数到/etc/security/limits.conf
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
5、添加下列条目到/etc/pam.d/login
这两个主要是限制使用进程数
vim /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
6、环境变量中添加下列语句
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 使环境变量生效
7、创建文件目录和相应的用户
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
groupadd oinstall --创建 oinstall组 安装数据库软件用
groupadd dba --创建 dba组 管理数据库软件用
groupadd oper --创建 oper组 操作数据库软件用–但是基本用不到。
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01
chmod -R 775 /u01/app/oracle
mkdir -p /u01/app/oracle --级联创建/u01/app/oracle目录
mkdir -p /u01/oraInventory --级联创建oraInventory目录 这个目录下放置的是安装oracle所需要的的环境
chown -R oracle:oinstall /u01 --该命令为把/u01这个目录的所属用户和所属组变为oracle用户和oracle用户所在的oinstall组
chmod -R 775 /u01/app/oracle --该命令为把/u01/app/oracle这个目录的权限改为所属用户可对可写可执行 所属用户所在组下的所有同组成员皆为可读可写可执行 其他用户对这个目录只有可读和可执行
给oracle用户加一个密码
passwd oracle
8、配置ORACLE用户的环境变量
su - oracle
修改oracle用户的环境变量文件
vim .bash_profile
export EDITOR=vi
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=cwai
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/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
参数说明
export EDITOR=vi 默认的编辑器是vi
export TMP=/tmp ORACLE默认的临时目录是/tmp
export TMPDIR=TMP 临时目录生成
export ORACLE_SID=cwai ORACLE实例名称是cwai
export ORACLE_BASE=/u01/app/oracle ORACLE的基本目录
export ORACLE_HOME=ORACLE_BASE/product/12.2.0/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的日期格式 我们使用会话的方式修改 没有上面的NLS_LANG,那么这个参数不会生成
export PATH=ORACLEHOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:ORACLEHOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:PATH:$HOME/bin 生成相关参数
9、上传软件并且解压
ls -lh /u01/soft/linuxx64_12201_*
-rw-r--r-- 1 root root 3.3G Feb 5 18:56 /u01/soft/linuxx64_12201_database.zip
-rw-r--r-- 1 root root 2.8G Feb 5 18:56 /u01/soft/linuxx64_12201_grid_home.zip
10、rlwrap软件配置
yum install readline readline-devel
tar -zxvf rlwrap-0.43.tar.gz
cd rlwrap-0.43 && ./configure
make && make install
su - oracle
vi /home/oracle/.bash_profile
#将下面两行文字粘贴进该文件中即可
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
#添加完内容后保存退出 并执行以下命令来生成环境变量
. /home/oracle/.bash_profile
11、解压安装包并安装
unzip linuxx64_12201_database.zip -d $ORACLE_HOME
#静默安装ORACLE 19C 数据库软件!进入到$ORACLE_HOME下 执行下列命令 那个rsp文件一定要记住被你放到哪了
#修改rsp文件
vim db_install.rsp
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/12.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
DECLINE_SECURITY_UPDATES=true
oracle.install.option=INSTALL_DB_SWONLY
./runInstaller -silent -force -noconfig -ignorePrereq -responseFile /home/oracle/12c_response/db_install.rsp
#root用户执行
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. u01/app/oracle/product/12.2.0/db_1/root.sh
12、创建并启动监听
cd $ORACLE_HOME
netca -silent -responseFile netca.rsp
13、初始化实例
vim dbca.rsp
gdbName=oracle
sid=cwai
characterSet=ZHS16GBK
sysPassword=OraPasswd1
systemPassword=OraPasswd1
oracleHomeUserPassword=oracle
createAsContainerDatabase=true
nationalCharacterSet=UTF8
databaseType=OLTP
datafileDestination=/u01/app/oradata
dbca -createdatabase -silent -responseFile dbca.rsp
Copying database files
1% complete
2% complete
18% complete
33% complete
Creating and starting Oracle instance
35% complete
40% complete
44% complete
49% complete
50% complete
53% complete
55% complete
Completing Database Creation
56% complete
57% complete
58% complete
62% complete
65% complete
66% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/oracle/oracle.log" for further details.
14、监听、数据库状态验证
[oracle@cent7z 12c_response]$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-FEB-2024 22:32:26
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 19-FEB-2024 22:32:25
Uptime 0 days 0 hr. 0 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/cent7z/listener/alert/log.xml
Listening Endpoints Summary...
sqlplus /as sysdba
SQL> select instance_name,status from v$instance;
INSTANCE_NAME
------------------------------------------------
STATUS
------------------------------------
cwai
OPEN
SQL> SELECT name,db_unique_name,open_mode from v$database;
NAME
---------------------------
DB_UNIQUE_NAME
--------------------------------------------------------------------------------
OPEN_MODE
------------------------------------------------------------
ORACLE
oracle
READ WRITE(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=cent7z)(PORT=1521)))
The listener supports no services
The command completed successfully
15、建库、建用户、建表
SQL> conn / as sysdba
Connected.
CREATE TABLESPACE hr LOGGING DATAFILE '/u01/app/oradata/oracle/hr.dbf'
SIZE 100M AUTOEXTEND ON NEXT 32M MAXSIZE 500M EXTENT MANAGEMENT LOCAL;
create temporary tablespace hr_temp tempfile '/u01/app/oradata/oracle/hr_temp.dbf'
size 100m autoextend on next 32m maxsize 500m extent management local;
Tablespace created.
SQL> SQL> 2
Tablespace created.
CREATE USER hr IDENTIFIED BY hr DEFAULT TABLESPACE hr TEMPORARY TABLESPACE hr_temp ;
grant connect,resource to hr;
grant create session to hr;
SQL> grant unlimited tablespace to hr ;
SQL> conn hr/hr
Connected.
SQL> create table test1(name VARCHAR2(20));
Table created.
SQL> insert into test1 values ('ZhangSan');
1 row created.
SQL> insert into test1 values ('Lisi');
1 row created.
SQL> commit ;
Commit complete.
SQL> select * from test1;
NAME
--------------------
ZhangSan
Lisi
至此,oracle12c单机静默安装成功!