发贴人 Sergio-Oracle 于2018-4-18 23:10:15在Oracle Linux

Introduction

In a previous blog post, I described the steps to streamline the pre-installation steps on Oracle Linux for Oracle Database 12c using the Database preinstallation package. In this post you will learn how to do a fully automated installation of Oracle Database 12c on Oracle Linux running in an Oracle VM VirtualBox guest. The tutorial is based on a Vagrantfile published in our Vagrant repo on GitHub.

Because this installation method uses VirtualBox, Vagrant and an Oracle Linux Vagrant Box, the whole process can be automated, requiring minimal to no input. Assuming you have VirtualBox, Vagrant and git installed, these are the steps needed to install Oracle Database:

  1. Clone the relevant GitHub repository
  2. Download the Oracle Database 12c installation media from OTN
  3. Issue a Vagrant to create the VM and start the Database installation process
  4. Wait 15-25 minutes, depending on your network bandwidth and machine horsepower
  5. Done

The commands are straightforward:

$ git clone https://github.com/oracle/vagrant-boxes

$ cd vagrant-boxes/OracleDatabase/12.2.0.1

<download Oracle Database installation zip file>

$ vagrant up

How Does This Work?

Assuming you have the required tools in place, the steps summarized earlier cause Vagrant to do the following

  • read the Vagrantfile (more about that later)
  • create a headless VM based on the pre-packaged Oracle Linux 7 Vagrant box
  • provision the VM by runing a script that
    • updates Oracle Linux to the latest available packages from Oracle Linux yum server
    • performs Database pre-installation checks and installs required packages
    • unzips the Database installion files,
    • installs the Oracle Database 12c software
    • creates a database and pluggable database container

After the installation has completed, you can either log in to the guest VM itself and interact with the Database there or, you can leave the VM running —headless— and connect from the host operating system to the Database using tools such as SQL Developer.

Requirements

Before You Get Started

You will need the following tools installed to follow this tutorial

Steps

Clone the vagrant-boxes repository from GitHub

  1. $ git clone https://github.com/oracle/vagrant-boxes
  2. Cloning into 'vagrant-boxes'...
  3. remote: Counting objects: 382, done.
  4. remote: Compressing objects: 100% (77/77), done.
  5. remote: Total 382 (delta 67), reused 108 (delta 52), pack-reused 249
  6. Receiving objects: 100% (382/382), 80.99 KiB | 0 bytes/s, done.
  7. Resolving deltas: 100% (195/195), done.
  8. Checking connectivity... done.
  9. $

Download Oracle Database Installation Files

From the Oracle Database 12c Release 2 download page, grab the Linux x86-64 file. Accept the license and click File 1 for Linux x86-64 (see Fig. 1)

Fig 1. Database 12c Release 2 installation file

Place the downloaded Database installation zip File in the appropriate directory

Because you are installing Database 12c, change to the appropriate directory:

  1. $ cd vagrant-boxes/OracleDatabase/12.2.0.1

You should see the following before you proceed:

  1. $ ls -1F
  2. README.md
  3. Vagrantfile
  4. linuxx64_12201_database.zip
  5. ora-response/
  6. scripts/
  7. $

For my installation I used Vagrant 2.0.1 and VirtualBox 5.2.8

  1. $ vagrant -v
  2. Vagrant 2.0.1
  3. $ vboxmanage -v
  4. 5.2.8r121009
  5. $

What's in a Vagrantfile?

Before we kick off the installation, let's take a look at the Vagrantfile, the file that controls everything from creating the Oracle Linux VM, to installing the Database.

At the top of the Vagrantfile, there's a section that defines a virtual machine to be based on a Vagrant base box. In this case it's using a the latest available Oracle Linux 7 box from yum.oracle.com

  1. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  2. config.vm.box = "ol7-latest"
  3. config.vm.box_url = "https://yum.oracle.com/boxes/oraclelinux/latest/ol7-latest.box"

This section configures port forwarding in VirtualBox so that a SQL*Net connection to port 1521 on the host operating system (for example) will end up connecting to the Database listener in the VM guest.

  1. # Oracle port forwarding
  2. config.vm.network "forwarded_port", guest: 1521, host: 1521
  3. config.vm.network "forwarded_port", guest: 5500, host: 5500

The last section tells Vagrant to provision the VM by running an install script that performs the Database installation. It also defines and sets environment variables for the execution of the script.  You can adjust these if you wish, but it's not required.

  1. config.vm.provision "shell", path: "scripts/install.sh", env:
  2. {
  3. "ORACLE_BASE"        => "/opt/oracle",
  4. "ORACLE_HOME"        => "/opt/oracle/product/12.2.0.1/dbhome_1",
  5. "ORACLE_SID"          => "ORCLCDB",
  6. "ORACLE_PDB"          => "ORCLPDB1",
  7. "ORACLE_CHARACTERSET" => "AL32UTF8",
  8. "ORACLE_EDITION"      => "EE"
  9. }

