How-to run Oracle 12.2 with docker on Ubuntu

栏目: 数据库 · Oracle · 发布时间: 7年前

内容简介:How-to run Oracle 12.2 with docker on Ubuntu

前言

昨天有一位搞 DBA 同学问我会不会用 Docker。Ta 想要在上面跑一个 Oracle 实例。整个过程非常流畅,写篇文章备用。 :)

ENV

# lsb_release -a
Distributor ID: Ubuntu
Description:  Ubuntu 16.04.2 LTS
Release:  16.04
Codename: xenial
 
# Oracle Version Package
linuxx64_12201_database.zip

Install docker

sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install docker-engine -y

Download Oracle Docker Image

Docker Images from Oracle https://github.com/oracle/docker-images

cd ~
git clone git@github.com:oracle/docker-images.git  oracle-images

Download & Upload Oracle

Download page http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

when you download the package, upload it to the ${docker-images}/OracleDatabase/dockerfiles/x.x.x.x/

du -sh ./oracle-images/OracleDatabase/dockerfiles/12.2.0.1/* | grep zip
3.3G    ./oracle-images/OracleDatabase/dockerfiles/12.2.0.1/linuxx64_12201_database.zip

接下来,开始无脑安装。因为有一些依赖包需要安装,请确保 REPO & 网络可用。

Build Docker Image

# bash oracle-images/OracleDatabase/dockerfiles/buildDockerImage.sh -v 12.2.0.1 -e 
 
# bash oracle-images/OracleDatabase/dockerfiles/buildDockerImage.sh 
 
Usage: buildDockerImage.sh -v [version] [-e | -s | -x] [-i]
Builds a Docker Image for Oracle Database.
  
Parameters:
   -v: version to build
       Choose one of: oracle-images  
   -e: creates image based on 'Enterprise Edition'
   -s: creates image based on 'Standard Edition 2'
   -x: creates image based on 'Express Edition'
   -i: ignores the MD5 checksums
 
* select one edition only: -e, -s, or -x
 
LICENSE CDDL 1.0 + GPL 2.0
 
Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.

整个过程分16步自动完成,具体完成时间取决于系统环境配置。

成功的日志类似如下的:

Oracle Database Docker Image for 'ee' version 12.2.0.1 is ready to be extended: 
 
--> oracle/database:12.2.0.1-ee
 
build completed in 50235 second

Check Image

$sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
oracle/database     12.2.0.1-ee         2b8746d2b5a0        23 hours ago        14.8GB
oraclelinux         7-slim              0b44f4e6980d        13 days ago         114MB

Run Oracle

docker run --name oracle
-p 1521:1521 
-p 5500:5500
-v /opt/oracle/oradata:/opt/oracle/oradata
oracle/database:12.2.0.1-ee
 
 
##########################################
docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_SID=<your SID> \
-e ORACLE_PDB=<your PDB name> \
-e ORACLE_PWD=<your database passwords> \
-e ORACLE_CHARACTERSET=<your character set> \
-v [<host mount point>:]/opt/oracle/oradata \
oracle/database:12.2.0.1-ee
 
Parameters:
   --name:        The name of the container (default: auto generated)
   -p:            The port mapping of the host port to the container port. 
                  Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)
   -e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)
   -e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1)
   -e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
   -e ORACLE_CHARACTERSET:
                  The character set to use when creating the database (default: AL32UTF8)
   -v             The data volume to use for the database.
                  Has to be owned by the Unix user "oracle" or set appropriately.
                  If omitted the database will not be persisted over container recreation.

Changing the admin accounts passwords

# ./OracleDatabase/dockerfiles/12.2.0.1/setPassword.sh
docker exec <container name> ./setPassword.sh <your password>

更多信息 详见 https://github.com/oracle/docker-images/tree/master/OracleDatabase

$sudo docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                                            NAMES
aba4fc65f3e7        oracle/database:12.2.0.1-ee   "/bin/sh -c 'exec ..."   7 hours ago         Up 2 hours          0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp   oracle

Oracle SQL Developer Test

How-to run Oracle 12.2 with docker on Ubuntu

How-to run Oracle 12.2 with docker on Ubuntu

至此,一个基于 Docker 的简单测试环境构建完成。

~ EOF ~

Reference

[0] https://github.com/oracle/docker-images

[1] https://github.com/oracle/docker-images/tree/master/OracleDatabase


以上所述就是小编给大家介绍的《How-to run Oracle 12.2 with docker on Ubuntu》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

决战大数据

决战大数据

车品觉 / 浙江人民出版社 / 2014-3-1 / 45.9

[内容简介]  大数据时代的来临,给当今的商业带来了极大的冲击,多数电商人无不“谈大数据色变”,并呈现出一种观望、迷茫、手足无措的状态。车品觉,作为一名经验丰富的电商人,在敬畏大数据的同时,洞悉到了数据时代商业发展的更多契机,他创新了数据框架的建立和使用,重新量化了数据价值的指标,并挖掘了在无线数据和多屏时代下商业发展的本质……在他看来,改变思维方式,即可改变数据和商业的未来。  ......一起来看看 《决战大数据》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码