1. 程式人生 > >docker安裝oracle,並匯入dump 檔案,客戶端Navicate連線

docker安裝oracle,並匯入dump 檔案,客戶端Navicate連線

把本地資料庫挪到自己的本本上

先下載docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g時這個是企業版檔案太大我的虛擬機器安裝失敗,安裝個j精簡版的成功了,可以看到大小仍有2G 多

[[email protected] ~]# docker pull registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g
Using default tag: latest
Trying to pull repository registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g ... 
latest: Pulling from registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g
f069f1d21059: Pull complete 
ecbeec5633cf: Pull complete 
ea6f18256d63: Pull complete 
54bde7b02897: Pull complete 
729f7fe87c9a: Pull complete 
f666cfd0593d: Pull complete 
Digest: sha256:88e4ac323eda6936920a92bbdb08f40b288674b45b51796bfd998fd847dfef28
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g:latest
[
[email protected]
~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 。。。 registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g latest 4ea53ad65b45 2 years ago 2.24 GB [[email protected]
~]# docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 1521:1521 --name oracle_11g 4ea53ad65b45 2f1f5b51d56b0162b617b81bb989ea14d72fbdfc0a280a1104c74c1cb0e8334f [[email protected] ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2f1f5b51d56b 4ea53ad65b45 "/bin/sh -c '/usr/..." 13 seconds ago Up 11 seconds 22/tcp, 8080/tcp, 0.0.0.0:1521->1521/tcp oracle_11g

啟動oracle_11g, 客戶端Navicate連線,建立使用者並connect

//建立使用者
create user cqq identified by 123456;
//使用者授權
grant connect, resource,dba to cqq;

[[email protected] ~]# docker exec -it oracle_11g bash
[email protected]:/# sqlplus

SQL*Plus: Release 11.2.0.2.0 Production on Tue Aug 14 06:48:27 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter user-name: cqq
Enter password: 

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> 

從宿主機拷檔案 uc.dmp到容器裡面,並匯入,然後通過Navicate客戶端開啟資料庫就可以方便的操作資料了

這裡有個小插曲:當rm 刪除不了一個目錄時,使用rm -rf強制刪除

[email protected]:/home# rm uc.dmp 
rm: cannot remove 'uc.dmp': Is a directory
[email protected]:/home# rm -rf uc.dmp

[[email protected] ~]# docker cp /home/uc.dmp oracle_11g:/home
must specify at least one container source
[[email protected] ~]# docker cp /home/uc.dmp 2f1f5b51d56b:/home
[[email protected] ~]# docker exec -it oracle_11g bash
[email protected]:/# imp uc_dev/123456 file=/home/uc.dmp ignore=y full=y

Import: Release 11.2.0.2.0 - Production on Tue Aug 14 06:20:10 2018

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

Export file created by EXPORT:V11.02.00 via conventional path

Warning: the objects were exported by UC, not by you

import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
export client uses ZHS16GBK character set (possible charset conversion)
. importing UC's objects into UC_DEV
. . importing table                     "ANNOUNCE"          6 rows imported
...
Import terminated successfully without warnings.