You can take a look at the install script here, but suffice to say it uses a response file to perform an installation of Oracle Dabase 12c using so-called response files so that no user interaction is required.

Start the installation

  1. $ vagrant up

Now, grab yourself a beverage or a snack. The installation can take anywhere from 15 to 25 minutes, depending on the power of the host running the VM and your bandwidth (to download the Oracle Linux box). On a late 2013 Macbook Pro with SSD storage and 8GB of RAM it took about 23 minutes to get from the initial vagrant command to fully installed Oracle Database.

You will see tons of output as the VM is configured and the Database is installed. Some snippets below:

==> default: Running provisioner: shell...

default: Running: /var/folders/dq/zx1355j55lj8n9wszqjq1j640000gn/T/vagrant-shell20180418-2363-fe5fuu.sh

default: INSTALLER: Started up

default: Resolving Dependencies

default: --> Running transaction check

default: ---> Package acl.x86_64 0:2.2.51-12.el7 will be updated

default: ---> Package acl.x86_64 0:2.2.51-14.el7 will be an update

default: ---> Package acpid.x86_64 0:2.0.19-8.el7 will be updated

default: ---> Package acpid.x86_64 0:2.0.19-9.el7 will be an update

default: ---> Package audit-libs.x86_64 0:2.7.6-3.el7 will be updated

default: ---> Package audit-libs.x86_64 0:2.8.1-3.el7 will be an update

default: ---> Package bash.x86_64 0:4.2.46-29.el7_4 will be updated

default: ---> Package bash.x86_64 0:4.2.46-30.el7 will be an update

default: ---> Package bind-libs-lite.x86_64 32:9.9.4-51.el7_4.2 will be updated

default: ---> Package bind-libs-lite.x86_64 32:9.9.4-61.el7 will be an update

default: ---> Package bind-license.noarch 32:9.9.4-51.el7_4.2 will be updated

...

default: --> Finished Dependency Resolution

default:

default: Dependencies Resolved

default:

default: ================================================================================

default:  Package                     Arch   Version                 Repository     Size

default: ================================================================================

default: Installing:

default:  kernel-uek                  x86_64 4.1.12-124.14.1.el7uek  ol7_UEKR4      46 M

default:  kernel-uek-firmware         noarch 4.1.12-124.14.1.el7uek  ol7_UEKR4     2.5 M

default: Updating:

default:  acl                         x86_64 2.2.51-14.el7           ol7_latest     81 k

default:  acpid                       x86_64 2.0.19-9.el7            ol7_latest     68 k

default:  audit-libs                  x86_64 2.8.1-3.el7             ol7_latest     99 k

...

default: Dependencies Resolved

default:

default: ================================================================================

default:  Package                 Arch   Version                        Repository  Size

default: ================================================================================

default: Installing:

default:  oracle-database-server-12cR2-preinstall

default:                          x86_64 1.0-3.el7                      ol7_latest  19 k

default: Installing for dependencies:

default:  bind-libs               x86_64 32:9.9.4-61.el7                ol7_latest 1.0 M

default:  bind-utils              x86_64 32:9.9.4-61.el7                ol7_latest 204 k

...

default: INSTALLER: Oracle preinstall and openssl complete

default: INSTALLER: Oracle directories created

default: INSTALLER: Environment variables set

default: Archive:  /vagrant/linuxx64_12201_database.zip

default:    creating: /vagrant/database/

default:    creating: /vagrant/database/install/

...

default: Starting Oracle Universal Installer...

default:

default: Checking Temp space: must be greater than 500 MB.   Actual 30233 MB    Passed

default: Checking swap space: must be greater than 150 MB.   Actual 4088 MB    Passed

default: Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-04-18_08-33-54PM. Please wait ...

default: [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.

default:    ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.

default: You can find the log of this install session at:

default:  /opt/oracle/oraInventory/logs/installActions2018-04-18_08-33-54PM.log

default: Prepare in progress.

...

default: Finish Setup successful.

default: The installation of Oracle Database 12c was successful.

default: Please check '/opt/oracle/oraInventory/logs/silentInstall2018-04-18_08-33-54PM.log' for more details.

...

default: Copying database files

default: 1% complete

default: 13% complete

default: 25% complete

default: Creating and starting Oracle instance

default: 26% complete

default: 30% complete

...

default: 100% complete

default: Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

default:

default: SQL*Plus: Release 12.2.0.1.0 Production on Wed Apr 18 20:47:37 2018

default:

default: Copyright (c) 1982, 2016, Oracle.  All rights reserved.

default:

default: Connected to:

default: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

default: SQL>

default: Pluggable database altered.

default: SQL>

default: Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

default: INSTALLER: Database created

default: INSTALLER: Oratab configured

default: Created symlink from /etc/systemd/system/multi-user.target.wants/oracle-rdbms.service to /etc/systemd/system/oracle-rdbms.service.

default: INSTALLER: Created and enabled oracle-rdbms systemd's service

default: INSTALLER: setPassword.sh file setup

default: ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: **********

default: INSTALLER: Installation complete, database ready to use!

Be sure to make a note of the generated password shown at the end of the output.

Next Steps

Connecting to the Database

To connect to your Database, you can either 1) ssh to the VM and interact with the database there; or 2) connect a database tool such as SQL Developer from your host machine to the VM.

