One minute
Docker安装Oracle11
拉镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
启动
docker run -d --name oracle -p 1521:1521 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
先别持久化, 配置好再持久化
docker exec -it oracle bash
source /home/oracle/.bash_profile
sqlplus /nolog
conn /as sysdba
alter user system identified by system;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
alter system set processes=2000 scope=spfile;
create tablespace bigdata datafile '/home/oracle/app/oracle/oradata/helowin/bigdata.dbf' size 500M autoextend on next 50M maxsize unlimited;
create user zhiyun IDENTIFIED BY zhiyun default tablespace bigdata;
grant connect,resource,dba to zhiyun;
将数据复制到宿主机, 这里是DSM里的路径(根据自己的情况配置)
docker cp oracle:/home/oracle/app/oracle/oradata/helowin/ /volume2/docker/oracle/data/
docker cp oracle:/home/oracle/app/oracle/flash_recovery_area/helowin/ /volume2/docker/oracle/flash_recovery_area/
chown -R 500:500 /volume2/docker/oracle/data/
chown -R 500:500 /volume2/docker/oracle/flash_recovery_area/
停止并删除
docker stop oracle
docker rm oracle
docker-compose.yaml
version: '2'
services:
oracle:
image: registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
container_name: oracle
environment:
- POSTGRES_USER=sentry
restart: always
volumes:
- ./data/helowin/:/home/oracle/app/oracle/oradata/helowin/
- ./flash_recovery_area/helowin/:/home/oracle/app/oracle/flash_recovery_area/helowin/
ports:
- 1521:1521
启动
docker-compose up -d
连接测试
IP: 宿主机 ip
端口: 1521
SID:helowin
账号:zhiyun
密码:zhiyun
启动后如果发现连接不上 - 而且似乎每次重启后都会需要操作一次下面的代码?
docker exec -it oracle bash
cd /home/oracle/
source .bash_profile
rm -rf /home/oracle/app/oracle/flash_recovery_area/helowin/control02.ctl
cp /home/oracle/app/oracle/oradata/helowin/control01.ctl /home/oracle/app/oracle/flash_recovery_area/helowin/control02.ctl
sqlplus / as sysdba
shutdown immediate
startup
删除新生成的版本控制文件,将数据卷中的版本控制文件复制为新生成的版本控制文件, 再重新启动实例
测试数据是否回丢失