[[Docker]]
一.生成[[Oracle11g]]数据库文件
1.运行容器
docker run -it -d -p 1521:1521 --privileged=true --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
2.进入容器配置用户及访问权限
# 进入容器
docker exec -it oracle11g bash
# 切换root用户
su root
Password:helowin
# 切换oracle
su - oracle
# 连接数据库
sqlplus / as sysdba
# 修改密码
alter user system identified by system;
alter user sys identified by sys;
# 创建用户
create user root identified by 123456;
grant connect,resource,dba,sysdba to root;
# 配置生效
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
3.将配置好的数据库cp到宿主机
docker cp oralce11g:/home/oracle/app/oracle/oradata/helowin ./
二.持久化Run
1.run挂载helowin
docker run -it -d -p 1521:1521 --privileged=true -v E:\DockerData\oracle\data:/home/oracle/app/oracle/oradata/ --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
2.进入容器将helowin文件夹权限赋予oracle用户500
docker exec -it oracle11g bash
# 切换root
su root
Password:helowin
# 将权限赋予oracle用户(id:500)
chown -R 500.500 /home/oracle/app/oracle/oradata/helowin/
3.切换oracle用户更新oracle版本控制文件
su - oracle
# 删除容器中生成的版本控制文件
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
# 连接oracle
sqlplus / as sysdba
shutdown immediate
startup
...