CentOS上快速安装Oracle服务器脚本

配置repos源

# 注释下列代码,可能导致源问题
# cd /etc/yum.repos.d
# wget http://yum.oracle.com/public-yum-ol7.repo

官网指出了,将需要安装的版本 enable =1 ,所以要修改一下 .repo文件

下载RMP-GPG-KEY

  • wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

oracle-rdbms-server-11gR2-preinstall包所干的事情

  • (1)自动安装oracle所需的RPM包
  • (2)自动创建oracle用户和group组
  • (3)自动配置/etc/sysctl.conf内核参数
  • (4)自动配置/etc/security/limits.conf参数
  • (5)关闭NUMA=OFF (关闭非一致内存访问)

安装必要软件

groupadd dba && useradd -m -G dba oracle && mkdir /u01 && chown oracle:dba /u01
yum install -y oracle-rdbms-server-11gR2-preinstall glibc-static wget unzip && yum clean all

保存脚本

mkdir -p /install
cd /install
wget https://raw.githubusercontent.com/MaksymBilenko/docker-oracle-ee-11g/master/oracle-11g-ee-base/install/oracle-11g-ee.rsp
wget https://raw.githubusercontent.com/MaksymBilenko/docker-oracle-ee-11g/master/oracle-11g-ee-base/install/oracle_install.sh
wget https://raw.githubusercontent.com/MaksymBilenko/docker-oracle-ee-11g/master/entrypoint.sh

下载Oracle安装包

官网下载地址:https://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html

# 请执行修改下载链接,AuthParam会自动过期
wget -q -O linux.x64_11gR2_database_1of2.zip https://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip?AuthParam=1561389203_9ccc19db849275e4a7d668f4607586ee# 请执行修改下载链接,AuthParam会自动过期
wget -q -O linux.x64_11gR2_database_2of2.zip https://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip?AuthParam=1561389203_9ccc19db849275e4a7d668f4607586ee

执行脚本oracle_install.sh

#!/bin/bashset -e#Delete limits cause of docker limits issue
cat /etc/security/limits.conf | grep -v oracle | tee /etc/security/limits.conf#此处请自行下载oracle的zip包
echo 'Downloading linux.x64_11gR2_database_1of2.zip'
wget -q -O linux.x64_11gR2_database_1of2.zip http://10.0.1.4:8080/linux.x64_11gR2_database_1of2.zip
#此处请自行下载oracle的zip包
echo 'Downloading linux.x64_11gR2_database_2of2.zip'
wget -q -O linux.x64_11gR2_database_2of2.zip http://10.0.1.4:8080/linux.x64_11gR2_database_2of2.zip
echo 'Unzipping'
unzip -q linux.x64_11gR2_database_1of2.zip
unzip -q linux.x64_11gR2_database_2of2.zip
#rm -f linux*.zipmv database /home/oracle/su oracle -c 'cd /home/oracle/database && ./runInstaller -ignorePrereq -ignoreSysPrereqs -silent -responseFile /install/oracle-11g-ee.rsp -waitForCompletion 2>&1'
rm -rf /home/oracle/databasemv /u01/app/oracle/product /u01/app/oracle-product#/u01/app/oraInventory/orainstRoot.sh
#/u01/app/oracle/product/11.2.0/EE/root.sh#$ORACLE_HOME/bin/dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname EE.oracle.docker -sid EE -responseFile NO_VALUE -totalMemory 2048 -emConfiguration LOCAL  -sysPassword oracle -systemPassword oracle -dbsnmpPassword oracle

注意:脚本是保存在/install目录中的,请cd到此目录,以root权限执行脚本

设置Oracle参数

# vi ~/.bash_profileexport DBCA_TOTAL_MEMORY=4096
export WEB_CONSOLE="true"
export CHARACTER_SET=ZHS16GBK
export DB_NAME=EE
export DB_SID=EE
export DB_PASSWORD=ORCL123456export ORACLE_SID=EE
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/EEPATH=$PATH:$ORACLE_HOME/binexport PATH#####保存完毕后,执行source ~/.bash_profile# . ~/.bash_profile

执行entrypoint.sh脚本

