Oracle_11g_R2在Centos7.5安装
官方最低要求配置
内存:1G
硬盘:40G
下载Oracle安装文件
或者
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
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],则安装程序已经停止。
当出现Successfully Setup Software.证明已经安装成功,然后根据提示以root用户执行脚本
sh /opt/app/oracle/oraInventory/orainstRoot.sh sh /opt/app/oracle/product/11.2.0/db_1/root.sh
$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_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

echo "su - oracle -c 'dbstart'" >> /etc/rc.local echo "su - oracle -c 'lsnrctl start'" >> /etc/rc.local
chmod +x /etc/rc.local
# 查看端口是否开放 firewall-cmd --query-port=1521/tcp # 永久开放1521端口号 firewall-cmd --permanent --zone=public --add-port=1521/tcp # 执行完命令后必须重启防火墙端口才会生效 # 重启防火墙 systemctl restart firewalld.service
# 查看防火墙状态 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2016-08-12 C# WebBrowser禁止F5刷新