1.下载
docker pull absolutapps/oracle-12c-ee
如果官方没有这个镜像了可以下载我的,我上传上去了:
docker pull heidaodageshiwo/oracle-12c-ee:latest
2.查看是否下载
3.启动(你们只需要修改8066这个端口即可)
创建一个文件夹来挂载数据
mkdir -p /var/oracle
启动(ad9bdfc002e7这个是我的镜像的imageid)上图可见
docker run -d -p 8080:8080 -p 8066:1521 -v /var/oracle:/u01/app/oracle --privileged ad9bdfc002e7
是否启动
docker logs -f 6fea41c62a884314c0ac3ceb385eba5a88e5fc5ad69d44791714dbf4baa2965d
启动截图日志:(docker logs -f 可能会很慢,但一定要看,要不然不知道是否启动)
中间可能会遇到 /dev/shm 挂载盘的问题,可自行百度一下
[root@iz2zej4i2jdf3i8bhr61xsz oracle]# docker run -d -p 8080:8080 -p 8066:1521 -v /var/oracle:/u01/app/oracle --privileged ad9bdfc002e7
6fea41c62a884314c0ac3ceb385eba5a88e5fc5ad69d44791714dbf4baa2965d
[root@iz2zej4i2jdf3i8bhr61xsz oracle]# docker logs -f 6fea41c62a884314c0ac3ceb385eba5a88e5fc5ad69d44791714dbf4baa2965d
ls: cannot access /u01/app/oracle/oradata/orcl: No such file or directory
No databases found in /u01/app/oracle/oradata/orcl. About to create a new database instance
Starting database listener
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 19-JAN-2020 02:24:27
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Starting /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.1.0.2.0 - Production
System parameter file is /u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/6fea41c62a88/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=6fea41c62a88)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=6fea41c62a88)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 19-JAN-2020 02:24:27
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/6fea41c62a88/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=6fea41c62a88)(PORT=1521)))
The listener supports no services
The command completed successfully
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 19-JAN-2020 02:29:40
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=6fea41c62a88)(PORT=1521)))
The command completed successfully
Database has been created in /u01/app/oracle/oradata/orcl
SYS and SYSTEM passwords are set to [oracle]
Setting HTTP port to 8080
PL/SQL procedure successfully completed.
Please login to http://<ip_address>:8080/em to use enterprise manager
User: sys; Password oracle; Sysdba: true
Fixing permissions...
Running init scripts...
Init scripts in /oracle.init.d/: Ignoring /oracle.init.d/*
Done with scripts we are ready to go
查看container状态
进入刚刚创建的container中
[root@iz2zej4i2jdf3i8bhr61xsz ~]# docker exec -it 6fea41c62a88 /bin/bash
[root@6fea41c62a88 /]# su oracle
[oracle@6fea41c62a88 /]$ $ORACLE_HOME/bin/sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sun Jan 19 05:20:04 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> conn system/oracle as sysdba;
Connected.
docker exec -it 6fea41c62a88 /bin/bash 进入
su oracle 切到oracle
$ORACLE_HOME/bin/sqlplus / as sysdba 使用sysdba登录
修改密码:
alter user system identified by oracle;
alter user sys identified by sys;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
创建用户
create user test identified by test;
并给用户赋予权限
grant connect,resource,dba to test;
[root@iz2zej4i2jdf3i8bhr61xsz ~]# docker exec -it 6fea41c62a88 /bin/bash
[root@6fea41c62a88 /]# su oracle
[oracle@6fea41c62a88 /]$ $ORACLE_HOME/bin/sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sun Jan 19 05:20:04 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> conn system/oracle as sysdba;
Connected.
SQL> alter user system identified by oracle;
User altered.
SQL> alter user sys identified by sys;
User altered.
SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Profile altered.
SQL> create user test identified by test;
User created.
SQL> grant connect,resource,dba to test;
Grant succeeded.
然后使用Navicat链接
点击TEST右键打开模式
我自己创建了一张表
4年了没有用oracle了不知道为啥登录上来就是一个TEST
而且oracle这块 表空间还有用户这块都忘了。 不清楚咋回事了只能用到的时候再看了。。。。。。。。。。。。
如有不明白的可以一块交流