1. ssh to the VM and interact with the database

The command vagrant ssh logs you in to the VM. This is another benefit of Vagrant — ssh keys are set up on both the host and the VM so that you can log in without a password. Next, set up the Oracle environment and use sqlplus to connect to the database with a connect string that includes a hostname and a service, in this case, localhost/orclpdb1.

  1. $ vagrant ssh
  2. [vagrant@oracle-12201-vagrant ~]$ . oraenv
  3. ORACLE_SID = [ORCLPDB1] ? ORCLPDB1
  4. ORACLE_HOME = [/home/oracle] ? /opt/oracle/product/12.2.0.1/dbhome_1
  5. ORACLE_BASE environment variable is not being set since this
  6. information is not available for the current user ID vagrant.
  7. You can set ORACLE_BASE manually if it is required.
  8. Resetting ORACLE_BASE to its previous value or ORACLE_HOME
  9. The Oracle base remains unchanged with value /opt/oracle/product/12.2.0.1/dbhome_1
  10. [vagrant@oracle-12201-vagrant ~]$ sqlplus system/<USE PASSWORD GENERATED BY SCRIPT>@localhost/orclpdb1
  11. SQL*Plus: Release 12.2.0.1.0 Production on Wed Apr 18 22:38:20 2018
  12. Copyright (c) 1982, 2016, Oracle.  All rights reserved.
  13. Last Successful login time: Wed Apr 18 2018 22:37:28 +00:00
  14. Connected to:
  15. Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
  16. SQL>

Note: If the generated password has a / or @ in it, you may need to use escaped quotes around the password as follows:

  1. sqlplus system/\"WPEfu/mdpFU=1\"@localhost/orclpdb1

2. Connect the Database from the host system

You'll recall that the Vagrantfile set up port mapping in VirtualBox so that a connection to port 1521 on the local host is re-directed to port 1521 in the VM. This means  you can create a connection in Oracle SQL Developer as follows:

Create a new connection (Fig. 2)

Fig 2. Create a new connection

Unless you changed the defaults in the Vagrantfile, the connection details are (see Fig. 3)

Hostname: localhost

Port: 1521

Service name: orclpdb1

You are now ready to connect to the Database, create database objects and run queries.

Learn from the Database 12c Learning Library

If you are new to Oracle Database or Database 12c, try some of the tutorials in the Database 12c Learning Library.

Use Vagrant to Make and Restore Snapshot of your VM

Oracle VM VirtualBox has a snapshot feature so that you can make a snapshot of your VM in a known, good state and recover this state later.  Using Vagrant's CLI:

  1. $ # shut down the vm first
  2. $ vagrant halt
  3. ==> default: Attempting graceful shutdown of VM...
  4. $ # create a snapshot called "freshdb"
  5. $ vagrant snapshot save freshdb
  6. ==> default: Snapshotting the machine as 'freshdb'...
  7. ==> default: Snapshot saved! You can restore the snapshot at any time by
  8. ==> default: using `vagrant snapshot restore`. You can delete it using
  9. ==> default: `vagrant snapshot delete`.
  10. $ # ...later ... restore the VM, making sure you don't trigger the provisioning steps in the Vagrantfile
  11. $ vagrant snapshot restore freshdb --no-provision
  12. ==> default: Restoring the snapshot 'freshdb'...
  13. ==> default: Clearing any previously set forwarded ports...
  14. ==> default: Fixed port collision for 22 => 2222. Now on port 2200.
  15. ==> default: Clearing any previously set network interfaces...
  16. ==> default: Preparing network interfaces based on configuration...
  17. default: Adapter 1: nat
  18. ==> default: Forwarding ports...
  19. default: 1521 (guest) => 1521 (host) (adapter 1)
  20. default: 5500 (guest) => 5500 (host) (adapter 1)
  21. default: 22 (guest) => 2200 (host) (adapter 1)
  22. ==> default: Running 'pre-boot' VM customizations...
  23. ==> default: Booting VM...
  24. ...

Conclusion

