1. 程式人生 > >mac os下使用 Docker安裝oracle-xe-11g資料庫

mac os下使用 Docker安裝oracle-xe-11g資料庫

一、安裝docker

在mac os需要通過docker-toolbox安裝docker 你可以在這裡下載

下載對應版本的pkg檔案 雙擊開啟安裝

如圖


next 安裝即可 

安裝完後 你的Application中多出來這兩項

如圖


其中 第一項是docker 命令列介面 第二項是docker gui操作介面 屬於內測版本 

在這裡我們使用 Terminal

單擊開啟Docker Terminal

它會自動初始化 並且為我們建立一個名為 default 的docker-machine 

如圖


這時候彆著急安裝oracle  我們需要給我們的docker設定國內映象

接下來我們初始化環境變數

eval "$(boot2docker shellinit)"

測試一下docker是否安裝成功

docker run hello-world

控制檯輸出 如下 表示安裝成功

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

3. The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it

to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

https://cloud.docker.com/

For more examples and ideas, visit:

https://docs.docker.com/engine/userguide/

此時我們的docker已經安裝成功了  這時候就可以pull我們的oracle 11g資料庫了

#下載映象

docker pull alexeiled/docker-oracle-xe-11g

#啟動映象為一個容器,並命名為oracle

docker run -h "oracle" --name "oracle" -d -p 49160:22 -p 49161:1521 -p 49162:8080 alexeiled/docker-oracle-xe-11g

此時 oracle已經被安裝到我們docker

我們可以 docker ps 一下 


49160是我們用ssh連線對應的埠

49161是我們連線sqlplus對應的埠

49162是我們連線oem對應的埠

oracle資料庫連線對應資訊

hostname: 192.168.99.100(通過boot2docker ip獲取)

port: 49161

sid: xe

username: system

password: oracle

SYS的密碼oracle

接下來我們啟動容器 並進入sqlplus介面

使用docker exec -it <CONTAINER> <COMMAND>:在容器裡執行命令,並輸出結果

docker exec -it 0deb75d61474  /bin/bash

其中  0deb75d61474 是我們的containerID 

可以通過docker ps查詢容器資訊

接下來我們可以進入sqlplus介面 

如圖


此時代表我們mac os 使用docker 安裝 oracle 11g已經成功了