欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

docker安装Oracle11g数据库

程序员文章站 2024-03-25 17:20:40
...

最近公司项目需要用到oracle数据库,为方面同事开发,于是在公司阿里云服务器上用docker安装了一个oracle11g,给同事开发测试使用。
1、下载oracle11g的镜像文件
这里我使用的镜像文件是:registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g,这个镜像文件有6.85G这么大,下载需要几分钟的时间。

[aaa@qq.com ~]# docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
[aaa@qq.com ~]# docker images
REPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZE
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g   latest              3fa112fd3642        4 years ago         6.85GB

2、创建运行oracle容器

[aaa@qq.com ~]#docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

3、配置oracle
进入oracle容器,配置环境变量。
分别在在/etc/profile和/home/oracle/.bashrc文件末尾添加环境变量。
在/etc/profile设置oracle环境变量:

[aaa@qq.com ~]# docker exec -it oracle11g bash
[aaa@qq.com /]$ vi /etc/profile
# /etc/profile
...
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

在/home/oracle/.bashrc设置oracle环境变量:

[aaa@qq.com /]$ vi /home/oracle/.bashrc
# .bashrc
...
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

测试数据库连接:

[aaa@qq.com /]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Thu May 14 20:57:07 2020

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected.
SQL> 

4、修改oracle用户密码
修改sys、system等管理员账户密码

SQL> alter user system identified by system;

User altered.

SQL> alter user sys identified by sys;

User altered.

SQL> 

查看oracle数据库状态、实例名等信息:

[aaa@qq.com /]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2020 21:00:56

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                12-MAY-2020 09:25:18
Uptime                    2 days 11 hr. 35 min. 38 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/753d0436c2f1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=753d0436c2f1)(PORT=1521)))
Services Summary...
Service "helowin" has 1 instance(s).
  Instance "helowin", status READY, has 1 handler(s) for this service...
Service "helowinXDB" has 1 instance(s).
  Instance "helowin", status READY, has 1 handler(s) for this service...
The command completed successfully

根据状态信息可知,实例名为:helowin。

5、PLSQL客户端连接
用户:sys,密码:sys,数据库:你的IP地址/helowin,以sysdba角色登录即可。
docker安装Oracle11g数据库