sudo package install docker oracle


[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# yum list installed | grep sudo
bash-4.2# yum install -y sudo
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package sudo.x86_64 0:1.8.23-3.el7 will be installed
--> Processing Dependency: /usr/bin/vi for package: sudo-1.8.23-3.el7.x86_64
--> Running transaction check
---> Package vim-minimal.x86_64 2:7.4.160-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                             Arch                           Version                                  Repository                          Size
======================================================================================================================================================
Installing:
 sudo                                x86_64                         1.8.23-3.el7                             ol7_latest                         841 k
Installing for dependencies:
 vim-minimal                         x86_64                         2:7.4.160-5.el7                          ol7_latest                         436 k

Transaction Summary
======================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 1.2 M
Installed size: 3.9 M
Downloading packages:
(1/2): vim-minimal-7.4.160-5.el7.x86_64.rpm                                                                                    | 436 kB  00:00:04     
(2/2): sudo-1.8.23-3.el7.x86_64.rpm                                                                                            | 841 kB  00:00:04     
------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                 283 kB/s | 1.2 MB  00:00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:vim-minimal-7.4.160-5.el7.x86_64                                                                                                 1/2 
  Installing : sudo-1.8.23-3.el7.x86_64                                                                                                           2/2 
  Verifying  : 2:vim-minimal-7.4.160-5.el7.x86_64                                                                                                 1/2 
  Verifying  : sudo-1.8.23-3.el7.x86_64                                                                                                           2/2 

Installed:
  sudo.x86_64 0:1.8.23-3.el7                                                                                                                          

Dependency Installed:
  vim-minimal.x86_64 2:7.4.160-5.el7                                                                                                                  

Complete!
bash-4.2# yum list installed | grep sudo
sudo.x86_64                    1.8.23-3.el7             @ol7_latest             
bash-4.2# 

sql oracle clone pluggable database


[oracle@609a69bc0b21 ~]$ cd $ORACLE_BASE
[oracle@609a69bc0b21 oracle]$ ll
total 40
drwxr-x---. 3 oracle oinstall   18 Dec 23 13:11 admin
drwxr-x---. 2 oracle oinstall    6 Dec 23 13:11 audit
drwxr-x---. 4 oracle oinstall   34 Dec 23 13:22 cfgtoollogs
-rwxrwxrwx. 1 oracle dba      1148 Dec  8 00:58 checkDBStatus.sh
drwxr-xr-x. 2 oracle dba         6 Dec 23 08:52 checkpoints
-rwxrwxrwx. 1 oracle dba      2953 Dec  8 00:58 createDB.sh
-rwxrwxrwx. 1 oracle dba      9204 Dec  8 00:58 dbca.rsp.tmpl
drwxrwxr-x. 1 oracle dba        34 Dec 23 08:52 diag
drwxrwx---. 1 oracle dba        89 Dec 23 08:52 oraInventory
drwxr-xr-x. 4 oracle dba        34 Dec 23 13:29 oradata
drwxr-xr-x. 1 oracle dba        22 Dec 23 08:20 product
-rwxrwxrwx. 1 oracle dba      6526 Dec  8 00:58 runOracle.sh
-rwxrwxrwx. 1 oracle dba      1015 Dec  8 00:58 runUserScripts.sh
drwxr-xr-x. 1 oracle dba        34 Dec 23 08:20 scripts
-rwxrwxrwx. 1 oracle dba       758 Dec  8 00:58 setPassword.sh
-rwxrwxrwx. 1 oracle dba       678 Dec  8 00:58 startDB.sh
[oracle@609a69bc0b21 oracle]$ cd oradata
[oracle@609a69bc0b21 oradata]$ ll
total 0
drwxr-x---. 5 oracle oinstall 239 Dec 25 12:14 ORCL
drwxr-xr-x. 3 oracle oinstall  18 Dec 23 13:29 dbconfig
[oracle@609a69bc0b21 oradata]$ cd ORCL
[oracle@609a69bc0b21 ORCL]$ ll
total 2263508
drwxr-x---. 2 oracle oinstall       104 Dec 23 13:29 PDB1
drwxr-x---. 2 oracle oinstall       104 Dec 25 12:14 PDB2
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:29 control01.ctl
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:29 control02.ctl
drwxr-x---. 2 oracle oinstall       111 Dec 23 13:18 pdbseed
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 00:05 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 14:28 redo02.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 24 22:06 redo03.log
-rw-r-----. 1 oracle oinstall 597696512 Dec 25 14:25 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 849354752 Dec 25 14:27 system01.dbf
-rw-r-----. 1 oracle oinstall 137371648 Dec 25 00:45 temp01.dbf
-rw-r-----. 1 oracle oinstall  73408512 Dec 25 14:27 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 25 00:10 users01.dbf
[oracle@609a69bc0b21 ORCL]$ pwd
/opt/oracle/oradata/ORCL
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:30:43 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
SYS@ORCL> create pluggable database PDB3 from PDB1 FILE_NAME_CONVERT=('/opt/oracle/oradata/ORCL/PDB1','/opt/oracle/oradata/ORCL/PDB3');

Pluggable database created.

Elapsed: 00:00:09.26
SYS@ORCL> create pluggable database PDB4 from PDB1 FILE_NAME_CONVERT=('/opt/oracle/oradata/ORCL/PDB1','/opt/oracle/oradata/ORCL/PDB4');

Pluggable database created.

Elapsed: 00:00:10.38
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
5 PDB3                           MOUNTED
6 PDB4                           MOUNTED
SYS@ORCL> alter pluggable database all open;

Pluggable database altered.

Elapsed: 00:00:25.74
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
5 PDB3                           READ WRITE NO
6 PDB4                           READ WRITE NO
SYS@ORCL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb3 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:37:14 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name: [oracle@609a69bc0b21 ORCL]$
[oracle@609a69bc0b21 ORCL]$ find / -name tnsnames.ora -type f 2>/dev/null
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/samples/tnsnames.ora
/opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@609a69bc0b21 ORCL]$ vim /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/tnsnames.ora

