環境:
2G 內存,60G 硬盤阿里云一臺(帶寬 1M), 配置如下圖:
軟件:docker
Docker version 1.6.2, build 7c8fca2
相關 link
docker 鏡像站:https://store.docker.com
視頻教程:https://asciinema.org/a/45878(oracle 12c)
步驟
1: 在鏡像站搜索 oracle, 第一頁有兩個(12c 和 11g) ,12c 太大了,要 3 個 G 且下載時間太長,我下載的是 11g
shell:docker pull wnameless/oracle-xe-11g
可以下載舊版:docker pull wnameless/oracle-xe-11g:14.04.4
2: 運行鏡像文件
shell:docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
映射了兩個端口出來。
鏡像網站上說:Run this, if you want the database to be connected remotely:(遠程連接)
得加-e ORACLE_ALLOW_REMOTE=true
3: 查看這個鏡像運行 log
shell:docker logs -f b97da5ba40541b28b05c4b799761f77aa6284f842ef696c16926bbc14a0d2627
4: 進入容器
Login by SSH : ssh root@localhost -p 49160
密碼: admin
5: 切換用戶, 連接 oracle
shell: su oracle
shell: cd $ORACLE_HOME
shell: bin/sqlplus / as sysdba
6: 測試 sql
7: 新建用戶
shell:create user test identified by 123456
shell: grant dba to test;
8: 新建表空間
shell:create tablespace TEST datafile '/u01/app/oracle/test/test.dbf' size 100M;
shell:create user TEST identified by TEST123 default tablespace TEST;
如果這個 TEST 用戶在其他表空間已存請先刪除
shell:drop user TEST cascade
然后給連接,dba 權限
shell:grant connect,resource to TEST;
shell:grant dba to TEST;
?
轉自:https://hacpai.com/article/1492914187689
?
?