说明:本文的所有步骤不适用于生产环境,仅用于个人测试环境的快速部署和学习,下述操作过程在Oracle Linux 7.9上安装Oracle 11.2.0.4单实例为例。

1 安装环境检查

安装环境的检查可以参考官方文档Oracle Database Quick Installation Guide for Linux x86-64。由于是测试环境,本文仅检查:

  1. 物理内存大于1G。使用free -m命令检查
  2. /tmp目录大于200MB。使用df -h命令检查,默认/tmp目录在分区中,会大于200MB
  3. hosts文件有对应的IP和主机名解析。使用cat /etc/hosts检查
  4. 安装和建库需要约10GB的空间。本文安装在/u01,未使用独立的分区,也隶属于分区中,有40GB的空间。

2 安装环境准备

2.1 准备Oracle用户和目录

使用root用户创建软件安装目录/u01/app/oracle/product/11.2.0.4/db_1,创建oinstall、dba、oper用户组,创建oracle用户,并且为oracle用户设置密码。

groupadd -g 1300 oinstall
groupadd -g 1301 dba
groupadd -g 1302 oper
useradd -u 1300 -g oinstall -G dba,oper -s /bin/bash oracle
mkdir -p /u01/app/oracle/product/11.2.0.4/db_1
chown -R oracle.oinstall /u01
passwd oracle

2.2 检查和安装所需的RPM包

  1. 使用rpm检查软件包是否已安装,如果未安装,则会提示is not installed
rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})n" binutils compat-db compat-libcap1 compat-libstdc++-33 control-center elfutils-libelf-devel gcc gcc-c++ glibc-common glibc glibc-devel glibc-headers ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel libgomp libXp make sysstat unzip
  1. 配置本地yum源,确保/etc/yum.repos.d/目录下仅有oracle-linux-ol7.repo配置文件
[root@oracle11g ~]# cat /etc/yum.repos.d/oracle-linux-ol7.repo 
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=file:///media/OEL79
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
[root@oracle11g ~]# df -h | grep OEL
/dev/sr0             4.6G  4.6G     0 100% /media/OEL79
[root@oracle11g ~]# yum makecache
Loaded plugins: ulninfo
ol7_latest                                                                                                     | 3.6 kB  00:00:00     
Metadata Cache Created
  1. 使用yum安装软件包
yum install binutils compat-db compat-libcap1 compat-libstdc++-33 control-center elfutils-libelf-devel gcc gcc-c++ glibc-common glibc glibc-devel glibc-headers ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel libgomp libXp make sysstat unzip -y

2.3 修改配置参数

  1. 修改pam认证机制,加载pam_limits.so模块来限制系统资源的使用
echo "session    required     pam_limits.so">>/etc/pam.d/login
  1. 配置oracle用户的资源限制,限制打开进程数量和文件数量
echo "oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536
">>/etc/security/limits.conf
  1. 修改profile,Linux中初始化shell时会使用该配置文件,当用户登录系统时,系统会首先加载/etc/profile文件,然后再加载用户个人的shell初始化文件,如~/.bash_profile等。
echo "if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
">>/etc/profile
  1. 修改内核参数,限制信号量、端口、文件数量等
echo "fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 15461882265  #16GB
kernel.shmmax = 4294967295 #4GB
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 = 1048576
">>/etc/sysctl.conf

内核参数介绍:

  • fs.aio-max-nr = 1048576:控制系统异步输入输出操作(Asynchronous I/O)并发数的最大值,影响系统的数据传输效率和压力处理能力。
  • fs.file-max = 6815744:表示系统最大文件打开数量,默认是1024,可能会造成系统资源不足或进程无法打开文件等问题。
  • kernel.shmall = 15461882265:定义了系统使用的最大共享内存容量,以页面(4K)为单位,这里设置的是16GB。
  • kernel.shmmax = 4294967295:定义了用户进程可使用的共享内存大小,以字节为单位,这里设置的是4GB。
  • 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 = 1048576:表示系统中发送缓存区的最大数量,用来调节系统发送性能。

  1. 配置oracle用户的环境变量,设置实例名为orcl、安装路径为/u01/app/oracle/product/11.2.0.4/db_1
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
echo "export ORACLE_SID=$ORACLE_SID
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/lib
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
umask 022
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export SQLPATH=$ORACLE_HOME/sqlplus/admin
">>/home/oracle/.bash_profile