ORCL=localhost:1521/ORCL
PDB1=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
PDB2=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB2)
)
)
PDB3=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB3)
)
)
PDB4=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB4)
)
)

[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb3 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:40:02 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb3> show con_name

CON_NAME
------------------------------
PDB3
SYS@pdb3> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb4 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:40:30 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb4> show con_name

CON_NAME
------------------------------
PDB4
SYS@pdb4> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus aine/ORACLE_PWD@pdb3

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:41:10 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Dec 25 2018 11:50:03 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

AINE@pdb3> select * from warehouse_mst;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29

3 rows selected.

Elapsed: 00:00:00.07
AINE@pdb3> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus aine/ORACLE_PWD@pdb4

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:41:38 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Dec 25 2018 11:50:03 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

AINE@pdb4> select * from warehouse_mst;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29

3 rows selected.

Elapsed: 00:00:00.06
AINE@pdb4> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ ll
total 2263564
drwxr-x---. 2 oracle oinstall       104 Dec 23 13:29 PDB1
drwxr-x---. 2 oracle oinstall       104 Dec 25 12:14 PDB2
drwxr-x---. 2 oracle oinstall       104 Dec 25 14:33 PDB3
drwxr-x---. 2 oracle oinstall       104 Dec 25 14:33 PDB4
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:41 control01.ctl
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:41 control02.ctl
drwxr-x---. 2 oracle oinstall       111 Dec 23 13:18 pdbseed
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 00:05 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 14:41 redo02.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 24 22:06 redo03.log
-rw-r-----. 1 oracle oinstall 597696512 Dec 25 14:41 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 849354752 Dec 25 14:41 system01.dbf
-rw-r-----. 1 oracle oinstall 137371648 Dec 25 14:36 temp01.dbf
-rw-r-----. 1 oracle oinstall  73408512 Dec 25 14:41 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 25 00:10 users01.dbf
[oracle@609a69bc0b21 ORCL]$

sql oracle 12cr2 dblink

[oracle@b51cf2f967ec ~]$ find / -name tnsnames.ora -type f 2>/dev/null
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/samples/tnsnames.ora
/opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@b51cf2f967ec ~]$ cd /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/
[oracle@b51cf2f967ec admin]$ pwd
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin
[oracle@b51cf2f967ec admin]$ ll
total 4
lrwxrwxrwx. 1 oracle oinstall   46 Dec 24 14:00 listener.ora -> /opt/oracle/oradata/dbconfig/ORCL/listener.ora
drwxr-xr-x. 1 oracle dba         6 Dec 25 20:21 samples
-rw-r--r--. 1 oracle dba      1441 Aug 28  2015 shrept.lst
lrwxrwxrwx. 1 oracle oinstall   44 Dec 24 14:00 sqlnet.ora -> /opt/oracle/oradata/dbconfig/ORCL/sqlnet.ora
lrwxrwxrwx. 1 oracle oinstall   46 Dec 24 14:00 tnsnames.ora -> /opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@b51cf2f967ec admin]$ vim tnsnames.ora


