docker镜像:wnameless/oracle-xe-11g
启动镜像的命令:
docker run -d -v /data/oracle_data:/data/oracle_data -p 11522:22 -p 11521:1521 -e ORACLE_ALLOW_REMOTE=true --name oracle-11g wnameless/oracle-xe-11g
进入镜像命令:
docker exec -it oracle-11g /bin/bash
1. 执行sqlplus命令,使用如下配置登录:
hostname: localhost
port: 49161
sid: xe
username: system
password: oracle
2. 创建表空间和用户:
2.1--创建表空间
CREATE TABLESPACE sunlight_space
DATAFILE ‘/data/oracle_data/sunlight_space.dbf‘ size 500M
AUTOEXTEND ON
NEXT 200M MAXSIZE 20480M
EXTENT MANAGEMENT LOCAL;
2.2--创建临时表空间
CREATE TEMPORARY TABLESPACE sunlight_tmp
TEMPFILE ‘/data/oracle_data/sunlight_tmp.dbf‘
SIZE 200M
AUTOEXTEND ON
NEXT 50M MAXSIZE 20480M
EXTENT MANAGEMENT LOCAL;
2.3 --创建用户并指定表空间(可选,参考)
CREATE USER sunlightopt IDENTIFIED BY 123456 DEFAULT TABLESPACE sunlight;
2.4 ----创建用户并指定表空间和临时表空间
CREATE USER sunlightopt IDENTIFIED BY 123456
DEFAULT TABLESPACE sunlight
TEMPORARY TABLESPACE sunlight_tmp;
2.5 --授权用户
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 sunlight;
其他,请参考:
https://blog.csdn.net/cai7095576/article/details/18898717
3. 首先查看服务端oracle监听配置:
进入容器,执行命令:
lsnrctl status
结果:
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 19-AUG-2018 04:18:43
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 18-AUG-2018 06:05:39
Uptime 0 days 22 hr. 13 min. 5 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/11a8a9a5a280/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=11a8a9a5a280)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=11a8a9a5a280)(PORT=8080))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XE" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully
4. 进入目录:/u01/app/oracle/product/11.2.0/xe/network/admin
查看文件内容:
cat tnsnames.ora
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 11a8a9a5a280)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
XE就是连接名称;
5. 客户端设置:
5.1 下载链接oracle客户端,地址:
http://www.oracle.com/technetwork/cn/database/features/instant-client/index-092699-zhs.html
一般选择 适用于 Microsoft Windows (x64) 的 Instant Client
解压到C:\instantclient_12_2
在以上目录中,创建递归目录:
C:\instantclient_12_2\NETWORK\ADMIN
在以上目录中,创建文件:tnsnames.ora
内容如下:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = *.*.*.*)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
在我的电脑-高级系统设置中创建环境变量:
变量名:NLS_LANG
变量值:AMERICAN_AMERICA.AL32UTF8
变量名:TNS_ADMIN
变量值:C:\instantclient_12_2\NETWORK\ADMIN
5.2 安装pl/sql developer 11
启动后:
原文地址:https://www.cnblogs.com/ralphdc/p/9500981.html