Oracle 安装 docker,使用docker安装Oracle 12c database(一)

首先在Ubuntu16.04安装好Docker软件,然后开始搜索Oracle的镜像。这里我们可以使用search命令搜索。可以发现在docker的镜像里面搜索到sath89创建的Oracle镜像。

postgres@postgres-N65S01:~$ sudo docker search oracle

NAME DESCRIPTION STARS OFFICIAL AUTOMATED

oraclelinux Official Docker builds of Oracle Linux. 446 [OK]

frolvlad/alpine-oraclejdk8 The smallest Docker image with OracleJDK 8 (… 301 [OK]

sath89/oracle-12c Oracle Standard Edition 12c Release 1 with d… 288 [OK]

alexeiled/docker-oracle-xe-11g This is a working (hopefully) Oracle XE 11.2… 249 [OK]

sath89/oracle-xe-11g Oracle xe 11g with database files mount supp… 178 [OK]

isuper/java-oracle This repository contains all java releases f… 55 [OK]

wnameless/oracle-xe-11g Dockerfile of Oracle Database Express Editio… 51 [OK]

oracle/glassfish GlassFish Java EE Application Server on Orac… 42 [OK]

oracle/openjdk Docker images containing OpenJDK Oracle Linux 37 [OK]

airdock/oracle-jdk Docker Image for Oracle Java SDK (8 and 7) b… 30 [OK]

ingensi/oracle-jdk Official Oracle JDK installed on centos. 21 [OK]

cogniteev/oracle-java Oracle JDK 6, 7, 8, and 9 based on Ubuntu 16… 20 [OK]

n3ziniuka5/ubuntu-oracle-jdk Ubuntu with Oracle JDK. Check tags for versi… 16 [OK]

oracle/nosql Oracle NoSQL on a Docker Image with Oracle L… 15 [OK]

sgrio/java-oracle Docker images of Java 7/8/9 provided by Orac… 11 [OK]

collinestes/docker-node-oracle A container with Node.js/Oracle instant clie… 10 [OK]

openweb/oracle-tomcat A fork off of Official tomcat image with Ora… 7 [OK]

andreptb/oracle-java Debian Jessie based image with Oracle JDK in… 7 [OK]

flurdy/oracle-java7 Base image containing Oracle's Java 7 JDK 5 [OK]

martinseeler/oracle-server-jre Oracle's Java 8 as 61 MB Docker container. 4 [OK]

davidcaste/debian-oracle-java Oracle Java 8 (and 7) over Debian Jessie 3 [OK]

teradatalabs/centos6-java8-oracle Docker image of CentOS 6 with Oracle JDK 8 i… 3

spansari/nodejs-oracledb nodejs with oracledb installed globally on o… 2

publicisworldwide/oracle-core This is the core image based on Oracle Linux… 1 [OK]

softwareplant/oracle oracle db 0 [OK]

我们选择拉12c数据库镜像

postgres@postgres-N65S01:~$ sudo docker pull sath89/oracle-12c

Using default tag: latest

latest: Pulling from sath89/oracle-12c

863735b9fd15: Pull complete

4fbaa2f403df: Pull complete

44be94a95984: Pull complete

a3ed95caeb02: Pull complete

b8bc6e8767ee: Pull complete

c918da326197: Pull complete

448e1619a038: Pull complete

faadd00cf98e: Pull complete

94c8eec9fdf0: Pull complete

58e66654f771: Pull complete

Digest: sha256:a0f6f1cfd3738b0c00f4025a656335b53c205b3bfc0722908ee7b1469111665b

Status: Downloaded newer image for sath89/oracle-12c:latest

镜像有点大,拉完之后查看镜像

postgres@postgres-N65S01:~$ sudo docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

hello-world latest e38bc07ac18e 3 weeks ago 1.85kB

sath89/oracle-12c latest 17cd1ab9d9a7 4 months ago 5.7GB

接下来创建一个容器,并运行Oracle 12c。这里需要参考网站https://hub.docker.com/r/sath89/oracle-12c/的内容。

运行容器有三种运行方式。

1.直接运行在8080和1521端口

docker run -d -p 8080:8080 -p 1521:1521 sath89/oracle-12c

2.在主机上运行数据并能够重用

docker run -d -p 8080:8080 -p 1521:1521 -v /my/oracle/data:/u01/app/oracle sath89/oracle-12c

3.使用自定于的DBCA_TOTAL_MEMORY运行

docker run -d -p 8080:8080 -p 1521:1521 -v /my/oracle/data:/u01/app/oracle -e DBCA_TOTAL_MEMORY=1024 sath89/oracle-12c

我使用第二种,第二种可以把创建的数据库保存在本地。这里我先创建一个文件夹用于持久保存数据。

sudo mkdir -p /u01/app/oracle

然后运行创建实例和数据库

sudo docker run -d -p 8080:8080 -p 1521:1521 -v /u01/app/oracle:/u01/app/oracle sath89/oracle-12c

81d5d58574c08b0f35fa57e7c1ff1cc06e8f1bcb918d42887de2bee5d83ad119

运行上述命令会有一串字母,这里可以通过这串字母查看创建期间的日志。

docker logs -f 81d5d58574c08b0f35fa57e7c1ff1cc06e8f1bcb918d42887de2bee5d83ad119

Database not initialized. Initializing database.

Starting tnslsnr

Copying database files

1% complete

3% complete

11% complete

18% complete

26% complete

33% complete

37% complete

Creating and starting Oracle instance

40% complete

45% complete

50% complete

55% complete

56% complete

60% complete

62% complete

Completing Database Creation

66% complete

70% complete

73% complete

85% complete

96% complete

100% complete

Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/xe/xe.log" for further details.

Configuring Apex console

Database initialized. Please visit http://#containeer:8080/em http://#containeer:8080/apex for extra configuration if needed

Starting web management console

PL/SQL procedure successfully completed.

Starting import from '/docker-entrypoint-initdb.d':

found file /docker-entrypoint-initdb.d//docker-entrypoint-initdb.d/*

[IMPORT] /entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

Import finished

Database ready to use. Enjoy! 😉

可以看到这里已经创建成功了。接下来我们进入到容器,执行操作。

postgres@postgres-N65S01:~$ sudo docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

81d5d58574c0 sath89/oracle-12c "/entrypoint.sh " 17 minutes ago Up 17 minutes 0.0.0.0:1521->1521/tcp, 0.0.0.0:8080->8080/tcp elegant_mcnulty

进入到容器

postgres@postgres-N65S01:~$ sudo docker exec -it 81d5d58574c0 /bin/bash

root@81d5d58574c0:/# su - oracle

默认Oracle的实例叫xe,没有配置环境变量,需要先运行.oraenv设置环境变量。

oracle@81d5d58574c0:~$ . oraenv

ORACLE_SID = [oracle] ? xe

The Oracle base has been set to /u01/app/oracle

oracle@81d5d58574c0:~$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu May 3 13:52:31 2018

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to:

Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production

SQL> select name,open_mode from v$database;

NAME OPEN_MODE

--------- --------------------

XE READ WRITE

当然你还可以在外面查看em。

http://localhost:8080/em/

分享到:

更多

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值