编程知识 cdmana.com

Oracle 19c的examples静默安装

Oracle 11g的examples示例schema安装,在这篇文章《Oracle 11g的examples静默安装》介绍过了,Oracle 19c的examples示例schema安装略有不同。

首先,从官网下载这个压缩包,

LINUX.X64_193000_examples.zip

上传服务器,解压缩得到如下目录结构,

[oracle@bisal examples]$ ls -rlht
total 20K
-rwxrwxr-x.  1 root root  500 Feb  7  2013 welcome.html
-rwxr-xr-x.  1 root root 8.7K Apr 17  2019 runInstaller
drwxr-xr-x.  4 root root  191 Apr 17  2019 install
drwxr-xr-x. 13 root root 4.0K Apr 17  2019 stage
drwxrwxr-x.  2 root root   50 Dec  6 22:25 response

采用静默安装,和11g相同,在response中根据demos_install.rsp,重新生成静默安装配置文件,

[root@bisal response]# cat demos_install.rsp | grep -v ^# | grep -v ^$ > install.rsp

和11g不同的是,文件就几行,

[root@bisal response]# vi install.rsp 
oracle.install.responseFileVersion=/oracle/install/rspfmt_demosinstall_response_schema_v19.0.0
UNIX_GROUP_NAME=
ORACLE_HOME=
ORACLE_BASE=

比对一下,这是11g的,

[oracle@app response]$ cat install.rsp 
oracle.install.responseFileVersion=/oracle/install/rspfmt_demosinstall_response_schema_v11_2_0
ORACLE_HOSTNAME=
UNIX_GROUP_NAME=dba
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4
ORACLE_BASE=/u01/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=

静默安装的指令,11g和19c是相同的,

[oracle@bisal examples]$ ./runInstaller -silent -force -ignorePrereq -ignoreSysPrereqs -responseFile /opt/software/examples/response/install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 415 MB.   Actual 2438 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2860 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-12-06_10-27-01PM. Please wait ... 
[WARNING] [INS-32056] The specified Oracle Base contains the existing Central Inventory location: /opt/oracle/oraInventory.
   ACTION: Oracle recommends that the Central Inventory location is outside the Oracle Base directory. Specify a different location for the Oracle Base.
The response file for this session can be found at:
 /opt/oracle/product/19c/dbhome_1/install/response/examples_2020-12-06_10-27-01PM.rsp
You can find the log of this install session at:
 /opt/oracle/oraInventory/logs/installActions2020-12-06_10-27-01PM.log


Successfully Setup Software.
The installation of Oracle Database 19c Examples was successful.
Please check '/opt/oracle/oraInventory/logs/silentInstall2020-12-06_10-27-01PM.log' for more details.

11g安装完成,直接执行mksample.sql,就可以完成schema的创建了,但是19c,没这个脚本,

[oracle@bisal schema]$ pwd
/opt/oracle/product/19c/dbhome_1/demo/schema
[oracle@bisal schema]$ ls -rlht
total 60K
-rw-r--r--. 1 oracle oinstall 2.3K Apr  4  2009 drop_sch.sql
-rw-r--r--. 1 oracle oinstall  17K Jul  1  2014 sted_mkplug.sql.dbl
-rw-r--r--. 1 oracle oinstall  27K Jul  1  2014 mkplug.sql
drwxr-xr-x. 2 oracle oinstall    6 Apr 17  2019 log
-rw-r--r--. 1 oracle oinstall 1.8K Apr 18  2019 mk_dir.sql.ouibak
drwxr-xr-x. 2 oracle oinstall  205 Dec  6 18:06 human_resources
-rw-r-----. 1 oracle oinstall 1.8K Dec  6 22:28 mk_dir.sql

从12.2开始,Oracle自带的examples只是包含了HR这个schema,其他schema,需要自行从github下载和安装,

Starting with Oracle Database 12c Release 2, the latest version of the sample schema scripts are available on GitHub at https://github.com/oracle/db-sample-schemas/releases/latest. During a complete installation of Oracle Database, the HR schema can be installed either manually or automatically when creating a database using the dbca option. All the other sample schemas must be installed manually via the scripts available on GitHub. https://docs.oracle.com/en/database/oracle/oracle-database/19/comsc/installing-sample-schemas.html#GUID-1E645D09-F91F-4BA6-A286-57C5EC66321D

这是19c的地址,

https://github.com/oracle/db-sample-schemas/releases/tag/v19c

这是19.2的地址,

https://github.com/oracle/db-sample-schemas/releases/tag/v19.2

文档中另外说了,CO(Customer Orders)是从12c开始引入的schema,在mksample.sql不包括他,

