欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle 11g R2 Sample Schemas 安装

程序员文章站 2022-11-25 14:16:24
最近准备对之前学习SQL Loader的笔记进行整理,希望通过官方文档中的示例学习(Case Studies)来进行,但是官方文档中示例学习相关的脚本文件在数据库软件安装完成之后默认并没有提供,而是整合在另外一个安装介质中,需通过安装Oracle Examples介质来获取相应的示例学习脚本。 数据 ......

最近准备对之前学习sql*loader的笔记进行整理,希望通过官方文档中的示例学习(case studies)来进行,但是官方文档中示例学习相关的脚本文件在数据库软件安装完成之后默认并没有提供,而是整合在另外一个安装介质中,需通过安装oracle examples介质来获取相应的示例学习脚本。

数据库示例(oracle database examples)包含了一系列的示例脚本和产品功能演示的schema信息,在学习oracle数据库的过程中可以通过这些示例更好的掌握数据库相关的选项和功能特性。关于oracle的示例schema,更详细的说明可以参考官方文档:database sample schemas

根据我的数据库版本,需要下载oracle 11g r2对应的examples安装介质。如果数据库版本是11.2.0.1,则可以到官网上进行下载示例安装介质:oracle database 11g release 2 examples。本文使用的数据库版本为11.2.0.4,相应的examples安装介质可通过oracle mos上进行获取,根据11.2.0.4的patch说明,对应的examples安装介质为:p13390677_112040_platform_6of7.zip

安装准备

首先上传对应压缩包p13390677_112040_platform_6of7.zip到相应的目录下。

# rz
rz waiting to receive.
upload zmodem
p13390677_112040_linux-x86-64_6of7.zip                                                  (465.75 mb, 0:10 min = 46.57 mb/sec)

对压缩包进行解压,将文件放在/tmp目录下。

# unzip p13390677_112040_linux-x86-64_6of7.zip -d /tmp/

# ls /tmp/examples/
install  readme.html  response  runinstaller  stage  welcome.html

变更安装文件的属主和属组。

# chown -r oracle.oinstall /tmp/examples/

# ls -ld /tmp/examples/
drwxr-xr-x 5 oracle oinstall 109 aug 27  2013 /tmp/examples/

查看安装介质解压后的文件结构,oracle database examples可以使用oracle installer软件安装器进行安装,其中安装种类可以通过图形界面或是静默安装的方式,为了更快速的完成安装,这里通过静默安装,同时需要结合response响应文件指定安装选项。

准备响应文件

安装介质中提供了一个响应文件模板,位于response目录下。

$ ls /tmp/examples/response/
demos_install.rsp

查看响应文件对应的文件内容,其中有各个选项的说明。

$ cat /tmp/examples/response/demos_install.rsp

###############################################################################
## copyright(c) oracle corporation 1998,2013. all rights reserved.           ##
##                                                                           ##
## specify values for the variables listed below to customize                ##
## your installation.                                                        ##
##                                                                           ##
## each variable is associated with a comment. the comment                   ##
## can help to populate the variables with the appropriate                   ##
## values.                                                                   ##
##                                                                           ##
###############################################################################

#-------------------------------------------------------------------------------
# do not change the following system generated value.
#-------------------------------------------------------------------------------
oracle.install.responsefileversion=/oracle/install/rspfmt_demosinstall_response_schema_v11_2_0

#-------------------------------------------------------------------------------
# this variable holds the hostname of the system as set by the user.
# it can be used to force the installation to use an alternative
# hostname rather than using the first hostname found on the system
# (e.g., for systems with multiple hostnames and network interfaces).
#-------------------------------------------------------------------------------
oracle_hostname=

#-------------------------------------------------------------------------------
# unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
unix_group_name=

#-------------------------------------------------------------------------------
# inventory location.
#-------------------------------------------------------------------------------
inventory_location=

#-------------------------------------------------------------------------------
# languages in which the components will be installed.
#
# en   : english                  ja   : japanese
# fr   : french                   ko   : korean
# ar   : arabic                   es   : latin american spanish
# bn   : bengali                  lv   : latvian
# pt_br: brazilian portuguese     lt   : lithuanian
# bg   : bulgarian                ms   : malay
# fr_ca: canadian french          es_mx: mexican spanish
# ca   : catalan                  no   : norwegian
# hr   : croatian                 pl   : polish
# cs   : czech                    pt   : portuguese
# da   : danish                   ro   : romanian
# nl   : dutch                    ru   : russian
# ar_eg: egyptian                 zh_cn: simplified chinese
# en_gb: english (great britain)  sk   : slovak
# et   : estonian                 sl   : slovenian
# fi   : finnish                  es_es: spanish
# de   : german                   sv   : swedish
# el   : greek                    th   : thai
# iw   : hebrew                   zh_tw: traditional chinese
# hu   : hungarian                tr   : turkish
# is   : icelandic                uk   : ukrainian
# in   : indonesian               vi   : vietnamese
# it   : italian
#
# all_langs   : all languages
#
# specify value as the following to select any of the languages.
# example : selected_languages=en,fr,ja
#
# specify value as the following to select all the languages.
# example : selected_languages=all_langs
#-------------------------------------------------------------------------------
selected_languages=en

