oracle:docker镜像部署11g 创建用户名,远程连接
程序员文章站
2022-04-29 17:14:43
将registry.cn-hangzhou.aliyuncs.com-helowin-oracle_11g.tar 上传到root下,然后按照如下进行操作就好,剩下的看文档:[root@oracle ~]# lltotal 13513832-rw-------. 1 root root 1505 Jul 10 18:57 anaconda-ks.cfg-rw-------. 1 root root 6913197568 Jul 11 07:25 registry.cn-hangzh....
将registry.cn-hangzhou.aliyuncs.com-helowin-oracle_11g.tar 上传到root下,然后按照如下进行操作就好,剩下的看文档:
注意镜像ID以及容器ID以本机生成为准,不要照抄文中的ID
[root@oracle ~]# ll
total 13513832
-rw-------. 1 root root 1505 Jul 10 18:57 anaconda-ks.cfg
-rw-------. 1 root root 6913197568 Jul 11 07:25 registry.cn-hangzhou.aliyuncs.com-helowin-oracle_11g.tar
[root@oracle ~]# docker load -i registry.cn-hangzhou.aliyuncs.com-helowin-oracle_11g.tar
Loaded image: registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
[root@oracle ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@oracle ~]# mkdir -p /usr/local/data_temp
[root@oracle ~]# chown -R 500.500 /usr/local/data_temp
[root@oracle ~]# docker run -d --name oracle_11g_v2 -p 1521:1521 -v /usr/local/data_temp:/home/oracle/data_temp registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
a1d48a68d5d6a2783b9f80984c345a403c21ff0d667d736df26fc9bcce3ddd55
[root@oracle ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1d48a68d5d6 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home..." 46 seconds ago Up 35 seconds 0.0.0.0:1521->1521/tcp oracle_11g_v2
[root@oracle ~]# docker exec -it a1d48a68d5d6 /bin/bash
[oracle@a1d48a68d5d6 /]$ cd
[oracle@a1d48a68d5d6 ~]$ ll
total 0
drwxr-xr-x. 1 oracle oinstall 20 Aug 27 2014 app
drwxr-xr-x. 2 oracle oinstall 6 Jul 11 11:26 data_temp
[oracle@a1d48a68d5d6 ~]$ ls -l
total 0
drwxr-xr-x. 1 oracle oinstall 20 Aug 27 2014 app
drwxr-xr-x. 2 oracle oinstall 6 Jul 11 11:26 data_temp
[oracle@a1d48a68d5d6 ~]$ ls -a
. .. .bash_history .bash_logout .bash_profile .bashrc .oracle app data_temp
[oracle@a1d48a68d5d6 ~]$ source .bash_profile
[oracle@a1d48a68d5d6 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 19:45:37 2020
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected.
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> alter user system identified by oracle;
User altered.
SQL> select * from nls_database_parameters where parameter ='NLS_CHARACTERSET';
PARAMETER
------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
AL32UTF8
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2213776 bytes
Variable Size 402655344 bytes
Database Buffers 1191182336 bytes
Redo Buffers 7360512 bytes
Database mounted.
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
System altered.
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
System altered.
SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;
System altered.
SQL> alter database open;
Database altered.
SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK;
Database altered.
SQL> startup;
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2213776 bytes
Variable Size 402655344 bytes
Database Buffers 1191182336 bytes
Redo Buffers 7360512 bytes
Database mounted.
Database opened.
SQL> create or replace directory DATA_TEMP as '/home/oracle/data_temp';
Directory created.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/home/oracle/app/oracle/oradata/helowin/temp01.dbf
SQL> create user testabc identified by test123456;
User created.
SQL> alter user testabc account unlock;
User altered.
SQL> grant dba to testabc;
Grant succeeded.
SQL> grant create session to testabc;
Grant succeeded.
SQL> GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,
DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,
DBA,CONNECT,RESOURCE,CREATE SESSION TO testabc;
Grant succeeded.
SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Profile altered.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@a1d48a68d5d6 ~]$ exit
exit
[root@oracle ~]#
设置容器自启动
[root@oracle ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1d48a68d5d6 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home..." 38 minutes ago Up 38 minutes 0.0.0.0:1521->1521/tcp oracle_11g_v2
[root@oracle ~]# docker update --restart=always a1d48a68d5d6
a1d48a68d5d6
[root@oracle ~]#
鸣谢:https://www.cnblogs.com/MrXiaoAndDong/p/docker_oracle.html
本文地址:https://blog.csdn.net/shunzi2016/article/details/107290054
上一篇: MySQL建表查询