当前位置: 首页 > 工具软件 > Docker Oracle > 使用案例 >

docker Oracle11G/Oracle 19C安装

墨寂弦
2023-12-01

Oracle11G

一、启动新容器

docker run -d -p 7000:1521 \
--name ora_gzns --restart=always \
-v /home/oracle/ora_gzns:/u01/app/oracle/oradata \
-v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime \
-e ORACLE_ALLOW_REMOTE=true \
-e ORACLE_DISABLE_ASYNCH_IO=true \
toneloc01/oracle-xe-11g

#Login http://localhost:8080/apex/apex_admin with following credential:
username: system
password: oracle

二、数据库用户密码设置

  1. sqlplus 连接
root@7d7d5691d859:/# sqlplus system/oracle@//localhost:1521/xe
  1. 修改密码有效期,由180天改成无限制

– 密码过期时间设置为无期限

alter profile default  limit password_life_time unlimited;
commit;

– 进行以上步骤之后需要改变密码,否则还会出现password has expired异常

alter user a identified by A;
  1. 解锁用户
SQL> alter user SYSTEM account unlock
SQL>alter user a account unlock;
  1. 创建用户
#sqlplus system/oracle@//localhost:1521/xe
SQL*Plus: Release 11.2.0.2.0 Production on Thu Nov 19 09:52:01 2020
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>

#创建用户,赋予权限

create user a identified by a;
grant connect, resource to a;

#修改密码

alter user a identified by A;

#退出

SQL> exit

三、修改端口

进入容器
docker exec -it <容器ID> bash
cd $ORACLE_HOME/network/admin
#需要修改这个文件tnsnames.ora 修改第四行的端口为外部端口即可
#这里是7000
docker_oracle11 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT =7000))
)
(CONNECT_DATA =
(SERVICE_NAME = helowinXDB)
)
)

Oralce19C

创建组
groupadd oracle
#注意:/oracle/oradata目录权限一定要正确,在容器中oracle用户的uid是54321,所以要保证容器内的oracle用户有权限读写该目录。
如创建oracle用户且uid是54321:
#用户uid:54321的用户,需要对数据持久化目录(如:/home/oracle/ora_hflc)有写的权限
useradd -u 54321 -g oracle -d /home/oracle -s /bin/bash -c “Oracle Software Owner” oracle19c

echo 新密码 | passwd --stdin 用户名

echo “oracle19c” | passwd --stdin oracle19c

uid:54321 对目录/home/oracle/ora_hflc赋权

chown oracle19c:oracle /home/oracle/ora_hflc

启动

docker run -d -p 17018:5500 -p 7018:1521 --name ora_hflc
–restart=always
-v /home/oracle/ora_hflc:/opt/oracle/oradata
-v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
-e ORACLE_PDB=aml
-e ORACLE_SID=orcl
-e ORACLE_PWD=oracle
container-registry.oracle.com/database/enterprise:19.3.0.0

ORACLE_SID:实例名
ORACLE_PWD:sys或者system用户的密码
#配置sys/system密码
docker exec -it ora_hflc /bin/bash
./setPassword.sh oracle

#登录数据库
$sqlplus sys/oracle@localhost/aml as sysdba

#注问题处理(连接空实例)
SQL> conn /as sysdba
Connected to an idle instance.
SQL> exit
$cd /opt/oracle/admin/ORCL/pfile
$cp init.ora.06202215440 /opt/oracle/product/19c/dbhome_1/dbs/initorcl.ora
SQL>strtup;

#给表空间配额

alter user aml_dm quota unlimited on system;

 类似资料: