1 安装 docker
- apt-get install apt-transport-https ca-certificates curl software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- apt-get update
- apt-get install docker-ce
2 搜索选择镜像
- docker search oracle
这里选择 wnameless/oracle-xe-11g 镜像
- docker pull wnameless/oracle-xe-11g
docker images
root@game:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wnameless/oracle-xe-11g latest 698cc7361de4 4 months ago 2.13GB
root@game:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wnameless/oracle-xe-11g latest 698cc7361de4 4 months ago 2.13GB
3 启动容器
本地连接:docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
远程连接:docker run -d -p 49160:22 -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g
远程连接:docker run -d -p 49160:22 -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g
查看容器
docker ps -a
root@game:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c88d60858b3c wnameless/oracle-xe-11g "/bin/sh -c '/usr/sb…" About an hour ago Up About an hour 8080/tcp, 0.0.0.0:49160->22/tcp, 0.0.0.0:49161->1521/tcp loving_galileo
root@game:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c88d60858b3c wnameless/oracle-xe-11g "/bin/sh -c '/usr/sb…" About an hour ago Up About an hour 8080/tcp, 0.0.0.0:49160->22/tcp, 0.0.0.0:49161->1521/tcp loving_galileo
4 连接串信息
- hostname: IP
- port: 49161
- sid: xe
- username: system
- password: oracle
- SYS & SYSTEM
- 密码:oracle
5 进入 Docker 容器 nsenter
- /home/oracle/docker-enter c88d60858b3c
6 创建表空间
#创建表空间testoadb ,定义空间文件目录(基础空间500MB,每次递增100MB,最大4GB)
- SQL>create tablespace testoa datafile '/u01/app/oracle/oradata/XE/testoa.dbf' size 500M autoextend on next 100M maxsize 4000M;
#创建用户testoa 密码设置为testoa1314 ,默认表空间为testoadb --创建用户并指定表空间
- SQL>create user testoa identified by testoa1314 default tablespace testoa;
##创建用户并指定表空间和临时表空间
- CREATE USER caiyl IDENTIFIED BY 123456 DEFAULT TABLESPACE caiyl_space TEMPORARY TABLESPACE caiyl_temp;
#给用户testoa 赋予connect,resource 权限,授予这两个权限就已经可以进行基本操作了,这样可以限制一个用户只能操作自己表空间,无需单独设置其他权限。
- SQL>grant connect,resource to testoa;
- SQL>GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,DBA,CONNECT,RESOURCE,CREATE SESSION TO testoa;
#删除表空间
- DROP TABLESPACE caiyl_space INCLUDING CONTENTS AND DATAFILES;
参考文章:
Ubuntu16.04下部署Oracle docker环境
Oracle创建表空间、创建用户、授予权限、锁定、解锁以及删除用户等
没有评论