时间:2021-07-01 10:21:17 帮助过:124人阅读
mkdir /usr/local/docker
cd /usr/local/docker
mkdir oracle
cd oracle
touch docker-compose.yml
version: ‘3.1‘
services:
master:
image: registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
container_name: oracle
privileged: true
ports:
- 1521:1521
docker-compose up -d
docker exec -it oracle bash
cd /home/oracle # 进入到 oracle 用户目录
source .bash_profile # 加载 oracle 环境变量
$PATH # 查看 oracle 环境变量是否生效
sqlplus / as sysdba # 连接 oracle 数据库
alter user system identified by oracle; # 修改 DBA 账号的密码
alter user sys identified by oracle; # 修改 DBA 账号的密码
alter profile default limit password_life_time unlimited; # 设置密码为永不过期
create user test identified by oracle; # 创建一个 test 用户,密码 oracle
select * from dba_users t where t.username = ‘TEST‘; # 查询用户是否创建成功
grant connect, resource to test; # 给用户授予连接和数据权限
docker cp oracle:/home/oracle/app/oracle/oradata/helowin /usr/local/docker/oracle/helowin
cd /usr/local/docker/oracle
chown -R 500.500 ./helowin # 500 500 是容器内 oracle 组合用户的 id
version: ‘3.1‘
services:
master:
image: registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
container_name: oracle
privileged: true
ports:
- 1521:1521
volumes:
- ./helowin:/home/oracle/app/oracle/oradata/helowin
docker exec -it oracle bash
cd /home/oracle # 进入到 oracle 用户目录
source .bash_profile # 加载 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
sqlplus / as sysdba # 以 dba 身份连接 oracle 数据库
shutdown immediate # 关闭数据库实例(这里会报错,不用管)
startup # 启动实例
docker 安装 oracle_11g_r2 并实现数据持久化
标签:version 用户目录 doc 本地 关闭数据库 shu creat 数据卷 art