ORCL=localhost:1521/ORCL
PDB1=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
RMTPDB2=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.108)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PDB2)
)
)

[oracle@b51cf2f967ec admin]$ sqlplus sys/ORACLE_PWD@pdb1 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 23:18:50 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb1> grant create database link to aine;

Grant succeeded.

Elapsed: 00:00:00.05
SYS@pdb1> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@b51cf2f967ec admin]$ sqlplus aine/ORACLE_PWD@pdb1

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 23:19:35 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Dec 25 2018 22:39:49 +09:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

AINE@pdb1> CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2';
CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2'
*
ERROR at line 1:
ORA-02011: duplicate database link name

Elapsed: 00:00:00.01
AINE@pdb1> drop database link testlink;

Database link dropped.

Elapsed: 00:00:00.01
AINE@pdb1> CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2';

Database link created.

Elapsed: 00:00:00.01
AINE@pdb1> select * from warehouse_mst@testlink;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29
w_9999                                              25

4 rows selected.

Elapsed: 00:00:00.35
AINE@pdb1>

oracle 12cr2 plugable database glogin.sql

参考文献
http://discus-hamburg.cocolog-nifty.com/mac_de_oracle/2013/07/oracle-database.html

COLUMN OTHER_PLUS_EXP FORMAT A200
COLUMN PLAN_PLUS_EXP  FORMAT A200
SET NUMWIDTH 13
SET LINESIZE 1000
SET LONG 40000
SET LONGCHUNKSIZE 40000
SET PAGESIZE 50000
SET SERVEROUTPUT ON
SET TAB OFF
SET TRIMSPOOL ON
set feed on
--set autotrace traceonly
set timing on
--set hist on
DEFINE_EDITOR=nano
set sqlp "_USER'@'_CONNECT_IDENTIFIER> "
[oracle@centos7 ~]$ docker exec -it orcl_12cr2 /bin/bash
[oracle@609a69bc0b21 ~]$ vim
[oracle@609a69bc0b21 ~]$ find / -name *login*.sql -type f 2>/dev/null
/mnt/11gr2/share/login/glogin.sql
/opt/oracle/product/12.2.0.1/dbhome_1/sqlplus/admin/glogin.sql
[oracle@609a69bc0b21 ~]$ vim /opt/oracle/product/12.2.0.1/dbhome_1/sqlplus/admin/glogin.sql
[oracle@609a69bc0b21 ~]$ sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sun Dec 23 14:49:53 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> 
SYS@ORCL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ~]$ sqlplus sys/ORACLE_PWD@pdb1 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sun Dec 23 14:50:22 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb1> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production