0


Docker 安装oracle11g 手把手详细教程

一、在线拉去镜像

因为镜像比较大,所以请划水等拉去好

命令:

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

查看拉去好的镜像:最新版本6.85GB

[root@syf ~]# docker images
REPOSITORY                                             TAG       IMAGE ID       CREATED        SIZE
dockertest                                             1.0       7f4faa206171   9 months ago   760MB
centosjava8                                            1.0       b66e5037b732   9 months ago   1.27GB
nginx                                                  latest    605c77e624dd   2 years ago    141MB
redis                                                  6.2.6     7614ae9453d1   2 years ago    113MB
mysql                                                  5.7       c20987f18b13   2 years ago    448MB
portainer/portainer-ce                                 2.9.1     bc46de77a3ff   2 years ago    252MB
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g   latest    3fa112fd3642   8 years ago    6.85GB

二、创建容器并运行

命令:

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

执行过程:

[root@syf ~]#  docker run  --privileged -d --restart=always -v /home/oracle:/data/oracle -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

f8f87a6214f9b4b7992ff1b087afb3ca3b9d09f6f2a7d2ee48dc545fc230f173
[root@syf ~]# 
[root@syf ~]# docker ps
CONTAINER ID   IMAGE                                                  COMMAND                  CREATED          STATUS          PORTS                                                           NAMES
f8f87a6214f9   registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g   "/bin/sh -c '/home/o…"   37 seconds ago   Up 5 seconds    0.0.0.0:1521->1521/tcp, :::1521->1521/tcp                       oracle11g
01426f3991ea   portainer/portainer-ce:2.9.1                           "/portainer"             9 months ago     Up 33 minutes   8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp   portainer
a34aff536643   redis:6.2.6                                            "docker-entrypoint.s…"   9 months ago     Up 33 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                       redis6.2.6
2a384f369e0b   mysql:5.7                                              "docker-entrypoint.s…"   9 months ago     Up 33 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp  

运行容器命令解释:

  • --privileged 允许挂载数据卷,默认是读写权限rw
  • -d:以后台方式运行实例,(退出容器oracle依旧运行)
  • 配置端口映射:
  • -p 1521:1521 指定宿主机器1521:docker容器1521端口 映射。
  • oracle 数据文件挂载: -v /data/dockerData/oracle:/data/oracle,将容器中的数据文件夹 /data/oracle 挂载到宿主机对应的 /data/dockerData/oracl 文件夹中。
  • 设置oracle 容器名称: --name oracle11g

三、进入创建好的容器

docker exec -it oracle11g bash

接着:登录设置密码

命令: su root

        Password: root

执行过程:

[root@syf ~]# docker exec -it oracle11g bash
[oracle@f8f87a6214f9 /]$ su root
'Password: 
su: incorrect password

四、配置oracle环境变量

开启编权限挂载的文件夹:

chown -R oracle/data

命令:查看文件

vi /etc/profile

** 编辑:按 i 键进入编辑**

在文件最后添加下面内容, 按Esc键退出编辑模式,输入 :wq! 保存

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

执行过程,如图:

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null 2>&1
        fi
    fi
done

unset i
unset -f pathmunge
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=root
export PATH=$ORACLE_HOME/bin:$PATH
:wq!
保存后使配置文件生效

** 命令: **

source /etc/profile
创建连接
     **命令:* ***
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

下面是修改默认用户密码

切换用户,并登录
        命令: su - oracle

        命令: sqlplus /nolog
        
        SQL> conn /as sysdba

修改sys system用户的密码(密码个人自定义,这里用root代表)

        SQL> alter user system identified by root;        

        SQL> alter user sys identified by root;

        SQL> create user admin identified by root;        --创建一个管理账号,自定义账号和密码

        SQL> grant connect,resource,dba to admin;     --授权给管理账号

 

重启数据库:

#关闭数据库
SQL> shutdown immediate;
#开启mount状态
SQL> startup mount;
# 开启归档日志,出现Database altered. 表示开启成功
SQL> alter database archivelog;
#查看归档状态
SQL> SELECT log_mode FROM v$database;
#打开数据库,一定要执行
SQL> alter database open;

exit退出容器:

查看一下oracle实例状态

lsnrctl status
[root@f8f87a6214f9 /]# lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-SEP-2024 23:01:18

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                25-SEP-2024 21:49:14
Uptime                    0 days 1 hr. 12 min. 4 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/f8f87a6214f9/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=f8f87a6214f9)(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...

注意事项:

  • 归档日志将占用大量的磁盘空间,如磁盘空间允许,则建议调大归档日志空间。
  • SQL> show parameter recovery NAME TYPE VALUE------------------------------------ ----------- ------------------------------db_recovery_file_dest string /u01/app/oracle/fast_recovery_ areadb_recovery_file_dest_size big integer 4182Mrecovery_parallelism integer 0# 修改归档目录地址SQL> alter system set db_recovery_file_dest='/u01/app/oracle/archivelog' scope=spfile;System altered.# 修改归档目录大小SQL> alter system set db_recovery_file_dest_size=4096m scope=spfile;System altered.#重启数据库SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started. Total System Global Area 759943168 bytesFixed Size 2257112 bytesVariable Size 499126056 bytesDatabase Buffers 255852544 bytesRedo Buffers 2707456 bytesDatabase mounted.Database opened.SQL> show parameter recovery NAME TYPE VALUE------------------------------------ ----------- ------------------------------db_recovery_file_dest string /u01/app/oracle/archivelogdb_recovery_file_dest_size big integer 4Grecovery_parallelism integer 0
标签: docker 容器

本文转载自: https://blog.csdn.net/javaxueba/article/details/142533695
版权归原作者 syfjava 所有, 如有侵权,请联系我们删除。

“Docker 安装oracle11g 手把手详细教程”的评论:

还没有评论