工作中需要频繁使用Oracle环境,但是每次搭建起来比较消耗时间,本想通过虚拟机模板的方式来快速安装oracle vm,但是每次改ip等环境也很耗时,因此想到docker中有没有已经做好的images,这样就能快速获得Oracle环境。
root@- rac1:docker search oracle INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/wnameless/oracle-xe-11g Oracle Express 11g R2 on Ubuntu 16.04 LTS [OK] docker.io docker.io/oraclelinux Oracle Linux is an open-source operating s... [OK] docker.io docker.io/alexeiled/docker-oracle-xe-11g This is a working (hopefully) Oracle XE ... [OK] docker.io docker.io/sath89/oracle-12c Oracle Standard Edition 12c Release with... [OK] docker.io docker.io/sath89/oracle-xe-11g Oracle xe 11g with database files mount su... [OK] docker.io docker.io/isuper/java-oracle This repository contains all java releases... [OK] docker.io docker.io/jaspeen/oracle-11g Docker image for Oracle 11g database [OK] docker.io docker.io/oracle/oraclelinux Oracle Linux is an open-source operating s... [OK] docker.io docker.io/ingensi/oracle-jdk Official Oracle JDK installed on CentOS. [OK] docker.io docker.io/airdock/oracle-jdk Docker Image for Oracle Java SDK ( and )... [OK] docker.io docker.io/oracle/openjdk Docker images containing OpenJDK Oracle Linux [OK] docker.io docker.io/cogniteev/oracle-java Oracle JDK , , , and based on Ubuntu ... [OK] docker.io docker.io/n3ziniuka5/ubuntu-oracle-jdk Ubuntu with Oracle JDK. Check tags for ver... [OK] docker.io docker.io/andreptb/oracle-java Debian Jessie based image with Oracle JDK ... [OK] docker.io docker.io/oracle/glassfish GlassFish Java EE Application Server on Or... [OK] docker.io docker.io/oracle/nosql Oracle NoSQL on a Docker Image with Oracle... [OK] docker.io docker.io/infogene/oracle Image for running Oracle Database 11g Stan... [OK] docker.io docker.io/openweb/oracle-tomcat A fork off of Official tomcat image with O... [OK] docker.io docker.io/flurdy/oracle-java7 Base image containing Oracle's Java 7 JDK 4 [OK] docker.io docker.io/jtech/oracle-jdk A Docker image based on the smallest Linux... [OK] docker.io docker.io/davidcaste/debian-oracle-java Oracle Java (and ) over Debian Jessie [OK] docker.io docker.io/kaluzki/oracle kaluzki/oracle [OK] docker.io docker.io/clincase/oracle clincase oracle db server image [OK] docker.io docker.io/jckrz/debian-oracle-jdk Vanilla Debian + Oracle JDK [OK] docker.io docker.io/publicisworldwide/oracle-core This is the core image based on Oracle Lin... [OK]
可以看到有很多版本,11g,12c
这里选择获取12c版本
root@- rac1:/home/# docker pull sath89/oracle-12c Using default tag: latest latest: Pulling from sath89/oracle-12c 863735b9fd15: Pull complete 4fbaa2f403df: Pull complete faadd00cf98e: Downloading [=======> ] 394.8 MB/2.768 GB 829e2e754405: Download complete root@- rac1:/home/# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/sath89/oracle-12c latest b8bf52883bc7 weeks ago 5.692 GB
使用刚刚下载下来的12g image创建一个container,并运行其上的oracle数据库
docker run -d -p : -p : -v /my/oracle/data:/u01/app/oracle sath89/oracle-12c
[root@-rac1 ~]# docker logs -f ffbeb07058449672c640ddb4e59b8376dae2e3b4dd54142871da7adbc069ee79 ls: cannot access /u01/app/oracle/oradata: No such file or directory Database not initialized. Initializing database. Starting tnslsnr Copying database files % complete % complete Creating and starting Oracle instance % complete % complete % complete Completing Database Creation % complete % 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! ;)
到这里Oracle实例就已经启动好了
可以看到创建的container已经在运行中
[root@-rac1 ~]~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9e893d773494 sath89/oracle-12c "/entrypoint.sh " minutes ago Up minutes 0.0.0.0:->/tcp, 0.0.0.0:->/tcp clever_chandrasekhar 进入oracle container [root@-rac1 ~]~$ docker exec -it 9e893d773494 /bin/bash root@9e893d773494:/# su oracle oracle@9e893d773494:~$ $ORACLE_HOME/bin/sqlplus / as sysdba SQL*Plus: Release 12.1.0.2. Production on Fri Feb :: Copyright (c) , , Oracle. All rights reserved. SQL> Oracle 使用的实例名,用户名,密码如下 --------------------------------------------- hostname: localhost port: sid: xe username: system password: oracle
---------------------------------------------
接下来就可以快速使用Oracle12C了
更多Docker相关教程见以下内容:
Docker安装应用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm
Ubuntu 14.04安装Docker http://www.linuxidc.com/linux/2014-08/105656.htm
Ubuntu使用VNC运行基于Docker的桌面系统 http://www.linuxidc.com/Linux/2015-08/121170.htm
64位 CentOS下安装与启动 Docker http://www.linuxidc.com/Linux/2017-03/141714.htm
Ubuntu 15.04下安装Docker http://www.linuxidc.com/Linux/2015-07/120444.htm
在Ubuntu Trusty 14.04 (LTS) (64-bit)安装Docker http://www.linuxidc.com/Linux/2014-10/108184.htm
在 Ubuntu 15.04 上如何安装Docker及基本用法 http://www.linuxidc.com/Linux/2015-09/122885.htm
Ubuntu 16.04上Docker使用手记 http://www.linuxidc.com/Linux/2016-12/138490.htm
Docker 的详细介绍:请点这里
Docker 的下载地址:请点这里
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-03/141760.htm