Docker 安装 Oracle 11G
镜像
docker pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/akaiot/oracle_11g:latest
docker tag swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/akaiot/oracle_11g:latest docker.io/akaiot/oracle_11g:latest
创建并启动容器
mkdir -p /home/oracle/app/oracle11g/oradata
# 容器内端口默认1521,且通过 -p 参数修改不成功,所以只能修改外部的端口
docker run -itd --name oracle11g --restart=always -p 1523:1521 -v /home/oracle/app/oracle11g/oradata:/home/oracle/app/oracle11g/oradata docker.io/akaiot/oracle_11g:latest
查看日志
docker logs -f --tail 100 oracle11g
/home/oracle/app/oracle/product/11.2.0/dbhome_2
Processing Database instance "helowin": log file /home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log
Fixed Size 2213776 bytes
Variable Size 402655344 bytes
Database Buffers 1174405120 bytes
Redo Buffers 24137728 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options/home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/dbstart: Database instance "helowin" warm started.
tail: unrecognized file system type 0x794c7630 for `/home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log'. Reverting to polling.
登录到容器内
docker exec -it oracle11g bash
配置环境变量
su root
Password: helowin
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/profilevi /home/oracle/.bashrc
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
source /home/oracle/.bashrc
登录
# 必须要切到 oracle 用户
su oracle
sqlplus / as sysdba
查询数据库状态
SELECT status FROM v$instance;STATUS
------------
OPEN
连接验证
- SID 和 Service Name 均为 helowin
- 用密码密码: sys/oracle
修改密码
alter user system identified by test123;
alter user sys identified by test123;
异常记录
ORA-00205: error in identifying control file, check alert log for more info
异常原因:运行容器是指定的目录为 /home/oracle/app/oracle/oradata ,该目录是容器内安装Oracle自带的目录,换一个别的新建目录即可
删除 Docker 容器
docker stop oracle11g
docker rm oracle11g