0%

docker-oracle

docker拉取

1
2
3
4
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
docker start oracle11g
docker exec -it oracle11g bash

这条不用,仅记录密码:su root 密码:helowin

修改环境变量

1
2
3
4
5
vi ./.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 ~/.bashrc

通过sqlplus在Oracle数据库创建用户

1
2
3
4
5
6
7
8
[oracle@79def098c093 ~]$ sqlplus /nolog
conn /as sysdba
alter user system identified by system;
alter user sys identified by sys;
create user frank identified by Gzxu2012;
grant connect,resource,dba to frank;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
exit

客户端连接

配置环境变量navicat需要64位驱动,plsqldev需要32位驱动
删1) 变量名:ORACLE_HOME 变量值:C:\app\PLSQLDeveloper\instantclient_11_2
删2) 变量名:TNS_ADMIN 变量值:E:\tool_01\PLSQL Developer\instantclient_11_2
plsqldev需要3) 变量名:NLS_LANG 变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
删4) 修改Path变量,在后面添加 E:\tool_01\PLSQL Developer\instantclient_11_2

通过客户端进行表空间操作

1
2
3
4
5
6
7
8
-- 创建表空间
create tablespace frank_table_space
datafile '/home/oracle/app/oracle/oradata/helowin/frank_table_space.dbf'
size 100M
autoextend on next 10M maxsize 3000M;

-- 删除表空间
drop tablespace frank_table_space including contents and datafiles

导入导出,采用sqlplus支撑

1
2
3
4
--导入导出命令   在装sqlplus机器上
ip导出方式: exp demo/demo@127.0.0.1:1521/orcl file=f:/f.dmp full=y
exp demo/demo@orcl file=f:/f.dmp full=y
imp demo/demo@orcl file=f:/f.dmp full=y ignore=y

运维

1
2
sql> SHUTDOWN IMMEDIATE
sql> STARTUP
1
2
3
4
5
6
7
lsnrctl status

Service "helowin" has 1 instance(s).
Instance "helowin", status READY, has 1 handler(s) for this service...
Service "helowinXDB" has 1 instance(s).
Instance "helowin", status READY, has 1 handler(s) for this service...
The command completed successfully

案例-在线平台

1
2
3
4
5
6
7
8
9
10
11
12
--创建用户
create user FGWCMS identified by Gzxu2012;
grant connect,resource,dba to FGWCMS;

-- 创建表空间
create tablespace WEBSITE
datafile '/home/oracle/app/oracle/oradata/helowin/WEBSITE_table_space.dbf'
size 100M
autoextend on next 10M maxsize 3000M;

-- 删除表空间
drop tablespace WEBSITE including contents and datafiles;
1
2
3
4
5
unzip FGW20181227
docker cp ~/FGW20181227.dmp oracle11g:/home/oracle/
imp frank/Gzxu2012@helowin file=/home/oracle/FGW20181227.dmp full=y ignore=y

会提示importing FGW's objects into FRANK
---------------- The End ----------------
Frank wechat
扫描+微信,共同学习.