#!/bin/bash
set -e# Prevent owner issues on mounted folders
echo "Preparing oracle installer."
chown -R oracle:dba /u01/app/oracle
rm -f /u01/app/oracle/product
ln -s /u01/app/oracle-product /u01/app/oracle/product#Run Oracle root scripts
echo "Running root scripts."
/u01/app/oraInventory/orainstRoot.sh 2>&1
echo | /u01/app/oracle/product/11.2.0/EE/root.sh 2>&1 || trueimpdp () {set +eDUMP_FILE=$(basename "$1")DUMP_NAME=${DUMP_FILE%.dmp} cat > /tmp/impdp.sql << EOL
-- Impdp User
CREATE USER IMPDP IDENTIFIED BY IMPDP;
ALTER USER IMPDP ACCOUNT UNLOCK;
GRANT dba TO IMPDP WITH ADMIN OPTION;
-- New Scheme User
create or replace directory IMPDP as '/docker-entrypoint-initdb.d';
create tablespace $DUMP_NAME datafile '/u01/app/oracle/oradata/$DUMP_NAME.dbf' size 1000M autoextend on next 100M maxsize unlimited;
create user $DUMP_NAME identified by $DUMP_NAME default tablespace $DUMP_NAME;
alter user $DUMP_NAME quota unlimited on $DUMP_NAME;
alter user $DUMP_NAME default role all;
grant all to $DUMP_NAME;
exit;
EOLsu oracle -c "NLS_LANG=.$CHARACTER_SET $ORACLE_HOME/bin/sqlplus -S / as sysdba @/tmp/impdp.sql"su oracle -c "NLS_LANG=.$CHARACTER_SET $ORACLE_HOME/bin/impdp IMPDP/IMPDP directory=IMPDP dumpfile=$DUMP_FILE $IMPDP_OPTIONS"#Disable IMPDP userecho -e 'ALTER USER IMPDP ACCOUNT LOCK;\nexit;' | su oracle -c "NLS_LANG=.$CHARACTER_SET $ORACLE_HOME/bin/sqlplus -S / as sysdba"set -e
}case "$1" in'')#Check for mounted database filesif [ "$(ls -A /u01/app/oracle/oradata)" ]; thenecho "found files in /u01/app/oracle/oradata Using them instead of initial database"echo "EE:$ORACLE_HOME:N" >> /etc/oratabchown oracle:dba /etc/oratabchown 664 /etc/oratabrm -rf /u01/app/oracle-product/11.2.0/EE/dbsln -s /u01/app/oracle/dbs /u01/app/oracle-product/11.2.0/EE/dbs#Startup Databasesu oracle -c "/u01/app/oracle/product/11.2.0/EE/bin/tnslsnr &"su oracle -c 'echo startup\; | $ORACLE_HOME/bin/sqlplus -S / as sysdba'elseecho "Database not initialized. Initializing database."export IMPORT_FROM_VOLUME=trueif [ -z "$CHARACTER_SET" ]; thenexport CHARACTER_SET="AL32UTF8"fi#printf "Setting up:\nprocesses=$processes\nsessions=$sessions\ntransactions=$transactions\n"mv /u01/app/oracle-product/11.2.0/EE/dbs /u01/app/oracle/dbsln -s /u01/app/oracle/dbs /u01/app/oracle-product/11.2.0/EE/dbsecho "Starting tnslsnr"su oracle -c "/u01/app/oracle/product/11.2.0/EE/bin/tnslsnr &"#create DB for SID: EEecho "Running initialization by dbca"su oracle -c "$ORACLE_HOME/bin/dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname EE -sid EE -responseFile NO_VALUE -characterSet $CHARACTER_SET -totalMemory $DBCA_TOTAL_MEMORY -emConfiguration LOCAL -dbsnmpPassword oracle -sysPassword oracle -systemPassword oracle"# echo "Configuring Apex console"# cd $ORACLE_HOME/apex# su oracle -c 'echo -e "0Racle$\n8080" | $ORACLE_HOME/bin/sqlplus -S / as sysdba @apxconf > /dev/null'# su oracle -c 'echo -e "${ORACLE_HOME}\n\n" | $ORACLE_HOME/bin/sqlplus -S / as sysdba @apex_epg_config_core.sql > /dev/null'# su oracle -c 'echo -e "ALTER USER ANONYMOUS ACCOUNT UNLOCK;" | $ORACLE_HOME/bin/sqlplus -S / as sysdba > /dev/null'# echo "Database initialized. Please visit http://#containeer:8080/em http://#containeer:8080/apex for extra configuration if needed"fiif [ $WEB_CONSOLE == "true" ]; thenecho 'Starting web management console'su oracle -c 'echo EXEC DBMS_XDB.sethttpport\(8080\)\; | $ORACLE_HOME/bin/sqlplus -S / as sysdba'elseecho 'Disabling web management console'su oracle -c 'echo EXEC DBMS_XDB.sethttpport\(0\)\; | $ORACLE_HOME/bin/sqlplus -S / as sysdba'fiif [ $IMPORT_FROM_VOLUME ]; thenecho "Starting import from '/docker-entrypoint-initdb.d':"for f in /docker-entrypoint-initdb.d/*; doecho "found file /docker-entrypoint-initdb.d/$f"case "$f" in*.sh)     echo "[IMPORT] $0: running $f"; . "$f" ;;*.sql)    echo "[IMPORT] $0: running $f"; echo "exit" | su oracle -c "NLS_LANG=.$CHARACTER_SET $ORACLE_HOME/bin/sqlplus -S / as sysdba @$f"; echo ;;*.dmp)    echo "[IMPORT] $0: running $f"; impdp $f ;;*)        echo "[IMPORT] $0: ignoring $f" ;;esacechodoneecho "Import finished"echoelseecho "[IMPORT] Not a first start, SKIPPING Import from Volume '/docker-entrypoint-initdb.d'"echo "[IMPORT] If you want to enable import at any state - add 'IMPORT_FROM_VOLUME=true' variable"echofiecho "Database ready to use. Enjoy! ;)"#### Workaround for graceful shutdown.##while [ "$END" == '' ]; dosleep 1trap "su oracle -c 'echo shutdown immediate\; | $ORACLE_HOME/bin/sqlplus -S / as sysdba'" INT TERMdone;;*)echo "Database is not configured. Please run '/entrypoint.sh' if needed."exec "$@";;
esac