The Customer Orders(CO) schema is available from Oracle Database 12c onwards. The master script @mksample currently does not include the CO schema.

在db-sample-schemas-19.2.zip中customer_orders文件夹,是他的创建脚本,可以参考Readme.txt安装。

19c的examples安装完成,可以在这个路径下创建hr,

$ORACLE_HOME/demo/schema/human_resources

[oracle@bisal human_resources]$ pwd
/opt/oracle/product/19c/dbhome_1/demo/schema/human_resources
[oracle@bisal human_resources]$ ls -rlht
total 100K
-rw-r--r--. 1 oracle oinstall 1.4K Aug 30  2002 hr_idx.sql
-rw-r--r--. 1 oracle oinstall 7.1K Aug 30  2002 hr_comnt.sql
-rw-r--r--. 1 oracle oinstall 9.2K Aug 30  2002 hr_cre.sql
-rw-r--r--. 1 oracle oinstall 2.7K Aug 30  2002 hr_code.sql
-rw-r--r--. 1 oracle oinstall 1.2K Oct 13  2002 hr_analz.sql
-rw-r--r--. 1 oracle oinstall  44K Aug 16  2008 hr_popul.sql
-rw-r--r--. 1 oracle oinstall 5.0K Nov  7  2015 hr_main_new.sql
-rw-r--r--. 1 oracle oinstall 2.6K Nov  7  2015 hr_drop_new.sql
-rw-r--r--. 1 oracle oinstall 4.7K Mar 30  2016 hr_main.sql
-rw-r--r--. 1 oracle oinstall 2.6K Mar 30  2016 hr_drop.sql

执行hr_main.sql,

SQL> @?/demo/schema/human_resources/hr_main.sql


specify password for HR as parameter 1:
Enter value for 1:


Enter value for 2:
Enter temp as the temporary tablespace for HR


Enter value for 3:
Enter your SYS password


specify password for SYS as parameter 4:
Enter value for 4:


specify log path as parameter 5:
Enter value for 5:

如果安装db-sample-schemas-19.2.zip,首先需要解压缩,

[oracle@bisal db-sample-schemas-19.2]$ ls
bus_intelligence  drop_sch.sql     LICENSE.md  mksample.sql  order_entry    README.txt
CONTRIBUTING.md   human_resources  mk_dir.sql  mkunplug.sql  product_media  sales_history
customer_orders   info_exchange    mkplug.sql  mkverify.sql  README.md      shipping

mksample.sql中,需要对_SUB__CWD__进行替换,

快捷方式,_SUB__CWD__替换为当前路径,

perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat

建议按照如下指令执行mksample.sql,避免一次次交互输入,因为这种方式下,有些用户取的账号出错,导致不能登录,另外,connect_string参数是PDB,例如localhost:1521/pdb,但可以是tnsnames.ora中的有效项,

SQL> @mksample <SYSTEM_password> <SYS_password>
     <HR_password> <OE_password> <PM_password> <IX_password> 
    <SH_password> <BI_password> EXAMPLE TEMP 
    $ORACLE_HOME/demo/schema/log/(忽略为当前路径) localhost:1521/pdb

我用的是,

SQL> @mksample oracle oracle oracle oracle oracle oracle oracle oracle EXAMPLE_TBS TEMP 
    空 BISAL(tnsnames.ora配置项)

schema创建完成,会自动执行一个校验脚本,显示所有相关的数据字典,

...


PROMPT
PROMPT All granted roles


SELECT    granted_role, grantee
 FROM     dba_role_privs
 WHERE    grantee in ('HR','OE','SH','PM','IX','BI')
 ORDER BY 1,2;


PROMPT
PROMPT All granted system privileges


SELECT    privilege, grantee
 FROM     dba_sys_privs
 WHERE    grantee in ('HR','OE','SH','PM','IX','BI')
 ORDER BY 1,2;


PROMPT
PROMPT All granted object privileges


SELECT    owner, table_name, privilege, grantee
 FROM     dba_tab_privs
 WHERE    grantee in ('HR','OE','SH','PM','IX','BI')
 ORDER BY 1,2,3,4;


PROMPT
PROMPT Space usage


SELECT    owner, segment_type, sum(bytes)
 FROM     dba_segments
 WHERE    owner in ('HR','OE','SH','PM','IX','BI')
 GROUP BY ROLLUP (owner, segment_type);


...

19c的examples之所以是这种安装方式,我猜其中一点原因可能是github存储examples的脚本,相比较Oracle官网提供,会更加灵活,随时有更新,随时能上传下载,还可以增加互动,更符合程序员的日常需求。

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

版权声明
本文为[bisal]所创,转载请带上原文链接,感谢
https://cloud.tencent.com/developer/article/1765053

Scroll to Top