使用Vagrant 快速安装Oracle Database 18c

版权声明:本文为Buddy Yuan原创文章,未经允许不得转载。原文地址:http://www.dboracle.com/archivers/使用Vagrant 快速安装Oracle Database 18c.html
首先介绍一下vagrant,Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境。它使用Oracle的开源VirtualBox虚拟化系统,使用 Chef创建自动化虚拟环境。 而Oracle最近推出了Oracle 18c数据库,现在可以在带有Vagrant的GitHub存储库中使用。在几分钟内,我们可以为这个要求准备好具有DB的VM,用于沙盒测试和QA环境。那么接下来我们来实际安装一下。
前提条件
1.安装Oracle VirtualBox
2.安装Vagrant
3.下载Oracle 18c安装介质
4.下载来自GitHub的Vagrant配置文件
在成功安装VirtualBox和Vagrant之后,我们需要下载或者是克隆GitHub上的配置文件,这里我使用的是windows上安装的Git Bash。运行命令:git clone https://github.com/oracle/vagrant-boxes。运行成功后会自动把配置文件下载下来,并存放在Git Bash软件的根目录下。

接下来我们把配置文件拷贝到一个单独的文件夹下面,同时我们需要把Oracle 18c的安装介质存放到vagrant-boxes\OracleDatabase\18.3.0这个目录下,如图所示:

上述操作完成之后,我们先来测试一下我们的Vagrant命令是否可以使用。

PS C:\Users\Administrator> vagrant -h
Usage: vagrant [options]  []

    -v, --version                    Print the version and exit.
    -h, --help                       Print this help.

Common commands:
     box             manages boxes: installation, removal, etc.
     destroy         stops and deletes all traces of the vagrant machine
     global-status   outputs status Vagrant environments for this user
     halt            stops the vagrant machine
     help            shows the help for a subcommand
     init            initializes a new Vagrant environment by creating a Vagrantfile
     login           log in to HashiCorp's Vagrant Cloud
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     port            displays information about guest port mappings
     powershell      connects to machine via powershell remoting
     provision       provisions the vagrant machine
     push            deploys code in this environment to a configured destination
     rdp             connects to machine via RDP
     reload          restarts vagrant machine, loads new Vagrantfile configuration
     resume          resume a suspended vagrant machine
     snapshot        manages snapshots: saving, restoring, etc.
     ssh             connects to machine via SSH
     ssh-config      outputs OpenSSH valid configuration to connect to the machine
     status          outputs status of the vagrant machine
     suspend         suspends the machine
     up              starts and provisions the vagrant environment
     validate        validates the Vagrantfile
     version         prints current and latest Vagrant version

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.

接下来我们要到刚刚配置好的G:\VM DATA\vagrant-boxes\OracleDatabase\18.3.0目录去运行vagrant up。也就是上面的starts and provisions the vagrant environment。不过我在运行这个命令的时候出了一点小问题,默认vagrant是依赖Windows的powershell的。然后报错提示powershell的版本是2,需要版本为3。然后我check了一下,的确我的版本是2。然后在百度上搜索了一下,首先需要安装.NET 4.0或者.NET 4.5。然后在安装Microsoft Windows Management Framework 3.0的6.1内核版本安装文件,链接在这里。默认我已经安装了.NET 4.0框架,我没有安装3.0的6.1内核版本安装文件。我把链接的补丁下载下来安装好了之后再次check版本就变成3了。

The version of powershell currently installed on this host is less than the required minimum version. Please upgrade the installed version of powershell to the minimum required version and run the command again.

PS C:\Users\Administrator> get-host
Name             : ConsoleHost
Version          : 2.0
InstanceId       : 2dae0b07-3120-4576-b81b-fa329f22a38f
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : zh-CN
CurrentUICulture : zh-CN
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

安装了3.0的6.1内核版本安装文件之后,再次check。

PS C:\Users\Administrator> get-host

Name             : ConsoleHost
Version          : 3.0
InstanceId       : d1c831a7-e985-403f-88cd-c338b212864a
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : zh-CN
CurrentUICulture : zh-CN
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

然后再次运行vagrant up,这次一切顺利。然后就开始构建环境了。最后安装完成之后会提示:INSTALLER: Installation complete, database ready to use.


现在,我们可以检查Vagrant是否已启动。

PS G:\VM DATA\vagrant-boxes\OracleDatabase\18.3.0> Vagrant global-status
id       name               provider   state   directory
----------------------------------------------------------------------------------------------
eacde45  oracle-18c-vagrant virtualbox running G:/VM DATA/vagrant-boxes/OracleDatabase/18.3.0
分享到: 更多

Trackbacks & Pingbacks 1

  1. From 通过Vagrant访问Oracle 18c数据库 | Buddy Yuan的个人技术博客 on 01 10月 2018 at 15:50

    […] 版权声明:本文为Buddy Yuan原创文章,未经允许不得转载。原文地址:http://www.dboracle.com/archivers/通过Vagrant访问Oracle 18c数据库.html […]

Post a Comment

Your email is never published nor shared. Required fields are marked *