赞
踩
docker是一个用Go语言实现的开源项目,可以让我们方便的创建和使用容器,docker将程序以及程序所有的依赖都打包到docker container,这样你的程序可以在任何环境都会有一致的表现,这里程序运行的依赖也就是容器就好比集装箱,容器所处的操作系统环境就好比货船或港口,程序的表现只和集装箱有关系(容器),和集装箱放在哪个货船或者哪个港口(操作系统)没有关系。
要根据硬件平台下载以免造成不兼容
https://download.docker.com/
根据自己的需求安装对应的版本(我这里选择的是docker-20.10.7)
https://download.docker.com/linux/static/stable/x86_64/docker-20.10.7.tgz
将下载好的的包上传到对应服务器
并解压 tar -zxvf docker-20.10.7.tgz
解压完的文件为docker
[root@v-ct-jy-czzp-app-160 opt]# tar -zxvf docker-20.10.7.tgz
[root@v-ct-jy-czzp-app-160 opt]# mv docker/* /usr/bin/
[root@v-ct-jy-czzp-app-160 opt]# vim /usr/lib/systemd/system/docker.service
将以下内容填入
[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity TimeoutStartSec=0 Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target
[root@v-ct-jy-czzp-app-160 opt]# systemctl daemon-reload
[root@v-ct-jy-czzp-app-160 opt]# systemctl start docker.service
[root@v-ct-jy-czzp-app-160 opt]# docker info
将docker设置为开机自启动
[root@v-ct-jy-czzp-app-160 opt]# systemctl enable docker
注意最好使用的服务器要和内网机器系统兼容否则镜像导入时会报错
[root@summer summer]# docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
Using default tag: latest
latest: Pulling from helowin/oracle_11g
ed5542b8e0e1: Pull complete
a3ed95caeb02: Pull complete
1e8f80d0799e: Pull complete
Digest: sha256:4c12b98372dfcbaafcd9564a37c8d91456090a5c6fb07a4ec18270c9d9ef9726
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
[root@summer summer]#docker save registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest > oracle11g.tar
[root@v-ct-jy-czzp-app-160 opt]# docker load -i oracle11g.tar
[root@v-ct-jy-czzp-oth-02 ~]# docker run -d --name oracle -p 1521:1521 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
[root@v-ct-jy-czzp-oth-02 ~]# mkdir -p /opt/oracle/
[root@v-ct-jy-czzp-oth-02 ~]# mkdir -p /opt/oracle/flash_recovery_area/
[root@v-ct-jy-czzp-oth-02 ~]# mkdir -p /opt/oracle/
[root@v-ct-jy-czzp-oth-02 ~]# mkdir -p /opt/oracle/flash_recovery_area/
[root@v-ct-jy-czzp-oth-02 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
149b2d1a4d64 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home/o…" 26 seconds ago Up 20 seconds 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp oracle
[root@v-ct-jy-czzp-oth-02 ~]# docker cp 149b2d1a4d64:/home/oracle/app/oracle/oradata /opt/oracle/oradata
[root@v-ct-jy-czzp-oth-02 ~]# docker cp 149b2d1a4d64:/home/oracle/app/oracle/flash_recovery_area/helowin /opt/oracle/flash_recovery_area/helowin
[root@v-ct-jy-czzp-oth-02 ~]# chmod -R 777 /opt/oracle/
[root@v-ct-jy-czzp-oth-02 ~]# docker stop 149b2d1a4d64
149b2d1a4d64
[root@v-ct-jy-czzp-oth-02 ~]# docker rm 149b2d1a4d64
149b2d1a4d64
[root@v-ct-jy-czzp-oth-02 ~]# docker run -d --name oracle_llg -p 1521:1521 --privileged=true -v /opt/oracle/oradata:/home/oracle/app/oracle/oradata -v /opt/oracle/flash_recovery_area/helowin:/home/oracle/app/oracle/flash_recovery_area/helowin registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
[root@v-ct-jy-czzp-oth-02 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
640d85e4800c registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home/o…" 10 seconds ago Up 10 seconds 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp oracle_llg
[root@v-ct-jy-czzp-oth-02 ~]# docker exec -it 640d85e4800c /bin/bash
[oracle@640d85e4800c /]$ source /home/oracle/.bash_profile
[oracle@640d85e4800c /]$ su root
Password:
#密码:helowin
[root@640d85e4800c /]# 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
#刷新配置
[root@640d85e4800c /]# source /etc/profile
[root@640d85e4800c /]# su oracle
[oracle@47badc5bb7c4 /]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 3 19:42:31 2023
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected.
SQL> alter user system identified by system;
User altered.
SQL> alter user sys identified by sys;
User altered.
SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Profile altered.
SQL>
SQL> create user summer IDENTIFIED BY 123456 default tablespace test;
User created.
SQL> grant connect,resource,dba to summer;
Grant succeeded.
SQL>
名称 | 参数 |
---|---|
IP | 宿主机ip |
端口 | 1521 |
SID | helowin |
账号 | summer |
密码 | 123456 |
原来SID为helowin,先需要修改为orcl
[oracle@47badc5bb7c4 /]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 4 01:00:41 2020
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
[oracle@47badc5bb7c4 /]$ vi /home/oracle/.bash_profile #更改 ORACLE_SID=orcl;export ORACLE_SID [oracle@47badc5bb7c4 /]$ cat /etc/oratab orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_2:Y [oracle@47badc5bb7c4 /]$ cd $ORACLE_HOME/dbs [oracle@47badc5bb7c4 dbs]$ ll total 32 -rw-r-----. 1 oracle oinstall 3584 Jan 4 2016 123.sp -rw-rw----. 1 oracle oinstall 1544 Nov 4 01:01 hc_helowin.dat -rw-r--r--. 1 oracle oinstall 2851 May 16 2009 init.ora -rw-r--r--. 1 oracle oinstall 1067 Jan 4 2016 inithelowin.ora -rw-r-----. 1 oracle oinstall 24 Aug 23 2014 lkHELOWIN -rw-r-----. 1 oracle oinstall 24 Dec 29 2015 lkORCL -rw-r-----. 1 oracle oinstall 2048 Nov 4 00:33 orapwhelowin -rw-r-----. 1 oracle oinstall 3584 Nov 4 00:25 spfilehelowin.ora [oracle@39721ba8b1dd dbs]$ mv hc_helowin.dat hc_orcl.dat [oracle@39721ba8b1dd dbs]$ mv orapwhelowin orapworcl [oracle@39721ba8b1dd dbs]$ mv spfilehelowin.ora spfileorcl.ora [oracle@39721ba8b1dd dbs]$ mv lkHELOWIN lkORCL [oracle@39721ba8b1dd dbs]$ exit exit [root@47badc5bb7c4 /]# exit exit [oracle@47badc5bb7c4 /]$ exit exit [root@summer oracle]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 47badc5bb7c4 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home/o…" 49 minutes ago Up 49 minutes 0.0.0.0:1521->1521/tcp oracle_llg [root@summer oracle]# docker restart 39721ba8b1dd 47badc5bb7c4
就此如何快速在内网环境搭建一个Oracle数据库搭建完成,感谢支持
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。