基于docker的安装非常简单。
其实就两行核心命令:
1 2 |
./buildDockerImage.sh -v 19.2.0 -e docker run --name oracle19c -p 1521:1521 -p 5500:5500 -v /Users/lovehouse/iDocker/dockervolums/oradata/oracle19c:/opt/oracle/oradata oracle/database:19.2.0-ee |
我们假设你已经在Mac上安装好了docker,我们开始安装oracle 19c。在docker上安装数据库或应用,是基于dockerfile的,目前Oracle官方还没发布基于19c的dockerfile,但是我们可以使用别人已经做好的dockerfile(感谢kamus告诉我这个docker file)。
如果你不知道如何在Mac上安装docker,可以参考我这篇《在Mac上安装docker并部署oracle 12.2》
我们先来试一下官方在github上的dockerfile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
LoveHousedeiMac:iDocker lovehouse$ pwd /Users/lovehouse/iDocker/oracle LoveHousedeiMac:iDocker lovehouse$ git clone https://github.com/oracle/docker-images.git Cloning into 'docker-images'... remote: Enumerating objects: 77, done. remote: Counting objects: 100% (77/77), done. remote: Compressing objects: 100% (52/52), done. remote: Total 9878 (delta 25), reused 55 (delta 23), pack-reused 9801 Receiving objects: 100% (9878/9878), 10.20 MiB | 2.47 MiB/s, done. Resolving deltas: 100% (5686/5686), done. LoveHousedeiMac:iDocker lovehouse$ LoveHousedeiMac:iDocker lovehouse$ LoveHousedeiMac:iDocker lovehouse$ ls -l total 0 drwxr-xr-x 31 lovehouse staff 1054 Feb 16 17:07 docker-images LoveHousedeiMac:iDocker lovehouse$ cd docker-images/OracleDatabase/SingleInstance/dockerfiles LoveHousedeiMac:dockerfiles lovehouse$ ls -l total 16 drwxr-xr-x 8 lovehouse staff 272 Feb 16 17:07 11.2.0.2 drwxr-xr-x 18 lovehouse staff 612 Feb 16 17:07 12.1.0.2 drwxr-xr-x 16 lovehouse staff 544 Feb 16 17:07 12.2.0.1 drwxr-xr-x 16 lovehouse staff 544 Feb 16 17:07 18.3.0 drwxr-xr-x 8 lovehouse staff 272 Feb 16 17:07 18.4.0 -rwxr-xr-x 1 lovehouse staff 5088 Feb 16 17:07 buildDockerImage.sh LoveHousedeiMac:dockerfiles lovehouse$ |
我们看到只有11.2.0.2,12.1.0.2,12.2.0.1,18.3.0和18.4.0几个版本,还没发布19c。
我们用marcelo-ochoa做好的dockerfile,具体的信息在这里。我们开始安装:
1. 先利用git clone下载marcelo-ochoa做好的dockerfiles:
1 2 3 4 5 6 7 8 9 10 11 12 |
LoveHousedeiMac:iDocker lovehouse$ mkdir marcelo-ochoa LoveHousedeiMac:iDocker lovehouse$ cd /Users/lovehouse/iDocker/marcelo-ochoa LoveHousedeiMac:marcelo-ochoa lovehouse$ LoveHousedeiMac:marcelo-ochoa lovehouse$ git clone https://github.com/marcelo-ochoa/docker-images.git Cloning into 'docker-images'... remote: Enumerating objects: 24, done. remote: Counting objects: 100% (24/24), done. remote: Compressing objects: 100% (20/20), done. remote: Total 9111 (delta 7), reused 7 (delta 3), pack-reused 9087 Receiving objects: 100% (9111/9111), 10.01 MiB | 1.59 MiB/s, done. Resolving deltas: 100% (5204/5204), done. LoveHousedeiMac:marcelo-ochoa lovehouse$ |
我们看到是存在19.2.0的dockerfile的,同时检查其安装的安装包文件名:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
LoveHousedeiMac:dockerfiles lovehouse$ cd /Users/lovehouse/iDocker/marcelo-ochoa/docker-images/OracleDatabase/SingleInstance/dockerfiles LoveHousedeiMac:dockerfiles lovehouse$ ls -l total 16 drwxr-xr-x 8 lovehouse staff 272 Feb 16 17:09 11.2.0.2 drwxr-xr-x 18 lovehouse staff 612 Feb 16 17:09 12.1.0.2 drwxr-xr-x 16 lovehouse staff 544 Feb 16 17:09 12.2.0.1 drwxr-xr-x 16 lovehouse staff 544 Feb 16 17:09 18.3.0 drwxr-xr-x 8 lovehouse staff 272 Feb 16 17:09 18.4.0 drwxr-xr-x 17 lovehouse staff 578 Feb 16 17:33 19.2.0 -rwxr-xr-x 1 lovehouse staff 5145 Feb 16 17:09 buildDockerImage.sh LoveHousedeiMac:dockerfiles lovehouse$ cd 19.2.0 LoveHousedeiMac:19.2.0 lovehouse$ ls -l total 136 -rw-r--r-- 1 lovehouse staff 49 Feb 16 17:09 Checksum.ee -rw-r--r-- 1 lovehouse staff 3405 Feb 16 17:09 Dockerfile -rwxr-xr-x 1 lovehouse staff 1148 Feb 16 17:09 checkDBStatus.sh -rwxr-xr-x 1 lovehouse staff 905 Feb 16 17:09 checkSpace.sh -rwxr-xr-x 1 lovehouse staff 3012 Feb 16 17:09 createDB.sh -rw-r--r-- 1 lovehouse staff 6878 Feb 16 17:09 db_inst.rsp -rw-r--r-- 1 lovehouse staff 9204 Feb 16 17:09 dbca.rsp.tmpl -rwxr-xr-x 1 lovehouse staff 2526 Feb 16 17:09 installDBBinaries.sh -rwxr-xr-x 1 lovehouse staff 6526 Feb 16 17:09 runOracle.sh -rwxr-xr-x 1 lovehouse staff 1015 Feb 16 17:09 runUserScripts.sh -rwxr-xr-x 1 lovehouse staff 758 Feb 16 17:09 setPassword.sh -rwxr-xr-x 1 lovehouse staff 932 Feb 16 17:09 setupLinuxEnv.sh -rwxr-xr-x 1 lovehouse staff 678 Feb 16 17:09 startDB.sh LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ cat Dockerfile LoveHousedeiMac:19.2.0 lovehouse$ cat Dockerfile |grep INSTALL_FILE_1 INSTALL_FILE_1="V981623-01.zip" \ COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_RSP $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/ LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:dockerfiles lovehouse$ |
我们可以看到,安装包就是叫V981623-01.zip,这和edelivery.oracle.com上下载的db安装包是同名的,不用改名。
2. 将安装包拷贝到该目录下,运行开始安装:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
LoveHousedeiMac:19.2.0 lovehouse$ pwd /Users/lovehouse/iDocker/marcelo-ochoa/docker-images/OracleDatabase/SingleInstance/dockerfiles/19.2.0 LoveHousedeiMac:19.2.0 lovehouse$ cp /Users/lovehouse/Downloads/V981623-01.zip ./ LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ ls -l total 11528424 -rw-r--r-- 1 lovehouse staff 49 Feb 16 17:09 Checksum.ee -rw-r--r-- 1 lovehouse staff 3405 Feb 16 17:09 Dockerfile -rw-r--r--@ 1 lovehouse staff 3032822863 Feb 16 17:33 V981623-01.zip -rw-r--r--@ 1 lovehouse staff 2869657581 Feb 16 17:14 V981627-01.zip -rwxr-xr-x 1 lovehouse staff 1148 Feb 16 17:09 checkDBStatus.sh -rwxr-xr-x 1 lovehouse staff 905 Feb 16 17:09 checkSpace.sh -rwxr-xr-x 1 lovehouse staff 3012 Feb 16 17:09 createDB.sh -rw-r--r-- 1 lovehouse staff 6878 Feb 16 17:09 db_inst.rsp -rw-r--r-- 1 lovehouse staff 9204 Feb 16 17:09 dbca.rsp.tmpl -rwxr-xr-x 1 lovehouse staff 2526 Feb 16 17:09 installDBBinaries.sh -rwxr-xr-x 1 lovehouse staff 6526 Feb 16 17:09 runOracle.sh -rwxr-xr-x 1 lovehouse staff 1015 Feb 16 17:09 runUserScripts.sh -rwxr-xr-x 1 lovehouse staff 758 Feb 16 17:09 setPassword.sh -rwxr-xr-x 1 lovehouse staff 932 Feb 16 17:09 setupLinuxEnv.sh -rwxr-xr-x 1 lovehouse staff 678 Feb 16 17:09 startDB.sh LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
LoveHousedeiMac:19.2.0 lovehouse$ cd .. LoveHousedeiMac:dockerfiles lovehouse$ ls 11.2.0.2 12.1.0.2 12.2.0.1 18.3.0 18.4.0 19.2.0 buildDockerImage.sh LoveHousedeiMac:dockerfiles lovehouse$ ./buildDockerImage.sh -v 19.2.0 -e Ignored MD5 sum, 'md5sum' command not available. ========================== DOCKER info: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 18.09.2 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true ...... Step 24/24 : CMD exec $ORACLE_BASE/$RUN_FILE ---> Running in f4bddc96e630 Removing intermediate container f4bddc96e630 ---> 65cdd07a7bc1 Successfully built 65cdd07a7bc1 Successfully tagged oracle/database:19.2.0-ee Oracle Database Docker Image for 'ee' version 19.2.0 is ready to be extended: --> oracle/database:19.2.0-ee Build completed in 574 seconds. LoveHousedeiMac:dockerfiles lovehouse$ LoveHousedeiMac:dockerfiles lovehouse$ |
附件是完整的log:build19c.log
我们看到image已经安装好,注意它是附带安装了一个slim版的oracle linux,这个在12.2安装的时候,就是这种模式:
1 2 3 4 5 |
LoveHousedeiMac:dockerfiles lovehouse$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 19.2.0-ee 65cdd07a7bc1 About an hour ago 6.33GB oraclelinux 7-slim c3d869388183 4 weeks ago 117MB LoveHousedeiMac:dockerfiles lovehouse$ |
3. 我们开始安装数据库实例:
注意oracle 企业版的docker run的命令格式如下(XE版的都有所区别):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
docker run --name <container name> \ -p <host port>:1521 -p <host port>:5500 \ -e ORACLE_SID=<your SID> \ -e ORACLE_PDB=<your PDB name> \ -e ORACLE_PWD=<your database passwords> \ -e ORACLE_CHARACTERSET=<your character set> \ -v [<host mount point>:]/opt/oracle/oradata \ oracle/database:18.3.0-ee Parameters: --name: The name of the container (default: auto generated) -p: The port mapping of the host port to the container port. Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express) -e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB) -e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1) -e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated) -e ORACLE_CHARACTERSET: The character set to use when creating the database (default: AL32UTF8) -v /opt/oracle/oradata The data volume to use for the database. Has to be writable by the Unix "oracle" (uid: 54321) user inside the container! If omitted the database will not be persisted over container recreation. -v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup Optional: A volume with custom scripts to be run after database startup. For further details see the "Running scripts after setup and on startup" section below. -v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup Optional: A volume with custom scripts to be run after database setup. For further details see the "Running scripts after setup and on startup" section below. |
我们开始安装实例(注意这里会生成一个sys,system和pdbadmin的密码):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
LoveHousedeiMac:dockerfiles lovehouse$ docker run --name oracle19c -p 1521:1521 -p 5500:5500 -v /Users/lovehouse/iDocker/dockervolums/oradata/oracle19c:/opt/oracle/oradata oracle/database:19.2.0-ee ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: L40uti33Ojk=1 LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 16-FEB-2019 10:55:17 ...... The Oracle base remains unchanged with value /opt/oracle ######################### DATABASE IS READY TO USE! ######################### The following output is now a tail of the alert.log: ORCLPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ORCLPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS" ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS" 2019-02-16T11:06:30.379489+00:00 ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE; 2019-02-16T11:06:30.383959+00:00 ALTER SYSTEM SET local_listener='' SCOPE=BOTH; ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE |
注,如果“DATABASE IS READY TO USE!”字样已经出现,且后面的log一直停着不动,可以在别的窗口重启container。
附件是完整的log:run19c.log
登陆主机或数据库进行操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
LoveHousedeiMac:19.2.0 lovehouse$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 39284f79172b oracle/database:19.2.0-ee "/bin/sh -c 'exec $O…" 26 minutes ago Up 11 minutes (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp oracle19c LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ LoveHousedeiMac:19.2.0 lovehouse$ docker exec -it 39284f79172b /bin/bash [oracle@39284f79172b ~]$ [oracle@39284f79172b ~]$ [oracle@39284f79172b admin]$ sqlplus sys/L40uti33Ojk=1@ORCLPDB1 as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 16 11:44:29 2019 Version 19.2.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.2.0.0.0 SQL> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
LoveHousedeiMac:~ lovehouse$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 39284f79172b oracle/database:19.2.0-ee "/bin/sh -c 'exec $O…" About an hour ago Up 39 minutes (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp oracle19c LoveHousedeiMac:~ lovehouse$ LoveHousedeiMac:~ lovehouse$ docker run --rm -ti oracle/database:19.2.0-ee sqlplus pdbadmin/L40uti33Ojk=1@//172.17.0.2:1521/ORCLPDB1 SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 16 11:50:21 2019 Version 19.2.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Last Successful login time: Sat Feb 16 2019 11:50:12 +00:00 Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.2.0.0.0 SQL> |
另外注意一下,以主机的方式登陆进去之后,直接sqlplus会报错ORA-12162,是因为docker镜像中没有指定ORACLE_SID,export一下就可以了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
[oracle@39284f79172b admin]$ sqlplus "/ as sysdba" SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 16 12:09:40 2019 Version 19.2.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. ERROR: ORA-12162: TNS:net service name is incorrectly specified Enter user-name: ERROR: ORA-12162: TNS:net service name is incorrectly specified Enter user-name: ERROR: ORA-12162: TNS:net service name is incorrectly specified SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus [oracle@39284f79172b admin]$ [oracle@39284f79172b admin]$ ps -ef |grep SID [oracle@39284f79172b admin]$ ps -ef |grep ora_smon |grep -v grep oracle 65 1 0 11:10 ? 00:00:00 ora_smon_ORCLCDB [oracle@39284f79172b admin]$ [oracle@39284f79172b admin]$ export ORACLE_SID=ORCLCDB [oracle@39284f79172b admin]$ [oracle@39284f79172b admin]$ [oracle@39284f79172b admin]$ sqlplus "/ as sysdba" SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 16 12:13:14 2019 Version 19.2.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.2.0.0.0 SQL> |
5条评论
19.3.0在官方dockerfile里面已经有了
嗯,谢谢,看到确实已经出来了。
oracle官方已经发布19.3的dockfile,见 https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance/dockerfiles/19.3.0 。
您好,请问这个zip包:/Users/lovehouse/Downloads/V981623-01.zip 是哪儿来的?
我用官网的也说找不到这个包!
Автономная канализация под ключ
Автономная канализация цена под ключ-это сегодня наш профиль
Обеспечиваем лучший завершающий результат
Автономная канализация в частном помещении – лучший выбор от компанииСборка септика – изрядно непростой процесс, предполагающий не только лишь строительство, но и дополнительно выбор нужной системы.
Для вас мы предлагаем высококлассные сервис по монтажу автономной канализации под ключ, владеем исключительной методикой и частным подходом к работе.
Большой уровень производства септиков