#-------------------------------------------------------------------------------
# complete path of the oracle home
#-------------------------------------------------------------------------------
oracle_home=

#-------------------------------------------------------------------------------
# complete path of the oracle base.
#-------------------------------------------------------------------------------
oracle_base=

#------------------------------------------------------------------------------
# specify the auto-updates option. it can be one of the following:
#   - myoraclesupport_download
#   - offline_updates
#   - skip_updates
#------------------------------------------------------------------------------
oracle.installer.autoupdates.option=

#------------------------------------------------------------------------------
# in case myoraclesupport_download option is chosen, specify the location where
# the updates are to be downloaded.
# in case offline_updates option is chosen, specify the location where the updates
# are present.
#------------------------------------------------------------------------------
oracle.installer.autoupdates.downloadupdatesloc=

#------------------------------------------------------------------------------
# specify the my oracle support account username which has the patches download privileges
# to be used for software updates.
#  example   : autoupdates_myoraclesupport_username=abc@oracle.com
#------------------------------------------------------------------------------
autoupdates_myoraclesupport_username=

#------------------------------------------------------------------------------
# specify the my oracle support account username password which has the patches download privileges
# to be used for software updates.
#
# example    : autoupdates_myoraclesupport_password=password
#------------------------------------------------------------------------------
autoupdates_myoraclesupport_password=

#------------------------------------------------------------------------------
# specify the proxy server name. length should be greater than zero.
#
# example    : proxy_host=proxy.domain.com
#------------------------------------------------------------------------------
proxy_host=

#------------------------------------------------------------------------------
# specify the proxy port number. should be numeric and at least 2 chars.
#
# example    : proxy_port=25
#------------------------------------------------------------------------------
proxy_port=

#------------------------------------------------------------------------------
# specify the proxy user name. leave proxy_user and proxy_pwd
# blank if your proxy server requires no authentication.
#
# example    : proxy_user=username
#------------------------------------------------------------------------------
proxy_user=

#------------------------------------------------------------------------------
# specify the proxy password. leave proxy_user and proxy_pwd
# blank if your proxy server requires no authentication.
#
# example    : proxy_pwd=password
#------------------------------------------------------------------------------
proxy_pwd=

#------------------------------------------------------------------------------
# specify the proxy realm.
#
# example    : proxy_realm=metalink
#------------------------------------------------------------------------------
proxy_realm=

可以对模版响应文件进行简化处理,去掉相应的注释内容和空行,复制生成一份响应文件dbabd_demos_install.rsp,关于响应文件中选项的设置可以参考另一篇博文关于响应文件的部分说明:centos 7静默安装oracle 11g r2数据库软件

$ cat /tmp/examples/response/demos_install.rsp | grep -v '^$' | grep -v '^#' > /tmp/examples/response/dbabd_demos_install.rsp

$ cat /tmp/examples/response/dbabd_demos_install.rsp
oracle.install.responsefileversion=/oracle/install/rspfmt_demosinstall_response_schema_v11_2_0
oracle_hostname=dbabd
unix_group_name=oinstall
inventory_location=/data/app/orainventory
selected_languages=en,zh_cn
oracle_home=/data/app/oracle/product/11.2.0/db_1
oracle_base=/data/app/oracle
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadupdatesloc=
autoupdates_myoraclesupport_username=
autoupdates_myoraclesupport_password=
proxy_host=
proxy_port=
proxy_user=
proxy_pwd=
proxy_realm=

执行静默安装

响应文件完成之后就可以进行静默安装了,需要使用oracle用户进行安装。

# su - oracle

$ cd /tmp/examples/

$ /tmp/examples/runinstaller -silent -force -ignoreprereq -ignoresysprereqs -responsefile /tmp/examples/response/dbabd_demos_install.rsp
starting oracle universal installer...

checking temp space: must be greater than 120 mb.   actual 36731 mb    passed
checking swap space: must be greater than 150 mb.   actual 5103 mb    passed
preparing to launch oracle universal installer from /tmp/orainstall2019-05-18_08-54-52pm. please wait ...

you can find the log of this install session at:
 /data/app/orainventory/logs/installactions2019-05-18_08-54-52pm.log
the installation of oracle database 11g examples was successful.
please check '/data/app/orainventory/logs/silentinstall2019-05-18_08-54-52pm.log' for more details.
successfully setup software.

通过简要的安装信息可以看出安装成功,如果需要详细的日志信息可以查询提示信息中涉及的日志文件。

完成安装

至此,关于数据库示例(oracle database examples)对应的安装介质就安装完成了。通过查看目录$oracle_home/rdbms/demo下的以ulcase命名的一系列文件就是oracle针对sql*loader示例学习文件。在没有安装之前,这个目录下是没有文件的。

