docker安装oracle

1.下载镜像

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

2.创建快速搭建脚本build.sh

#!/bin/bash
#启动镜像
containId=`docker ps -a |grep -i oracle11g|awk '{print $1}'`
FDIR=$(dirname $(readlink -f "$0"))
if [[ ! $containId ]] ;then
        echo "target container not exist!"
else
        echo "target container exist , ID = "$containId
        docker stop $containId
        docker rm $containId
        echo "success delete container "$containId
fi

docker run -d -p 1521:1521  -v $FDIR/data/oracle:/data/oracle  --name oracle11g --restart always  registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
sleep 3
docker logs -f --tail 100 oracle11g

3.启动脚本并进入容器进行配置

sh build.sh
docker exec -it oracle11g bash

 root密码:helowin

su - root
vi /etc/profile
最后加上代码:
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

 数据库配置:

su - oracle

sqlplus /nolog 

conn /as sysdba;

修改密码:
alter user system identified by system;
alter user sys identified by sys;
alter profile default limit password_life_time unlimited;

创建用户:
create user test identified by test;

并给用户赋予权限:
grant connect,resource,dba to test;

用户解锁:
alter user test account unlock;

自动增加表空间容量:
alter tablespace users add datafile '/home/oracle/app/oracle/oradata/helowin/users02.dbf' size 10240m autoextend on next 1024m maxsize unlimited;

扩大共享内存:
alter system set SHARED_POOL_SIZE='150M' SCOPE=spfile;

shutdown immediate;

startup;

原文地址:

https://blog.csdn.net/u012725623/article/details/122013707

posted @ 2022-05-26 14:01  幸福在靠近  阅读(108)  评论(0编辑  收藏  举报