###一、安装docker
1、移除旧版本:
yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-selinux
docker-engine-selinux
docker-engine
rm -rf /etc/systemd/system/docker.service.d
rm -rf /var/lib/docker
rm -rf /var/run/docker
rm -rf /usr/local/docker
rm -rf /etc/docker
2、安装一些必要的系统工具:
yum -y install yum-utils device-mapper-persistent-data lvm2
3、添加软件源信息:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4、更新 yum 缓存:
yum makecache fast
5、安装 Docker-ce:
yum -y install docker-ce
6、启动 Docker 后台服务:
systemctl start docker
###二、安装oracle
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
已有镜像oracle_11g.tar则导入,将镜像文件oracle_11g.tar上传到系统中(/home/oracle/),执行导入命令:
docker load --input /home/oracle/oracle_11g.tar
1.1
临时关闭selinux然后再打开(解决docker挂载的目录无法读写)
setenforce 0
docker run -d -p 1521:1521 -v /home/data/oracle:/home/data/oracle --name oracle11 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
3.进入容器中:
docker exec -it oracle11 /bin/bash
su root
输入密码helowin
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
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
7.1. 修改用户权限,让oracle有权限创建文件
chown -R oracle /home/data/
su oracle
登录sqlplus并修改sys、system用户密码
sqlplus /nolog
conn /as sysdba
alter user system identified by system;
alter user sys identified by system;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
也可以创建用户>create user admin identified by admin;
并给用户赋予权限>grant connect,resource,dba to admin;
经过以上步骤,即可使用创建的账号连接oracle数据库了!
PS:远程数据库的导出:
exp USER_XXX/{password}@192.168.1.111:1521/helowin file=/home/data/bigdata_xxx.dmp owner=USER_XXX
远程数据库的导入:
imp USER_XXX/{password} file=/home/data/bigdata_xxx.dmp full=y
1.确认自己的docker源是安装阿里的docker源,下面是我的docker源
命令:
cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://gdyp3kvs.mirror.aliyuncs.com"]
}
如果不是这个源,改一下并重启docker。
docker search oracle
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/oraclelinux Official Docker builds of Oracle Linux. 651 [OK]
docker.io docker.io/jaspeen/oracle-11g Docker image for Oracle 11g database 159 [OK]
docker.io docker.io/oracleinanutshell/oracle-xe-11g 97
docker.io docker.io/oracle/graalvm-ce GraalVM Community Edition Official Image 70 [OK]
docker.io docker.io/absolutapps/oracle-12c-ee Oracle 12c EE image with web management co... 38
docker.io docker.io/araczkowski/oracle-apex-ords Oracle Express Edition 11g Release 2 on Ub... 30 [OK]
docker.io docker.io/oracle/nosql Oracle NoSQL on a Docker Image with Oracle... 24 [OK]
docker.io docker.io/wnameless/oracle-xe-11g-r2 Oracle Express Edition 11g Release 2 on Ub... 21
docker.io docker.io/datagrip/oracle Oracle 11.2 & 12.1.0.2-se2 & 11.2.0.2-xe 19 [OK]
docker.io docker.io/truevoly/oracle-12c Copy of sath89/oracle-12c image (https://g... 17
docker.io docker.io/oracle/weblogic-kubernetes-operator Docker images containing the Oracle WebLog... 12
docker.io docker.io/openweb/oracle-tomcat A fork off of Official tomcat image with O... 8 [OK]
docker.io docker.io/iamseth/oracledb_exporter A Prometheus exporter for Oracle modeled a... 3
docker.io docker.io/18fgsa/oracle-client Hosted version of the Oracle Container Ima... 2
docker.io docker.io/oracle/coherence-operator Kubernetes Operator for Oracle Coherence 2
docker.io docker.io/paulosalgado/oracle-java8-ubuntu-16 Oracle Java 8 on Ubuntu 16.04 LTS. 2 [OK]
docker.io docker.io/softwareplant/oracle oracle db 2 [OK]
docker.io docker.io/publicisworldwide/oracle-core This is the core image based on Oracle Lin... 1 [OK]
docker.io docker.io/roboxes/oracle7 A generic Oracle Linux 7 base image. 1
docker.io docker.io/amd64/oraclelinux Official Docker builds of Oracle Linux. 0
docker.io docker.io/arm64v8/oraclelinux Official Docker builds of Oracle Linux. 0
docker.io docker.io/bitnami/oraclelinux-extras Oracle Linux base images 0 [OK]
docker.io docker.io/bitnami/oraclelinux-runtimes Oracle Linux runtime-optimized images 0 [OK]
docker.io docker.io/pivotaldata/oracle7-test Oracle Enterprise Linux (OEL) image for GP... 0
docker.io docker.io/toolsmiths/oracle7-test
我下载的是其中的 docker.io/absolutapps/oracle-12c-ee
docker pull absolutapps/oracle-12c-ee
3.下载完成后,依次执行如下命令:
#运行容器
docker run -d -p 8180:8080 -p 1522:1521 -v /home/data/oracle12c:/home/data/oracle --name oracle-12cR1-ee --privileged absolutapps/oracle-12c-ee
#容器开启时间很长,需要打开日志查看安装情况,此条命令会卡很久,看个人机器配置,我卡了20分钟。
docker logs -f oracle-12cR1-ee
#进入容器内部
docker exec -it oracle-12cR1-ee /bin/bash
#授权
chown -R oracle /home/data/
#登录
sqlplus system/oracle@//localhost:1521/orcl
#接下来就和上面安装11g的一样了,比如修改system的密码,创建一个帐密为admin/admin,且有dba权限的用户:
alter user system identified by system;
create user admin identified by admin;
grant connect,resource,dba to admin;