1. 拉取oracle_11g镜像

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

在这里插入图片描述

2. 创建oracle11g容器

docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

3. 查看oracle11g容器是否创建成功

docker ps -a

在这里插入图片描述

4. 启动oracle11g容器

docker start oracle11g

5. 进入oracle11g容器进行配置

docker exec -it oracle11g bash

6. 切换到root用户下进行配置

su root

密码为:helowin

7. 编辑profile文件配置ORACLE环境变量

vi /etc/profile

8. 最后添加以下3行配置

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

在这里插入图片描述
保存 ::wq
让配置生效:source /etc/profile

9. 创建软连接

ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

10. 切换到oracle 用户

su - oracle

在这里插入图片描述

11. 登录sqlplus并修改sys、system用户密码

sqlplus /nolog
conn /as sysdba

在这里插入图片描述

12. 修改sys、system用户密码并刷新权限

alter user system identified by oracle;
alter user sys identified by oracle;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

在这里插入图片描述
退出:exit;

13. 查看一下oracle实例状态

lsnrctl status

在这里插入图片描述

14. oracle中文编码设置问题

查看oracle的字符编码

select * from nls_database_parameters;

用sysdba用户修改字符编码为

alter database character set  ZHS16GBK;

如果遇到不能修改,则调用以下步骤:

alter system enable restricted session;

alter system set job_queue_processes=0;

alter system set aq_tm_processes=0;

alter database open;

alter database character set ZHS16GBK;

当系统提示字符集必须为旧字符集的超集时,可用下面的句强制修改字符集

alter database character set internal_use ZHS16GBK;

15. oracle创建新用户和用户表空间

1.首先,创建(新)用户:

create user username identified by password;

2.创建表空间:

create tablespace tablespacename datafile 'd:\data.dbf' size 500m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  

3.将空间分配给用户:

alter user username default tablespace tablespacename;

4.给用户授权:

GRANT ALTER ANY PROCEDURE TO username;
GRANT ALTER ANY TABLE TO username;
GRANT ALTER ANY TRIGGER TO username;
GRANT ALTER ANY TYPE TO username;
GRANT CREATE ANY TABLE TO username;
GRANT DELETE ANY TABLE TO username;
GRANT DROP ANY PROCEDURE TO username;
GRANT DROP ANY SEQUENCE TO username;
GRANT DROP ANY TABLE TO username;
GRANT DROP ANY TRIGGER TO username;
GRANT DROP ANY TYPE TO username;
GRANT DROP ANY VIEW TO username;
GRANT SELECT ANY DICTIONARY TO username;
GRANT SELECT ANY SEQUENCE TO username;
GRANT SELECT ANY TABLE TO username;
GRANT UNDER ANY TABLE TO username;
GRANT UNDER ANY TYPE TO username;
GRANT UNDER ANY VIEW TO username;
GRANT UNLIMITED TABLESPACE TO username;
GRANT UPDATE ANY TABLE TO username;
GRANT CONNECT TO username;
GRANT DBA TO username;
GRANT RESOURCE TO username;
#下面两句主要用于给其他用户赋权限
GRANT insert ANY TABLE TO username;
GRANT execute ANY PROCEDURE TO username;

备注:自己从helowin修改为orcl的镜像启动容器后还需做后续操作

1.删除$ORACLE_BASE/oradata/orcl下的控制文件

[oracle@brms03 trace]$ cd $ORACLE_BASE/oradata
[oracle@brms03 oradata]$ mv helowin orcl
[oracle@brms03 oradata]$ cd orcl/
[oracle@brms03 trace]$ rm -rf control01.ctl 

2.删除$ORACLE_BASE/flash_recovery_area/orcl下的控制文件

[oracle@brms03 trace]$ cd $ORACLE_BASE/flash_recovery_area/orcl
[oracle@brms03 trace]$ rm -rf control02.ctl 

3.调用trace目录下的orcl.sql文件,目的是生成链接控制文件

[oracle@brms03 trace]$ sqlplus / as sysdba
SQL> @/home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/orcl.sql

4.重启数据库

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size		    2220200 bytes
Variable Size		 2298482520 bytes
Database Buffers	 1962934272 bytes
Redo Buffers		   12144640 bytes
Database mounted.
Database opened.

5.重启监听

[oracle@brms03 trace]$ lsnrctl start

6.表空间处理方式

-- 清空表数据
truncate table TBBWCONTRACTINFO;
-- 释放表空间
alter table TBBWCONTRACTINFO deallocate UNUSED KEEP 0; 
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