$ cd $oracle_home/rdbms/demo
$ ls ulcase*
ulcase10.ctl  ulcase11.sql  ulcase2.dat  ulcase4.dat  ulcase5.sql  ulcase7.ctl   ulcase8.ctl   ulcase92.dat  ulcase96.dat
ulcase10.sql  ulcase1.ctl   ulcase3.ctl  ulcase4.sql  ulcase6.ctl  ulcase7.dat   ulcase8.dat   ulcase93.dat  ulcase9.ctl
ulcase11.ctl  ulcase1.sql   ulcase3.sql  ulcase5.ctl  ulcase6.dat  ulcase7e.sql  ulcase8.sql   ulcase94.dat  ulcase9.sql
ulcase11.dat  ulcase2.ctl   ulcase4.ctl  ulcase5.dat  ulcase6.sql  ulcase7s.sql  ulcase91.dat  ulcase95.dat  ulcase.sh

其中ulcase.sh的内容如下:

$ cat ulcase.sh
#!/bin/sh
#
# $header: ulcase.sh 06-sep-2007.13:54:17 jstenois exp $
#
# ulcase.sh
#
# copyright (c) 1999, 2007, oracle. all rights reserved.
#
#    name
#      ulcase.sh - run sqlldr demos
#
#    description
#      shell script to run sqlldr demos.
#      please append to script as more ulcase* demos are added.
#
#    modified   (mm/dd/yy)
#    jstenois    09/06/07 - remove password from demo script
#    krich       01/26/04 - adding case study 11
#    cmlim       07/20/99 - create shell script for running all sqlldr demos
#    cmlim       07/20/99 - creation
#

echo "  "
echo "- this script runs through all of the sql loader demos."
echo "- it uses sqlplus to create the necessary objects and then"
echo "- calls sql loader to load data.  this script uses schema"
echo "- scott for all of the tests.  whenever the script executes"
echo "- sqlplus or sql loader utilities, it will prompt you for"
echo "- password of the scott user.  you will need to enter this"
echo "- password every time for the script to continue.  the"
echo "- default password for user scott is tiger."
echo "  "

# case1
echo "  "
echo "  starting case 1"
echo "  calling sql plus to do setup for case 1"
sqlplus scott @ulcase1
echo "  calling sql loader to load data for case 1"
sqlldr scott ulcase1.ctl

# case2
echo "  "
echo "  starting case 2"
echo "  calling sql loader to load data for case 2"
sqlldr scott ulcase2

# case3
echo "  "
echo "  starting case 3"
echo "  calling sql plus to do setup for case 3"
sqlplus scott @ulcase3
echo "  calling sql loader to load data for case 3"
sqlldr scott ulcase3

# case4
echo "  "
echo "  starting case 4"
echo "  calling sql plus to do setup for case 4"
sqlplus scott @ulcase4
echo "  calling sql loader to load data for case 4"
sqlldr scott ulcase4

# case5
echo "  "
echo "  starting case 5"
echo "  calling sql plus to do setup for case 5"
sqlplus scott @ulcase5
echo "  calling sql loader to load data for case 5"
sqlldr scott ulcase5

# case6
echo "  "
echo "  starting case 6"
echo "  calling sql plus to do setup for case 6"
sqlplus scott @ulcase6
echo "  calling sql loader to load data for case 6"
sqlldr scott ulcase6 direct=true

# case7
echo "  "
echo "  starting case 7"
echo "  calling sql plus to do setup for case 7"
sqlplus scott @ulcase7s
echo "  calling sql loader to load data for case 7"
sqlldr scott ulcase7
echo "  calling sql plus to do cleanup for case 7"
sqlplus scott @ulcase7e

# case8
echo "  "
echo "  starting case 8"
echo "  calling sql plus to do setup for case 8"
sqlplus scott @ulcase8
echo "  calling sql loader to load data for case 8"
sqlldr scott ulcase8

# case9
echo "  "
echo "  starting case 9"
echo "  calling sql plus to do setup for case 9"
sqlplus scott @ulcase9
echo "  calling sql loader to load data for case 9"
sqlldr scott ulcase9

# case10
echo "  "
echo "  starting case 10"
echo "  calling sql plus to do setup for case 10"
sqlplus scott @ulcase10
echo "  calling sql loader to load data for case 10"
sqlldr scott ulcase10

# case11
echo "  "
echo "  starting case 11"
echo "  calling sql plus to do setup for case 11"
sqlplus scott @ulcase11
echo "  calling sql loader to load data for case 11"
sqlldr scott ulcase11

参考

https://docs.oracle.com/cd/e11882_01/server.112/e10831/toc.htm
https://docs.oracle.com/cd/e11882_01/install.112/e24501/toc.htm#babgfcih

☆〖本人水平有限,文中如有错误还请留言批评指正!〗☆