Docker install Oracle12c

 

    First, install the Docker application in the system (linux with a kernel above 3.8). Due to network reasons, it takes a long time for us to download an official Docker image, or even the download fails. To this end, Alibaba Cloud Container Image Service provides an official image site to speed up the download speed of official images. [No, you can refer to my previous article: Docker <1> Architecture Introduction and Installation on Linux  https://my.oschina.net/u/3375733/blog/1582281 ].

 

1. Docker install Oracle12c

    1. View the oracle command in the docker repository


docker search oracle 

    to see the information shown below:

    2. Select the database mirroring that needs to be pulled into the system

# docker pull sath89/oracle-12c --------sath89/oracle-12c为选定需要pull到系统中的数据库镜像

docker pull sath89/oracle-12c

    The whole pull process will take some time, be patient.

    If you see the figure below, it proves that the pull is successful.

 

2. View and start the Docker image

    1. List downloaded mirrors

# 使用 docker images 命令即可列出已下载的镜像

docker images

    After executing the command, you can see a table similar to the following:

    2. List running containers

# 使用 docker ps 命令即可列出运行中的容器

docker ps

    After executing the command, you can see a table similar to the following:

    It can be found that there are currently no running containers. Therefore, next we create and start an Oracle12c container.

 

3. Start the container and use the Oracle 12c database

    1. Create and start the container

# 使用 docker run 命令即可新建并启动一个容器

docker run

     The command syntax is as follows:

# 语法
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]  

# OPTIONS
-a stdin: 指定标准输入输出内容类型,可选 STDIN/STDOUT/STDERR 三项;

-d: 后台运行容器,并返回容器ID;

-i: 以交互模式运行容器,通常与 -t 同时使用;

-t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;

--name="nginx-lb": 为容器指定一个名称;

--dns 8.8.8.8: 指定容器使用的DNS服务器,默认和宿主一致;

--dns-search example.com: 指定容器DNS搜索域名,默认和宿主一致;

-h "mars": 指定容器的hostname;

-e username="ritchie": 设置环境变量;

--env-file=[]: 从指定文件读入环境变量;

--cpuset="0-2" or --cpuset="0,1,2": 绑定容器到指定CPU运行;

-m :设置容器使用内存最大值;

--net="bridge": 指定容器的网络连接类型,支持 bridge/host/none/container: 四种类型;

--link=[]: 添加链接到另一个容器;

--expose=[]: 开放一个端口或一组端口;

     Startup method 1: Run to open ports 8080 and 1521:

docker run -d -p 8080:8080 -p 1521:1521 sath89/oracle-12c

    After executing the command, see the following information, the container is started.

   

    View log:

docker log -f d9b8cbfa692bc4cfbf4fbbb85bec1990b76c6a7b454ae7bedee0fea21f88af89

   Enter the container virtual terminal:

docker exec -it d9b8cbfa692bc4cfbf4fbbb85bec1990b76c6a7b454ae7bedee0fea21f88af89 /bin/bash

    Startup method 2: The following commands can be used to achieve effective separation of containers and data:

docker run -d -p 8080:8080 -p 1521:1521 -v /my/oracle/data:/u01/app/oracle sath89/oracle-12c

    Startup method three: run with custom DBCA_TOTAL_MEMORY (in MB):


docker run -d -p 8080:8080 -p 1521:1521 \
 -v /my/oracle/data:/u01/app/oracle -e \
CA_TOTAL_MEMORY=1024 sath89/oracle-12c

   2. Connect to the Oracle Database 12c of this image

    Note that the oracle username and password created using this image are: system / oracle or sys / oracle; then we can use the local sql tool JetBrains DataGrip to connect to the oracle12c database.


# 使用以下设置连接数据库:
hostname: localhost
port: 1521
sid: xe
service name: xe
username: system
password: oracle

    

    Connect using sqlplus:

sqlplus system/oracle@//localhost:1521/xe

    Password for SYS & SYSTEM:

oracle

    Connect to the Oracle Application Express Web Administration Console with the following settings:

http://localhost:8080/apex
workspace: INTERNAL
user: ADMIN
password: 0Racle$

    Apex upgrade to v 5.*

docker run -it --rm --volumes-from ${DB_CONTAINER_NAME} \ 
--link ${DB_CONTAINER_NAME}:oracle-database \
-e PASS=YourSYSPASS sath89/apex install

    Connect to the Oracle Enterprise Management Console with the following settings:

http://localhost:8080/em
user: sys
password: oracle
connect as sysdba: true

    By default, the web management console is enabled. Disable adding environment variables:

docker run -d -e WEB_CONSOLE=false -p 1521:1521 -v /my/oracle/data:/u01/app/oracle sath89/oracle-12c
#You can Enable/Disable it on any time

    Added script or dump (clean) initialization:

docker run -d -p 1521:1521 -v \
/my/oracle/data:/u01/app/oracle -v \
/my/oracle/init/SCRIPTSorSQL:/docker-entrypoint-initdb.d sath89/oracle-12c

    By default, docker-entrypoint-initdb.dimporting is only enabled when the database is initialized (first run).

    To custom dump import use IMPDP_OPTIONS environment variable like -e IMPDP_OPTION="REMAP_TABLESPACE=FOO:BAR" In any case run import add -e IMPORT_FROM_VOLUME=true .

    In case the dump file is imported using DMP, it should be named ${IMPORT_SCHEME_NAME}.dmp

    User entered credentials are ${IMPORT_SCHEME_NAME}/${IMPORT_SCHEME_NAME}

 

Fourth, connect to Oracle 12c and modify the default administrator account password

    1. Change the user's password

-- 查看用户的proifle是哪个,一般是default:
SELECT username,PROFILE FROM dba_users;

-- 查看指定概要文件(如default)的密码有效期设置:
SELECT * FROM dba_profiles s WHERE s.profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';

-- 将密码有效期由默认的180天修改成“无限制”:修改之后不需要重启动数据库,会立即生效。
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

-- 修改用户SYSTEM 密码
alter user SYSTEM identified by "****password****";

    2. How to unlock the user


-- 解锁方法
alter user SYSTEM account unlock;

 

Related Links

    · docker-oracle-12c its GitHub homepage:  https://github.com/MaksymBilenko/docker-oracle-12c
    · Apex details: http://https://github.com/MaksymBilenko/docker-oracle-apex

    · Docker's Github homepage: https://github.com/docker

   · Oracle Database 12c documentation: http://www.oracle.com/technetwork/cn/database/enterprise-edition/documentation/index.html

 

This article is an original article by the blogger, please indicate the source for reprinting!

https://my.oschina.net/u/3375733/blog/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325434285&siteId=291194637