本文主要是介绍Docker 安装oracle12c容器并创建新用户,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Docker 安装oracle12c容器并创建新用户
-
下载镜像
docker pull truevoly/oracle-12c
-
启动镜像 8080和22端口没有映射出来,有需要自己
docker run -d -p 8123:1521 -restart=always --privileged=true -v /data/docker/Oracle12c_sichuan:/u01/app/oracle/ --name oracle12c-sichuan truevoly/oracle-12c
-
正常日志
Database not initialized. Initializing database. Starting tnslsnr Copying database files 1% complete 3% complete 11% complete 18% complete 37% complete Creating and starting Oracle instance 40% complete 62% complete Completing Database Creation 96% complete 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/xe/xe.log" for further details. Configuring Apex console Database initialized. Please visit http://#containeer:8080/em http://#containeer:8080/apex for extra configuration if needed Starting web management console PL/SQL procedure successfully completed. Starting import from '/docker-entrypoint-initdb.d': ls: cannot access /docker-entrypoint-initdb.d/*: No such file or directory Import finished Database ready to use. Enjoy! ;)
-
启动报错日志
atabase not initialized. Initializing database. Starting tnslsnr Cannot create directory "/u01/app/oracle/cfgtoollogs/dbca". Unique database identifier check passed. Error writing into silent log -- /u01/app/oracle/cfgtoollogs/dbca/silent.log_2023-10-17_03-29-34-AM (No such file or directory) /u01/app/oracle/ has enough space. Required space is 6140 MB , available space is 128006 MB. File Validations Successful. Error writing into silent log -- /u01/app/oracle/cfgtoollogs/dbca/silent.log_2023-10-17_03-29-34-AM (No such file or directory) Cannot create directory "/u01/app/oracle/cfgtoollogs/dbca/xe". Error writing into silent log -- /u01/app/oracle/cfgtoollogs/dbca/silent.log_2023-10-17_03-29-34-AM (No such file or directory) Error in file copy from </u01/app/oracle/cfgtoollogs/dbca/silent.log_2023-10-17_03-29-34-AM> to </u01/app/oracle/cfgtoollogs/dbca/xe.log> Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/silent.log_2023-10-17_03-29-34-AM" for further details.
原因 容器没有操作主机文件夹权限
主机内执行
chmod -R a+w /data/docker/Oracle12c_sichuan
-
-
进入容器内并以dba登录Oracle
# 进入oracle-12c容器内 docker exec -it oracle-12c /bin/bash # 切换成oracle用户 su oracle # 进入sqlplus $ORACLE_HOME/bin/sqlplus / as sysdba
-
创建表空间及用户和赋权
# 设置密码有效期为无限制 # 默认有sys和system两个用户,密码都是oracle,默认的一个SID/服务名是xeSQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;# 解锁system用户 SQL> alter user SYSTEM account unlock; SQL> alter user SYS account unlock;创建四川表空间 --表空间 --不限制表空间大小用:maxsize unlimited --限制表空间大小用:maxsize 1024m --自动扩充表空间:一次50m --注意表空间名实际会变成大写 SICHUAN_DATA create tablespace sichuan_data logging datafile '/u01/app/oracle/oradata/xe/sichuan_data.dbf' size 50m autoextend on next 50m maxsize unlimited extent management local;--创建临时表空间 create temporary tablespace sichuan_temp tempfile '/u01/app/oracle/oradata/xe/sichuan_temp.dbf' size 50m autoextend on next 50m maxsize unlimited extent management local;alter user system identified by "6#rKXq24@1"; alter user sys identified by "6#rKXq24@1"; # 创建用户 # 密码带特殊符号 password 需要双引号 "password" create user username identified by password;# 依次给各用户赋权SQL> GRANT ALTER ANY PROCEDURE TO username; SQL> GRANT ALTER ANY TABLE TO username; SQL> GRANT ALTER ANY TRIGGER TO username; SQL> GRANT ALTER ANY TYPE TO username; SQL> GRANT CREATE ANY TABLE TO username; SQL> GRANT DELETE ANY TABLE TO username; SQL> GRANT DROP ANY PROCEDURE TO username; SQL> GRANT DROP ANY SEQUENCE TO username; SQL> GRANT DROP ANY TABLE TO username; SQL> GRANT DROP ANY TRIGGER TO username; SQL> GRANT DROP ANY TYPE TO username; SQL> GRANT DROP ANY VIEW TO username; SQL> GRANT SELECT ANY DICTIONARY TO username; SQL> GRANT SELECT ANY SEQUENCE TO username; SQL> GRANT SELECT ANY TABLE TO username; SQL> GRANT UNDER ANY TABLE TO username; SQL> GRANT UNDER ANY TYPE TO username; SQL> GRANT UNDER ANY VIEW TO username; SQL> GRANT UNLIMITED TABLESPACE TO username; SQL> GRANT UPDATE ANY TABLE TO username; SQL> GRANT CONNECT TO username; SQL> GRANT DBA TO username; SQL> GRANT RESOURCE TO username;修改用户的默认表空间为sichuan_data: SQL> alter user XZXK default tablespace sichuan_data; SQL> alter user XZXK_JL default tablespace sichuan_data; SQL> alter user ESF default tablespace sichuan_data; SQL> alter user DIC default tablespace sichuan_data;
这篇关于Docker 安装oracle12c容器并创建新用户的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!