使用docker安装oracle19c

  • 环境准备:2核2Gcpu,磁盘70G,centos8.4操作系统

一、环境配置

1.0.配置本地yum仓库

#下载新的镜像源,这里使用的是aliyun
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
#生成缓存
[root@localhost ~]# yum makecache
#如果报错如下
#1\
...
Repository extras is listed more than once in the configuration
CentOS-8.5.2111 - Base - mirrors.aliyun.com     277 kB/s | 4.6 MB     00:16    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com    57 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.co 676 kB/s | 8.4 MB     00:12    
CentOS Linux 8 - AppStream                      0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
...

#删除仓库
[root@localhost yum.repos.d]# rm -rf /etc/yum.repos.d/*
#再次下载
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2495  100  2495    0     0  16201      0 --:--:-- --:--:-- --:--:-- 16201
#生成缓存
[root@localhost yum.repos.d]# yum makecache
CentOS-8.5.2111 - Base - mirrors.aliyun.com      79 kB/s | 3.9 kB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com    40 kB/s | 1.5 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.co  28 kB/s | 4.3 kB     00:00    
Metadata cache created.
#删除旧缓存
[root@localhost yum.repos.d]# yum clean all
18 files removed

1.1.更新yum

[root@localhost yum.repos.d]# yum update
#中途需要确认
#1\
...
Transaction Summary
================================================================================
Install   10 Packages
Upgrade  296 Packages

Total download size: 574 M
Is this ok [y/N]: y       #请输入y
Downloading Packages:
...

#更新成功,显示如下
#2\
...
Installed:
  elfutils-debuginfod-client-devel-0.185-1.el8.x86_64                           
  elfutils-devel-0.185-1.el8.x86_64                                             
  grub2-tools-efi-1:2.02-106.el8.x86_64                                         
  kernel-4.18.0-348.7.1.el8_5.x86_64                                            
  kernel-core-4.18.0-348.7.1.el8_5.x86_64                                       
  kernel-devel-4.18.0-348.7.1.el8_5.x86_64                                      
  kernel-modules-4.18.0-348.7.1.el8_5.x86_64                                    
  libbpf-0.4.0-1.el8.x86_64                                                     
  libzstd-devel-1.4.4-1.el8.x86_64                                              
  xz-devel-5.2.4-3.el8.x86_64                                                   

Complete!

...

1.2.删除旧版本

[root@localhost yum.repos.d]# yum remove docker  docker-common docker-selinux docker-engine
#删除成功或不存在
#1\
...
Repository extras is listed more than once in the configuration
No match for argument: docker
No match for argument: docker-common
No match for argument: docker-selinux
No match for argument: docker-engine
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
...

1.3安装依赖

[root@localhost yum.repos.d]# yum install -y yum-utils device-mapper-persistent-data lvm2
#报错如下
#1\
...
Repository extras is listed more than once in the configuration
CentOS Linux 8 - AppStream                      0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve ho
...

#再次重构镜像仓库
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2495  100  2495    0     0  21324      0 --:--:-- --:--:-- --:--:-- 21144
...

[root@localhost yum.repos.d]# yum makecache
...
CentOS-8.5.2111 - Base - mirrors.aliyun.com      29 kB/s | 3.9 kB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com   3.8 kB/s | 1.5 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.co  29 kB/s | 4.3 kB     00:00    
Metadata cache created.
...

[root@localhost yum.repos.d]# yum install -y yum-utils device-mapper-persistent-data lvm2
#配置成功
#1\
...
Installed:
  device-mapper-event-8:1.02.177-10.el8.x86_64                                  
  device-mapper-event-libs-8:1.02.177-10.el8.x86_64                             
  device-mapper-persistent-data-0.9.0-4.el8.x86_64                              
  libaio-0.3.112-1.el8.x86_64                                                   
  lvm2-8:2.03.12-10.el8.x86_64                                                  
  lvm2-libs-8:2.03.12-10.el8.x86_64                                             
  yum-utils-4.0.21-3.el8.noarch                                                 

Complete!
...

二、配置docker源

[root@localhost yum.repos.d]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#添加成功
#1\
...
Adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
...

2.0.更新yum缓存

[root@localhost yum.repos.d]# yum makecache
#如下
#1\
...
CentOS-8.5.2111 - Base - mirrors.aliyun.com      48 kB/s | 3.9 kB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com   6.8 kB/s | 1.5 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.co  42 kB/s | 4.3 kB     00:00    
Docker CE Stable - x86_64                        93 kB/s |  66 kB     00:00    
Metadata cache created.

...

2.1.安装docker

#安装容器
[root@localhost yum.repos.d]# yum -y install docker-ce
#成功如下
#1\
...
  python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                          
  python3-libsemanage-2.9-6.el8.x86_64                                          
  python3-policycoreutils-2.9-16.el8.noarch                                     
  python3-setools-4.3.0-2.el8.x86_64                                            
  slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                        

Complete!
...

#启动容器
[root@localhost yum.repos.d]# systemctl start docker
#查看启动是否成功
[root@localhost yum.repos.d]# docker info
#成功如下
#1\
...
Client: Docker Engine - Community
 Version:    26.1.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
...

#配置容器开机自启
[root@localhost yum.repos.d]# systemctl enable docker
#如果出现
# Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the d
#systemctl restart docker  #重启一下就行

三、拉取oracle镜像至容器

3.0.拉取基础镜像

[root@localhost yum.repos.d]# docker pull doctorkirk/oracle-19c
#成功如下
#1\
...
Using default tag: latest
latest: Pulling from doctorkirk/oracle-19c
29415c7d058f: Pull complete 
198bff5413e1: Pull complete 
e8b1c0b24c00: Pull complete 
8bfefd996a95: Pull complete 
1afbeedfc34a: Pull complete 
30ed1731acd1: Pull complete 
Digest: sha256:5816fe124f2a2f3a624be60c13badca54ee473ba7d30de811705f90b5cdb7a47
Status: Downloaded newer image for doctorkirk/oracle-19c:latest
docker.io/doctorkirk/oracle-19c:latest

...
#查看镜像
[root@localhost yum.repos.d]# docker images
REPOSITORY              TAG       IMAGE ID       CREATED       SIZE
doctorkirk/oracle-19c   latest    bb78ab7143bb   3 years ago   11.5GB

3.1.运行容器

#创建主目录
[root@localhost yum.repos.d]# mkdir -p /path/oracle-19c/oradata/
[root@localhost ~]# cd /path/
[root@localhost path]# chown -R 54321:54321 oracle-19c/
#配置
#程序sid:Oracle555     ##需要以字母开头
#oracle密码为:oracle_123
#设置编码:AL32UTF8
#设置主目录建立映射:/path/oracle-19c/oradata/
[root@localhost yum.repos.d]# docker run --name oracle-19c \
> -p 1521:1521 \
> -e ORACLE_SID=Oracle555 \
> -e ORACLE_PWD=oracle_123 \
> -e ORACLE_CHARACTERSET=AL32UTF8 \
> -v /path/oracle-19c/oradata/:/opt/oracle/oradata \
> doctorkirk/oracle-19c
#成功如下:
#1\
...

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值