Oracle_11g_R2在Centos7.5安装

官方最低要求配置

内存:1G

硬盘:40G

下载Oracle安装文件

https://www.oracle.com/database/technologies/112010-linx8664soft.html

或者

链接:https://pan.baidu.com/s/1IdbkdrVQVXJZFShpO-1Z4A
提取码:ola2
 
(读者注:oracle官网已经不提供下载了,需要有官方licence去申请;上面这个百度云提供的版本也有问题,在7.5下有些库会取函数不存在;可以在 https://pan.baidu.com/s/143nImZMUu3NCU3EZI9Xoxg  下载,提取码:l9cr)
 
 

1.准备Oracle 11g R2安装包

 下载解压缩命令unzip及net-tools工具 

yum -y install unzip
yum -y install net-tools

将Oracle数据库解压缩

复制代码
复制代码
unzip linux.x64_11gR2_database_1of2.zip 
unzip linux.x64_11gR2_database_2of2.zip 
// 或者
unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
// 解完压缩后放置到/opt/目录下
复制代码
复制代码

解压完成后会在本级目录下生成/database

2.修改主机名 添加主机名与IP对应记录

 

sed -i "s/HOSTNAME=localhost.localdomain/HOSTNAME=oracledb/" /etc/sysconfig/network
hostname oracledb 
echo $(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')    oracledb >> /etc/hosts
cat /etc/hosts

 3.关闭Selinux

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config 
setenforce 0 
cat /etc/selinux/config

4.创建用户和组

 

groupadd -g 200 oinstall
groupadd -g 201 dba
useradd -u 440 -g oinstall -G dba oracle
echo "oracle" | passwd --stdin oracle
5.修改内核参数
# 内核参数kernel.shmall,内存16G时建议设为4194304类推8G应为2097152,类似4G:1048576
# kernel.shmmax设置为物理内存的一半,8G:4294967296计算方式为4*1024*1024*1024,所以4G应为2147483648
复制代码
复制代码
echo "net.ipv4.ip_local_port_range= 9000 65500" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.shmall = 10523004" >> /etc/sysctl.conf
echo "kernel.shmmax = 6465333657" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100128" >> /etc/sysctl.conf
echo "net.core.rmem_default=262144" >> /etc/sysctl.conf
echo "net.core.wmem_default=262144" >> /etc/sysctl.conf
echo "net.core.rmem_max=4194304" >> /etc/sysctl.conf
echo "net.core.wmem_max=1048576" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
cat /etc/sysctl.conf
复制代码
复制代码

6.修改系统资源限制

echo "oracle  soft  nproc  2047" >> /etc/security/limits.conf
echo "oracle  hard  nproc  16384" >> /etc/security/limits.conf
echo "oracle  soft  nofile  1024" >> /etc/security/limits.conf
echo "oracle  hard  nofile  65536" >> /etc/security/limits.conf
cat /etc/security/limits.conf

7.修改用户体验选项

sed -i '/session    required     pam_namespace.so/a\session    required     pam_limits.so' /etc/pam.d/login
cat /etc/pam.d/login

8.创建目录

mkdir -p /opt/app/oracle/
chmod 755 /opt/app/oracle/
chown oracle.oinstall -R /opt/app/oracle/ 

9.安装Oracle数据库依赖包

yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

检查Oracle数据库依赖包是否安装完成

rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel

10.以Oracle用户修改Oracle的环境变量配置文件~/.bash_profile

复制代码
复制代码
echo "export ORACLE_BASE=/opt/app/oracle" >> ~/.bash_profile
echo 'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' >> ~/.bash_profile
echo 'export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin' >> ~/.bash_profile
echo 'export ORACLE_SID=orcl' >> ~/.bash_profile
echo 'export ORACLE_PID=ora11g' >> ~/.bash_profile
echo 'export NLS_LANG=AMERICAN_AMERICA.AL32UTF8' >> ~/.bash_profile
echo 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib' >> ~/.bash_profile
source ~/.bash_profile
cat ~/.bash_profile
复制代码
复制代码

11.修改静默安装配置文件(root)

复制代码
复制代码
sed -i "s/oracle.install.option=/oracle.install.option=INSTALL_DB_SWONLY/" /opt/database/response/db_install.rsp
sed -i "s/ORACLE_HOSTNAME=/ORACLE_HOSTNAME=oracledb/" /opt/database/response/db_install.rsp
sed -i "s/UNIX_GROUP_NAME=/UNIX_GROUP_NAME=oinstall/" /opt/database/response/db_install.rsp
sed -i "s/INVENTORY_LOCATION=/INVENTORY_LOCATION=\/opt\/app\/oracle\/oraInventory/" /opt/database/response/db_install.rsp
sed -i "s/SELECTED_LANGUAGES=/SELECTED_LANGUAGES=en,zh_CN/" /opt/database/response/db_install.rsp
sed -i "s/ORACLE_HOME=/ORACLE_HOME=\/opt\/app\/oracle\/product\/11.2.0\/db_1/" /opt/database/response/db_install.rsp
sed -i "s/ORACLE_BASE=/ORACLE_BASE=\/opt\/app\/oracle/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.InstallEdition=/oracle.install.db.InstallEdition=EE/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.isCustomInstall=false/oracle.install.db.isCustomInstall=false/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.DBA_GROUP=/oracle.install.db.DBA_GROUP=dba/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.OPER_GROUP=/oracle.install.db.OPER_GROUP=oinstall/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.type=/oracle.install.db.config.starterdb.type=GENERAL_PURPOSE/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.globalDBName=/oracle.install.db.config.starterdb.globalDBName=ora11g/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.SID=/oracle.install.db.config.starterdb.SID=ora11g/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.characterSet=AL32UTF8/oracle.install.db.config.starterdb.characterSet=AL32UTF8/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.memoryOption=true/oracle.install.db.config.starterdb.memoryOption=true/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.memoryLimit=/oracle.install.db.config.starterdb.memoryLimit=1500/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.installExampleSchemas=false/oracle.install.db.config.starterdb.installExampleSchemas=false/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.enableSecuritySettings=true/oracle.install.db.config.starterdb.enableSecuritySettings=true/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.password.ALL=/oracle.install.db.config.starterdb.password.ALL=oracle/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.control=DB_CONTROL/oracle.install.db.config.starterdb.control=DB_CONTROL/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false/oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.automatedBackup.enable=false/oracle.install.db.config.starterdb.automatedBackup.enable=false/" /opt/database/response/db_install.rsp
sed -i "s/oracle.install.db.config.starterdb.storageType=/oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE/" /opt/database/response/db_install.rsp
sed -i "s/DECLINE_SECURITY_UPDATES=/DECLINE_SECURITY_UPDATES=true/" /opt/database/response/db_install.rsp
cat /opt/database/response/db_install.rsp |grep -v "#"|grep -v "^$"
复制代码
复制代码

修改完成后与下面文件对比以下,查看是否有未修改的地方

复制代码
复制代码
[root@oracledb ~]# cat /opt/database/response/db_install.rsp |grep -v "#"|grep -v "^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracledb
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/opt/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=ora11g
oracle.install.db.config.starterdb.SID=ora11g
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1500
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
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.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
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=FILE_SYSTEM_STORAGE
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=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
复制代码
复制代码

更改完静默安装配置文件后,切换Oracle用户,执行db_install.rsp文件

cd /opt/database
./runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp

注:[WARING]可暂时忽略,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止。

安装需要一会儿,如果想看安装进度,可以再打开一个窗口,输出会话日志
tail -f 日志文件(下图中红色框中未日志文件绝对路径)

 

 

 当出现Successfully Setup Software.证明已经安装成功,然后根据提示以root用户执行脚本

sh /opt/app/oracle/oraInventory/orainstRoot.sh
sh /opt/app/oracle/product/11.2.0/db_1/root.sh

12.使用Oracle用户配置静默监听
启动监听:lsnrctl start
停止监听:lsnrctl stop
重启监听:lsnrctl reload
查看监听:lsnrctl status
$ORACLE_HOME/bin/netca /silent /responseFile /opt/database/response/netca.rsp

13.静默dbca建库,使用root用户修改/opt/database/response/dbca.rsp文件

 

 

sed -i '78c GDBNAME = "orcl"' /opt/database/response/dbca.rsp
sed -i '149c SID="orcl"' /opt/database/response/dbca.rsp
sed -i '415c CHARACTERSET="AL32UTF8"' /opt/database/response/dbca.rsp
sed -i '425c NATIONALCHARACTERSET="UTF8"' /opt/database/response/dbca.rsp
注:有的并不是在这些行,最好先手动确认后更改
然后切换至Oracle用户,执行以下命令
$ORACLE_HOME/bin/dbca -silent -responseFile /opt/database/response/dbca.rsp
此条命令执行完后会先清屏,然后输入两次密码后开始自动创建
 

 14.启动Oracle数据库

复制代码
复制代码
sqlplus / as sysdba
# 查看Oracle数据库是否正常
show parameter
# 或者 select table_name from dba_tables; # 查看Oracle数据库实例及状态 select instance_name,status from v$instance;
复制代码
复制代码

15.开机自动启动监听、Oracle

将/etc/oratab文件中最后一行的N改为Y(都为大写)
/etc/rc.local文件末尾出增加如下内容
echo "su - oracle -c 'dbstart'" >> /etc/rc.local
echo "su - oracle -c 'lsnrctl start'" >> /etc/rc.local
然后为/etc/rc.local增加执行权限
chmod +x /etc/rc.local
16.开放1521端口(远程链接Oracle所需)
复制代码
复制代码
# 查看端口是否开放
firewall-cmd --query-port=1521/tcp
# 永久开放1521端口号
firewall-cmd --permanent --zone=public --add-port=1521/tcp
# 执行完命令后必须重启防火墙端口才会生效
# 重启防火墙
systemctl restart firewalld.service
复制代码
复制代码
17.防火墙
复制代码
复制代码
# 查看防火墙状态
systemctl status firewalld.service
# 启动防火墙
systemctl start firewalld.service
# 关闭防火墙
systemctl stop firewalld.service
# 重启防火墙
systemctl restart firewalld.service
# 永久关闭防火墙
systemctl disable firewalld.service
复制代码
复制代码

 

文章来源:https://www.cnblogs.com/yu-sheng/p/13698315.html

 

读者注:这篇文章,非常优秀,感谢原创作者。作为初学者,受益匪浅。美中不足,静默安装完成后,端口1158没有启动起来,需要自己解决。相关参考文章如下:

https://blog.csdn.net/weixin_33921444/article/details/116510331

https://blog.csdn.net/Dream19881003/article/details/6120224

https://blog.csdn.net/iw1210/article/details/10277145

 

posted on   咚..咚  阅读(82)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2016-08-12 C# WebBrowser禁止F5刷新
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示