docker安装oracle

最近在学习docker安装了oracl11g此处做个记录

拉去oracle镜像

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

等待下载完成

注:若想离线安装可参考centos7离线安装docker-ce-17.12.0.ce-1.el7.centos.x86_64.,并实现镜像的导入导出以及启动(以mysql安装为例子)最下面有docker离线安装的例子

下载完成后查看镜像

docker images

REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
redis                    3.2                 87856cc39862        7 weeks ago         76MB
mysql                    5.7                 9e64176cd8a2        19 months ago       407MB
million12/zabbix-agent   latest              5b2e6ddedea9        2 years ago         315MB
oracle_11g               latest              3fa112fd3642        2 years ago         6.85GB

我的是把镜像名称重命名过的(可不重命名)

docker run -d -p 1521:1521 --restart=always --name  oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

-p是docker端口和宿主机端口的映射

--restart=always 配置宿主机重启后自动启动镜像

启动oracle镜像执行

docker start oracle_11g

进入镜像命令配置

docker exec -it oracle11g bash

切换到root用户

su root

输入默认密码helowin

执行

vi /etc/profile

[root@a8a161b66e1d /]# vi /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

保存之后执行命令(使配置自动生效)

source /etc/profile

切换oracle用户

su oracle

连接数据库

root@2786f28f0b30 /]# sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 10 12:54:06 2018

Copyright (c) 1982, 2009, Oracle.  All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> alter user system identified by system;

User altered.

SQL> alter user sys identified by sys;

User altered.

切换oracle用户查找tnsnames.ora文件位置

su oracle

find / -name tnsnames.ora

root@2786f28f0b30 /]# find / -name tnsnames.ora
/home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/samples/tnsnames.ora
/home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora

编辑文件

vi /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora

修改对应的HOST的主机ip

# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2..
0/dbhome_2/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_HELOWIN =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.114)(PORT = 1521))


HELOWIN =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.114)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = helowin)
    )
  )

~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               

重启监听

lsnrctl stop

lsnrctl start

你可能感兴趣的:(docker安装oracle)