如果没有发生异常的话,到此就完工结束了

CentOS上快速安装Oracle服务器脚本相关推荐

  1. CentOS上快速安装Oracle11g数据库

    CentOS上快速安装Oracle11g数据库 下载RMP-GPG-KEY wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /e ...

  2. 如何在 Raspberry Pi 上快速安装 Oracle Linux ?

    你知道树莓派(Raspberry Pi)吗?它可不是一款餐后甜点,而是一个只有信用卡大小的计算机,更准确的说它是一款单板计算机.那么,如何简单快速地在上面安装 Oracle Linux?下面将会详细介 ...

  3. aix 安装oracle smit install_latest,在AIX 5L上快速部署Oracle

    在AIX 5L上快速部署Oracle 作者:网络 来源:佚名 更新时间:2008-02-09 10:45:40 点击:0 环境准备1.系统资源 ü         /tmp或可用做临时空间的disk要 ...

  4. Postgresql在CentOS上的安装(脚本在线安装)

    场景 PostGresSQL简介与Windows上的安装教程: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/113981563 ...

  5. CentOS Stream 8 安装Oracle 19C (静默模式)

    CentOS Stream 8 安装Oracle 19C (静默模式) 1.提前准备工作 说明:必须严格遵守用户规则去创建目录,否则会导致缺少目录权限进而影响安装! 安装以下软件包最新版本(注意:如果 ...

  6. ubuntu18安装oracle11g,在Ubuntu 18.04系统下快速安装Oracle Java 11的方法

    本文介绍在Ubuntu 18.04操作系统下使用PPA快速安装Oracle Java 11的方法,同时也可以用在Ubuntu 18.10.Ubuntu 16.04.Ubuntu 14.04版本中. O ...

  7. 安装flarum的php扩展,在 Windows 上快速安装 Flarum 指南

    在 Windows 上快速安装 Flarum 指南 由 学院君 创建于5年前, 最后更新于 10个月前 版本号 #2 17639 views 6 likes 0 collects 1.下载安装包 去下 ...

  8. 在PK体系下的CentOS上编译安装 MySQL 5.7

    本文主要介绍如何在 PK 体系下的 CentOS 上编译安装 MySQL 5.7,本文使用的操作系统环境为: CentOS 版本: # cat /etc/redhat-release CentOS L ...

  9. ELK-日志收集系统在Centos上环境安装

    ELK-日志收集系统在Centos上环境安装 文章目录 ELK-日志收集系统在Centos上环境安装 前言 安装 elastcsearch6.5.4安装 准备 学习资料 启动 创建新用户 取掉只能本机 ...

最新文章

  1. DWM1000 长距离模块讨论
  2. Android项目的目录结构
  3. linux导出硬件信息,Linux 上生成硬件信息与配置报告: Sysreport
  4. 天池 在线编程 布尔表达式求值(栈)
  5. android camera2 采集,视频采集:Android平台基于Camera 2的实现
  6. altas(ajax)控件(二):悬浮面板控件AlwaysVisibleControl
  7. 协会元宇宙产业园基地孵化器授牌案例:循环经济元宇宙加速基地
  8. BZOJ 3772 精神污染 主席树+欧拉序
  9. Android绘制优化(二)布局优化
  10. cephfs:1 clients failing to respond to cache pressure原因分析
  11. Wsl2 Ubuntu18.04图形化界面,亲测成功
  12. Android常见的问题
  13. BorderStyle short usage
  14. Javascript中最常用的55个经典技巧
  15. golang panic recover return defer的逻辑顺序问题
  16. Silicon Labs EFR32 RF射频测试-RAILTEST
  17. 商城App接入快递100
  18. 使用Chrome开发者工具调用REST接口(附图)
  19. 【基础知识】An Implementation of Double-Array Trie
  20. 【Android,Kotlin】No type arguments expected for class Call

热门文章

  1. 项目优化经验mdash;mdash;垃圾回收导致的性能问题[z]
  2. IndexedDB:浏览器里内置的数据库
  3. 机器学习降维算法三:LLE (Locally Linear Embedding) 局部线性嵌入
  4. tensorflow代码中的tf.app.run()
  5. PC中存在多个Python版本,在指定的版本中安装包或者模块
  6. Linux head命令:显示文件开头的内容
  7. 【今日CV 计算机视觉论文速览】Thu, 28 Feb 2019
  8. centos 中查找文件、目录、内容
  9. WinForm下屏幕截图程序的实现
  10. JS编程建议——32:使用制表