linux下静默方式安装oracle 19c

安装前准备工作

一、安装相关依赖包

1
2
3
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel

yum -y install compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc-devel ksh libaio-devel libaio-devel sysstat elfutils-libelf-devel fontconfig-devel libxcb smartmontools libX11 libXau libXtst libXrender libXrender-devel

二、修改内核参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(root身份,没有的自行添加)
vi /etc/sysctl.conf
kernel.shmall = 2097152 //表示系统一次可以使用的共享内存总量(以页为单位)。缺省值就是2097152,通常不需要修改
kernel.shmmax = 2147483648 //定义了共享内存段的最大尺寸(以字节为单位)。缺省为32M,对于oracle来说,该缺省值太低了,通常将其设置为2G=2147483648/1024/1024/1024
kernel.shmmni = 4096 //用于设置系统范围内共享内存段的最大数量。该参数的默认值是4096 。通常不需要更改
kernel.sem = 250 32000 100 128 //表示设置的信号量
fs.file-max = 65536 //表示文件句柄的最大数量。文件句柄表示在Linux系统中可以打 开的文件数量。其实是由"fs.file-max = 512 * PROCESSES"得到的,我们指定PROCESSES的值为128,即为"fs.file-max =512 *128"
fs.aio-max-nr = 1048576 //同时可以拥有的的异步IO请求数目。
net.ipv4.ip_local_port_range = 1024 65000 //应用程序可使用的Ipv4端口范围。
net.core.rmem_default = 262144 //默认的接收窗口大小
net.core.rmem_max = 4194304 //接收窗口的最大大小
net.core.wmem_default = 262144 //默认的发送窗口大小
net.core.wmem_max = 1048586 //发送窗口的最大大小

实例:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
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 = 1048586

使修改生效

1
sysctl -p   //使修改立即生效

sysctl -p报错处理

1
2
3
4
5
6
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key  
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key

modprobe bridge
lsmod | grep bridge

为oracle用户设置shell限制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#vi /etc/security/limits.conf   添加以下内容
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

#vi /etc/pam.d/login 添加以下内容
session required pam_limits.so

关闭selinux
#vi /etc/selinux/config 修改为disabled
SELINUX=disabled

临时关闭命令
setenforce 0

编辑/etc/profile,添加如下内容

1
2
3
4
5
6
7
8
9
#vi /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

编辑/etc/csh.login,添加如下内容

1
2
3
4
5
#vi /etc/csh.login
if ( $USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
endif

注:内核参数并非必须修改,可以根据自己实际情况而定。 以上为安装oracle的前置工作

安装oracle

创建需要的目录

1
2
3
4
5
6
7
groupadd oinstall
groupadd oradba
useradd -g oinstall -G oradba oracle
id oracle //查看账户是否建立完成
mkdir -p /opt/oracle
mkdir /opt/oracle/19c
chown -R oracle:oinstall /opt/oracle

添加oracle环境变量

1
2
3
4
5
6
7
8
9
10
#vi /etc/profile
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/19c
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
#export ORACLE_HOSTNAME=oracledb
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/network/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib

#source /etc/profile

设置db_install.rsp安装文件

编辑oracle应答文件db_install.rsp,文件存在解压目录的install/response目录下(最好将文件解压到oracle家目录/home/oracle/app下)

解压安装文件

1
2
3
4
5
su - oracle
mkdir app
mv LINUX.X64_193000_db_home.zip app
cd /home/oralce/app
unzip LINUX.X64_193000_db_home.zip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#vi db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=localhost
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/oracle/oraInventory
SELECTED\_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/oracle/19c
ORACLE_BASE=/opt/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=oradba
oracle.install.db.OSOPER_GROUP=oradba
oracle.install.db.OSBACKUPDBA_GROUP=oradba
oracle.install.db.OSDGDBA_GROUP=oradba
oracle.install.db.OSKMDBA_GROUP=oradba
oracle.install.db.OSRACDBA_GROUP=oradba
oracle.install.db.rootconfig.executeRootScript=false

#su oracle
$./runInstaller -silent -responseFile /home/oracle/app/install/response/db_install.rsp -ignorePrereq

当出现下面提示时,脚本执行正常完成

1
2
3
4
5
6
7
8
9
10
11
12
13
The following configuration scripts need to be executed as the "root" user. 
#!/bin/sh
#Root scripts to run

/opt/oracle/oraInventory/orainstRoot.sh
/opt/oracle/19c/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

系统初始化

1
2
3
su root
$ORACLE_BASE/oraInventory/orainstRoot.sh
$ORACLE_HOME/root.sh

安装网络监听器

1
2
3
4
5
su oracle
$ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/app/assistants/netca/netca.rsp
查看监听器状态
$ORACLE_HOME/bin/lsnrctl status

安装数据库实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
编辑response目录下的assistants/dbca/dbca.rsp文件
#vi dbca.rsp
gdbName=orcl //全局数据库的名字=SID+主机域名
sid=orcl //对应的实例名字
databaseConfigType=SI
templateName=General_Purpose.dbc //建库用的模板文件
sysPassword=xxxx //SYS用户初始密码
systemPassword=xxxx //SYSTEM用户初始密码
emConfiguration=NONE
dbsnmpPassword=xxxx //snmp密码
datafileDestination=/opt/oracle/oradata //数据文件存放目录
recoveryAreaDestination=/opt/oracle/flash_recovery_area //恢复数据文件存放目录
storageType=FS
characterSet=ZHS16GBK
nationalCharacterSet=AL16UTF16
sampleSchema=true
totalMemory=2048



保存完毕后切换到oracle身份
su oracle
$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/app/assistants/dbca/dbca.rsp


## ORACLE的启动和关闭

```bash
su oracle

监听器的启动
$ORACLE_HOME/bin/lsnrctl start
监听器的状态查看
$ORACLE_HOME/bin/lsnrctl status

启动oracle实例
sqlplus sys as sysdba
输入密码后进入
SQL>startup //启动数据库命令
或者使用命令启动
$ORACLE_HOME/bin/dbstart

关闭数据库实例
SQL>shutdown immediate
或者使用命令关闭
$ORACLE_HOME/bin/dbstart

关闭监听
$lsnrctl stop

将oracle作为服务

在root登录下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
vi /etc/init.d/oracle  复制以下文本后保存

#!/bin/sh

# chkconfig: 35 80 10
# description: Oracle auto start-stop script.

#
# Set ORACLE\_HOME to be equivalent to the $ORACLE\_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORACLE_OWNER to the user id of the owner of the
# Oracle database in ORACLE_HOME.
ORACLE_HOME=/opt/oracle/19c
ORACLE_OWNER=oracle
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart" >>/var/log/oracle
echo "Done"

# Start the Listener:
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;

'stop')
# Stop the Oracle Listener:
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop" >>/var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle

# Stop the Oracle Database:
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;

'restart')
$0 stop
$0 start
;;
esac





chmod +x /etc/init.d/oracle
chkconfig --level 35 oracle on

错误解决

  1. Solution for [INS-08101] Unexpected error ‘supportedOSCheck’ while Oracle 19C Installation
    解决办法:
    1
    2
    3
    4
    5
    6
    #添加环境变量
    export CV_ASSUME_DISTID=OEL8.1
    #或者直接修改文件内容
    cat $ORACLE_HOME/cv/admin/cvu_config | grep -i CV_ASSUME_DISTID
    #CV_ASSUME_DISTID=OEL5
    CV_ASSUME_DISTID=OEL8.1