Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching, Zero-Downtime Upgrade, GoldenGate

Oracle Exadata ,Oracle ODA, Oracle ZDLRA


当前位置: 首页 » 技术文章 » Cloud

Vagrant with oracle

Vagrant是一款用于构建及配置虚拟开发环境的软件,基于Ruby,主要以命令行的方式运行。主要使用Oracle的开源VirtualBox虚拟化系统,与Chef,Salt,Puppet等环境配置管理软件搭配使用, 可以实行快速虚拟开发环境的构建。

需要安装的软件

  1. Install Oracle VM VirtualBox
  2. Install Vagrant
通过下面的几条命令就可以快速的部署一个操作系统
$ vagrant box add --name <name> <url>
$ vagrant init <name>
$ vagrant up
$ vagrant ssh
For example:
$ vagrant box add --name ol76 https://yum.oracle.com/boxes/oraclelinux/ol76/ol76.box
$ vagrant init ol76
$ vagrant up
$ vagrant ssh

To verify the checksum of the downloaded box:
$ vagrant box add --name ol76 --checksum 4ba496525f44bd2ad4f741c4a9328cdb78f606b0c87df7125e6a32b33b808a8e \
--checksum-type sha256 https://yum.oracle.com/boxes/oraclelinux/ol76/ol76.box
下面是在windows上快速构建的样本
C:\>vagrant box add --name ol76 https://yum.oracle.com/boxes/oraclelinux/ol76/ol76.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ol76' (v0) for provider:
    box: Downloading: https://yum.oracle.com/boxes/oraclelinux/ol76/ol76.box
    box: Progress: 100% (Rate: 944k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'ol76' (v0) for 'virtualbox'!
C:\>vagrant init ol76
The user that is running Vagrant doesn't have the proper permissions
to write a Vagrantfile to the specified location. Please ensure that
you call `vagrant init` in a location where the proper permissions
are in place to create a Vagrantfile.

C:\>cd C:\Users\nini\.vagrant.d

C:\Users\nini\.vagrant.d>vagrant init ol76
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

C:\Users\nini\.vagrant.d>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ol76'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: vagrantd_default_1550648895681_55990
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

  https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

  VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

  config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.2.22
    default: VirtualBox Version: 6.0
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/nini/.vagrant.d
进入构建的环境
C:\Users\nini\.vagrant.d>vagrant ssh
Last login: Wed Nov 14 15:03:15 2018 from 10.0.2.2
Last login: Wed Nov 14 15:03:15 2018 from 10.0.2.2

Welcome to Oracle Linux Server release 7.6 (GNU/Linux 4.14.35-1818.4.5.el7uek.x86_64)

The Oracle Linux End-User License Agreement can be viewed here:

    * /usr/share/eula/eula.en_US

For additional packages, updates, documentation and community help, see:

    * http://yum.oracle.com/

[vagrant@localhost ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fed0:4f43  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:d0:4f:43  txqueuelen 1000  (Ethernet)
        RX packets 626  bytes 79592 (77.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 458  bytes 81419 (79.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 64  bytes 5440 (5.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64  bytes 5440 (5.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[vagrant@localhost ~]$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[vagrant@localhost ~]$ id root
uid=0(root) gid=0(root) groups=0(root)
[vagrant@localhost ~]$ su -
Last login: Wed Nov 14 15:03:16 UTC 2018 on pts/0

[root@localhost ~]#

下一步就可以用常规方法部署数据库了,如果想快,也可以用docker
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/oracle/product/192
chown -R oracle: /u01/app/oraInventory
chown -R oracle: /u01/app/oracle
su - oracle

如果想定制用vagrant构建的box,可以通过Vagrantfile来设置,比如机器名、ip地址等等

https://www.vagrantup.com/docs/vagrantfile/machine_settings.html

如何通过vagrant够快kubernetes集群

https://github.com/oracle/vagrant-boxes/tree/master/Kubernetes


其他有用的docker工具,比如Docker Toolbox(包含boot2docker,kitematic),不是Docker for windows

https://docs.docker.com/toolbox/toolbox_install_windows/

https://download.docker.com/win/stable/DockerToolbox.exe

https://github.com/boot2docker
https://docs.docker.com/toolbox/
https://kitematic.com/
https://github.com/docker/kitematic


Reference

https://www.vagrantup.com/

https://zh.wikipedia.org/wiki/Vagrant

https://github.com/hashicorp/vagrant

https://github.com/oracle/vagrant-boxes/

https://yum.oracle.com/boxes
https://www.vagrantup.com/docs/cli/box.html
https://blogs.oracle.com/scoter/vbox-ga-rpms
https://blogs.oracle.com/linux/latest-oracle-linux-75-and-610-vagrant-boxes-now-available

https://github.com/hashicorp/vagrant/issues/10335


关键词:vagrant cloud oracle 

相关文章

Oracle Database 23ai初体验
Oracle GoldenGate 23ai for Oracle和PG发布了
Oracle 23ai发布了
Oracle宣布推出全球分布式自治数据库
Oracle 23c新特性---开发人员
Oracle 23c free FAQ
Oracle 23c free and OCI Base Service
Oracle 21c
基于PDB的Active Data Guard(Oracle 21.7+)
在Oracle数据库中使用REST
OGG from MySQL to Oracle
Oracle数据库容灾之两地三中心实践
Top