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文章来源:https://www.toymoban.com/news/detail-715221.html
# 进入oracle-12c容器内 docker exec -it oracle-12c /bin/bash # 切换成oracle用户 su oracle # 进入sqlplus $ORACLE_HOME/bin/sqlplus / as sysdba
-
创建表空间及用户和赋权文章来源地址https://www.toymoban.com/news/detail-715221.html
# 设置密码有效期为无限制 # 默认有sys和system两个用户,密码都是oracle,默认的一个SID/服务名是xe SQL> 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容器并创建新用户的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!