2.4 关闭selinux和防火墙

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl disable firewalld --now

完成上述操作后,需要重启操作系统才生效

reboot

2.5 准备软件安装包

  1. 将安装包放在/tmp目录下
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
  1. 更改安装包的属组和用户为oinstall和oracle
chown -R oracle.oinstall /tmp/database

2.6 创建响应文件

需要留意的是UNIX_GROUP_NAME、INVENTORY_LOCATION、ORACLE_HOME、ORACLE_BASE,保持和前文的创建的用户名、安装路径一致。

echo "oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=DBProduce
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,en_GB
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=false
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
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.enableSecuritySettings=true
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.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
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=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD="/tmp/11gR2.rsp

3 执行静默安装

  1. 使用oracle用户,执行./runInstaller,注意-responseFile要用绝对路径
cd /tmp/database
./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent -responseFile /tmp/11gR2.rsp
  1. 安装过程输出
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 28865 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3967 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2023-05-06_03-53-30AM. Please wait ...You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2023-05-06_03-53-30AM.log

Prepare in progress.
..................................................   9% Done.

Prepare successful.

Copy files in progress.
..................................................   14% Done.
..................................................   20% Done.
..................................................   26% Done.
..................................................   31% Done.
..................................................   36% Done.
..................................................   41% Done.
..................................................   46% Done.
..................................................   51% Done.
..................................................   56% Done.
..................................................   63% Done.
..................................................   68% Done.
..................................................   73% Done.
..................................................   78% Done.
..................................................   83% Done.
..............................
Copy files successful.

Link binaries in progress.
..........
Link binaries successful.

Setup files in progress.
..................................................   88% Done.
..................................................   94% Done.

Setup files successful.
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2023-05-06_03-53-30AM.log' for more details.

Execute Root Scripts in progress.

As a root user, execute the following script(s):
	1. /u01/app/oraInventory/orainstRoot.sh
	2. /u01/app/oracle/product/11.2.0.4/db_1/root.sh


..................................................   100% Done.

Execute Root Scripts successful.
Successfully Setup Software.

4 安装后配置

使用root用户来之执行配置脚本

/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0.4/db_1/root.sh

5 执行静默建库

5.1 创建监听

  1. 准备netca响应文件
echo 'RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
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"'>>/tmp/netca.rsp
  1. 执行静默安装,注意是/responsefile,而且响应文件要绝对路径
netca /silent /responsefile /tmp/netca.rsp
  1. 配置成功后,输出如下:
Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /u01/install/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0
  1. 启动监听程序
[oracle@oracle11g admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-MAY-2023 04:28:25

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0.4/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                06-MAY-2023 04:28:26
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))

5.2 执行静默建库

  1. 使用oracle用户执行dbca命令来完成静默建库,安装过程中会自动创建/u01/app/oracle/oradata目录,并拷贝数据文件和生成控制文件、日志文件,将所有密码设置为oracle11g
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK -memoryPercentage 75 -emConfiguration LOCAL -datafiledestination /u01/app/oracle/oradata -sysPassword oracle11g -systemPassword oracle11g -dbsnmpPassword oracle11g -sysmanPassword oracle11g
  1. 建库过程输出
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

6 安装完成后检查

  1. 数据库实例的监听注册状态,确定是READY
[oracle@oracle11g ~]$ lsnrctl stat

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-MAY-2023 04:35:48

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                06-MAY-2023 04:28:26
Uptime                    0 days 0 hr. 7 min. 22 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

  1. 登录数据库,检查数据库状态为OPEN
[oracle@oracle11g ~]$ sqlplus  / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat May 6 04:36:58 2023

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name,open_mode from v$database;

NAME	  OPEN_MODE
--------- --------------------
ORCL	  READ WRITE

至此,Oracle11gR2单实例静默安装和建库完成。
再次强调一遍,本文安装的环境仅适用于测试,生产环境的数据库安装,请遵循Oracle的最佳实践。

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/kernelry/p/17377679.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!