Docker Oracle11g
安装 Docker
- docker pull wnameless/oracle-xe-11g
下载镜像
docker pull wnameless/oracle-xe-11g
Using default tag: latest
latest: Pulling from wnameless/oracle-xe-11g
a48c500ed24e: Pull complete
1e1de00ff7e1: Pull complete
0330ca45a200: Pull complete
471db38bcfbf: Pull complete
0b4aba487617: Pull complete
ae2e6e303543: Pull complete
e860d792de52: Pull complete
Digest: sha256:806c005a3d6af211e92b96015daaeefdcde53b7b6434d34353e620fb46ea7dad
Status: Downloaded newer image for wnameless/oracle-xe-11g:latest
Using default tag: latest
latest: Pulling from wnameless/oracle-xe-11g
a48c500ed24e: Pull complete
1e1de00ff7e1: Pull complete
0330ca45a200: Pull complete
471db38bcfbf: Pull complete
0b4aba487617: Pull complete
ae2e6e303543: Pull complete
e860d792de52: Pull complete
Digest: sha256:806c005a3d6af211e92b96015daaeefdcde53b7b6434d34353e620fb46ea7dad
Status: Downloaded newer image for wnameless/oracle-xe-11g:latest
查看当前镜像
root@debian:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos6/fake latest d9791d553a78 21 hours ago 1.33GB
wnameless/oracle-xe-11g latest 698cc7361de4 7 months ago 2.13GB
alexeiled/docker-oracle-xe-11g latest f7304758169d 2 years ago 2.39GB
REPOSITORY TAG IMAGE ID CREATED SIZE
centos6/fake latest d9791d553a78 21 hours ago 1.33GB
wnameless/oracle-xe-11g latest 698cc7361de4 7 months ago 2.13GB
alexeiled/docker-oracle-xe-11g latest f7304758169d 2 years ago 2.39GB
以镜像wnameless/oracle-xe-11g 启动容器
docker run -d -p 9090:8080 -p 1521:1521 -3222:22 –name Oracle11g wnameless/oracle-xe-11g
查看容器是否运行
root@debian:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9a88cc47e3b wnameless/oracle-xe-11g “/bin/sh -c ‘/usr/sb…” 3 seconds ago Up 3 seconds 0.0.0.0:1521->1521/tcp, 0.0.0.0:3122->22/tcp, 0.0.0.0:9090->8080/tcp Oracle11g
9fb4edcca9f2 centos6/fake “/bin/bash” 21 hours ago Up 21 hours 0.0.0.0:2233->22/tcp, 0.0.0.0:8080->80/tcp, 0.0.0.0:3388->3306/tcp CentOS6-LAMP-WEB
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9a88cc47e3b wnameless/oracle-xe-11g “/bin/sh -c ‘/usr/sb…” 3 seconds ago Up 3 seconds 0.0.0.0:1521->1521/tcp, 0.0.0.0:3122->22/tcp, 0.0.0.0:9090->8080/tcp Oracle11g
9fb4edcca9f2 centos6/fake “/bin/bash” 21 hours ago Up 21 hours 0.0.0.0:2233->22/tcp, 0.0.0.0:8080->80/tcp, 0.0.0.0:3388->3306/tcp CentOS6-LAMP-WEB
可以看到容器已成功运行 接下来连接容器:
root@debian:~# docker exec -ti c9a88cc47e3b bash
Oracle XE 使用
http://192.168.5.159:9090
username: ADMIN
password: Oracle_11g
or
username: system
password: oracle
username: ADMIN
password: Oracle_11g
or
username: system
password: oracle
条件环境变量:
- vim /root/.profile
- export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
- export ORACLE_SID=hellooracle
- export PATH=$PATH:$ORACLE_HOME/bin
- source /root/.profile
进入 Oracle 用户 登陆数据库
su – oracle
sqlplus /nolog
SQL*Plus: Release 11.2.0.2.0 Production on Fri Dec 28 08:07:40 2018Copyright (c) 1982, 2011, Oracle. All rights reserved.
sqlplus /nolog
SQL*Plus: Release 11.2.0.2.0 Production on Fri Dec 28 08:07:40 2018Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn sys/sys as sysdba
Connected.
创建表空间
1 创建临时表
CREATE SMALLFILE TEMPORARY TABLESPACE “TS_MSG_TEMP” TEMPFILE ‘/u01/app/oracle/oradata/XE/TS_MSG_TEMP.dbf’ SIZE 1024M AUTOEXTEND ON NEXT 100M TABLESPACE GROUP “TS_MSG” EXTENT MANAGEMENT LOCAL UNIFORM;
2 创建永久表
CREATE SMALLFILE TABLESPACE “TS_MSG_D” DATAFILE ‘/u01/app/oracle/oradata/XE/TS_MSG_D.dbf’ SIZE 2048M AUTOEXTEND ON NEXT 100M LOGGING DEFAULT NOCOMPRESS ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO;
3 创建用户
create user USR_MSG IDENTIFIED BY asdf123123 default tablespace TS_MSG_D temporary tablespace TS_MSG_TEMP profile DEFAULT;
4 授权
- grant connect to USR_MSG;
- grant dba to USR_MSG;
- grant exp_full_database to USR_MSG;
- grant imp_full_database to USR_MSG;
- grant resource to USR_MSG;
- — Grant/Revoke system privileges
- grant select any table to USR_MSG;
- grant unlimited tablespace to USR_MSG;
- grant update any table to USR_MSG;
查询 oracle 服务名称
SQL> select instance_name from v$instance;
INSTANCE_NAME
—————-
XE
本地连接 Oracle
我是用的 Nacicat Premium
参考:https://github.com/wnameless/docker-oracle-xe-11g
https://blog.csdn.net/zhichunqi/article/details/80656780