In this tutorial I showed how using only git, Oracle VM VirtualBox, and Vagrant you can perform an automated installation of Oracle Database 12c on your development machine.

Quick and Easy Installation of Oracle Database 12c on Oracle Linux in Oracle VM VirtualBox的更多相关文章

  1. Oracle Database 12c Preinstall Steps for Oracle Linux Simplified

    This post is a quick reminder that Oracle Linux includes a handy RPM to address pre-installation req ...

  2. [翻译] Oracle Database 12c 新特性Multitenant

    译自官方白皮书http://www.oracle.com/technetwork/database/plug-into-cloud-wp-12c-1896100.pdf,包含新的云计算相关技术的介绍. ...

  3. Oracle Database 12c Release 1 Installation On Oracle Linux 6.4 x86_64

    Create groups and users [root@vmdb12c ~]# groupadd oinstall [root@vmdb12c ~]# groupadd dba [root@vmd ...

  4. 12 Things Developers Will Love About Oracle Database 12c Release 2

    by Chris Saxon-Oracle It's Here: Oracle Database 12c Release 2 (12.2) Is available on Oracle Cloud. ...

  5. Oracle Database 12c Data Redaction介绍

    什么是Data Redaction Data Redaction是Oracle Database 12c的高级安全选项之中的一个新功能,Oracle中国在介绍这个功能的时候,翻译为“数据编纂”,在EM ...

  6. Oracle Database 12c Release 1下载安装(自身经历)

    1.访问Oracle官网:https://www.oracle.com/index.html,下载Oracle Database 12c Release 1 (注意:File1和File2都要下载!! ...

  7. Oracle Database 12c 新特性 - Pluggable Database

    在Oracle Database 12c中,可组装式数据库 - Pluggable Database为云计算而生.在12c以前,Oracle数据库是通过Schema来进行用户模式隔离的,现在,可组装式 ...

  8. 《Oracle Database 12c DBA指南》第一章 - 基本技能简介

    当前关于12c的中文资料比较少,本人将关于DBA的一部分官方文档翻译为中文,很多地方为了帮助中国网友看懂文章,没有按照原文句式翻译,翻译不足之处难免,望多多指正. 1 基本技能简介 作为一个数据库管理 ...

  9. Linked Server for SQL Server 2012(x64) to Oracle Database 12c(x64)

    因为把两台数据库装了同一台机机器上,所以没有安装oracle Client的部分,Oracle部分使用netca创建的Net Service Name,使用tnsping以及登入方式的确认用户权限的以 ...

随机推荐

  1. ASP.NET 数据绑定到列表控件

    <div> <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox> ...

  2. 【杂谈】Java I/O的底层实现

    前言 Java I/O功能封装的很好,使用起来很方便,就是刚开始学的时候,如果不了解装饰器模式,会被他繁多的类给吓到.用多了也就习惯了,而且现在有很多实用的封装良好的实用类,可直接读写整个文件.开发者 ...

  3. 使用显式的Lock对象取代synchronized关键字进行同步

    Java SE5的java.util.concurrent类库还包含有定义在java.util.concurrent.locks中的显式的互斥机制.Lock对象必须被显式地创建.锁定和释放.因此,它与 ...

  4. Css相关用法个人总结

    Css相关用法个人总结

  5. js设计模式总结4

    链模式 链模式:通过在对象方法中将当前对象返回,实现对同一个对象多个方法的链式调用,从而简化多次调用该对象多个方法时的对该对象的多次引用. 具体不多说:主要是方法最后return this; 委托模式 ...

  6. Git学习笔记4

    现在,远程库已经准备好了,下一步是用命令git clone克隆一个本地库: $ git clone git@github.com:michaelliao/gitskills.git 要克隆一个仓库,首 ...

  7. POJ 3692 Kindergarten(最大团问题)

    题目链接:http://poj.org/problem?id=3692 Description In a kindergarten, there are a lot of kids. All girl ...

  8. [NOI 2016]循环之美

    Description 题库链接 给出十进制下的 \(n,m,k\) ,求 \(\frac{i}{j},i\in[1,n],j\in[1,m]\) 在 \(k\) 进制下不同的纯循环小数个数. 纯循环 ...

  9. leetcode937-java

    937. 重新排列日志文件 一个简单题让我做了将近一个小时去.. 你有一个日志数组 logs.每条日志都是以空格分隔的字串. 对于每条日志,其第一个字为字母数字标识符.然后,要么: 标识符后面的每个字 ...

  10. 【 js 基础 】【 源码学习 】源码设计 (更新了backbone分析)

    学习源码,除了学习对一些方法的更加聪明的代码实现,同时也要学习源码的设计,把握整体的架构.(推荐对源码有一定熟悉了之后,再看这篇文章) 目录结构:第一部分:zepto 设计分析 第二部分:unders ...