gmail sending settings centos7 cron

plugin install


[oracle@centos7 postfix]$ sudo yum install -y mailx cyrus-sasl-plain
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: ftp.nara.wide.ad.jp
 * updates: centos.ustc.edu.cn
パッケージ mailx-12.5-19.el7.x86_64 はインストール済みか最新バージョンです
パッケージ cyrus-sasl-plain-2.1.26-23.el7.x86_64 はインストール済みか最新バージョンです
何もしません
[oracle@centos7 postfix]$ 

postfix mail send env


[oracle@centos7 ~]$ sudo vim /etc/postfix/main.cf
[sudo] oracle のパスワード:

/etc/postfix/main.cf


# The relayhost parameter specifies the default host to send mail to
# when no entry is matched in the optional transport(5) table. When
# no relayhost is given, mail is routed directly to the destination.
#
# On an intranet, specify the organizational domain name. If your
# internal DNS uses no MX records, specify the name of the intranet
# gateway host instead.
#
# In the case of SMTP, specify a domain, host, host:port, [host]:port,
# [address] or [address]:port; the form [host] turns off MX lookups.
#
# If you're connected via UUCP, see also the default_transport parameter.
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]
relayhost = [smtp.gmail.com]:587

#sasl setting
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain

#tls setting
smtp_use_tls = yes

root mail transport to gamil


[oracle@centos7 postfix]$ vim /etc/aliases
# Person who should get root's mail
#root:          marc
root:           メールアドレス@gmail.com

/etc/postfix/sasl_passwd


[oracle@centos7 ~]$ cd /etc/postfix/
[oracle@centos7 postfix]$ ll
合計 148
-rw-r--r--. 1 root root 20876  6月 10  2014 access
-rw-r--r--. 1 root root 11681  6月 10  2014 canonical
-rw-r--r--. 1 root root  9904  6月 10  2014 generic
-rw-r--r--. 1 root root 21545  6月 10  2014 header_checks
-rw-r--r--. 1 root root 27464 12月 29 07:46 main.cf
-rw-r--r--. 1 root root  6105  6月 10  2014 master.cf
-rw-r--r--. 1 root root  6816  6月 10  2014 relocated
-rw-r--r--. 1 root root 12549  6月 10  2014 transport
-rw-r--r--. 1 root root 12494  6月 10  2014 virtual
[oracle@centos7 postfix]$ sudo vim /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 メールアドレス@gmail.com:password

grand to sasl_passwd


[oracle@centos7 postfix]$ ll
合計 152
-rw-r--r--. 1 root root 20876  6月 10  2014 access
-rw-r--r--. 1 root root 11681  6月 10  2014 canonical
-rw-r--r--. 1 root root  9904  6月 10  2014 generic
-rw-r--r--. 1 root root 21545  6月 10  2014 header_checks
-rw-r--r--. 1 root root 27464 12月 29 07:46 main.cf
-rw-r--r--. 1 root root  6105  6月 10  2014 master.cf
-rw-r--r--. 1 root root  6816  6月 10  2014 relocated
-rw-r--r--. 1 root root    62 12月 29 07:52 sasl_passwd
-rw-r--r--. 1 root root 12549  6月 10  2014 transport
-rw-r--r--. 1 root root 12494  6月 10  2014 virtual
[oracle@centos7 postfix]$ sudo chmod 600 /etc/postfix/sasl_passwd
[oracle@centos7 postfix]$ ll
合計 152
-rw-r--r--. 1 root root 20876  6月 10  2014 access
-rw-r--r--. 1 root root 11681  6月 10  2014 canonical
-rw-r--r--. 1 root root  9904  6月 10  2014 generic
-rw-r--r--. 1 root root 21545  6月 10  2014 header_checks
-rw-r--r--. 1 root root 27464 12月 29 07:46 main.cf
-rw-r--r--. 1 root root  6105  6月 10  2014 master.cf
-rw-r--r--. 1 root root  6816  6月 10  2014 relocated
-rw-------. 1 root root    62 12月 29 07:52 sasl_passwd
-rw-r--r--. 1 root root 12549  6月 10  2014 transport
-rw-r--r--. 1 root root 12494  6月 10  2014 virtual
[oracle@centos7 postfix]$ 

mapping sasl_passwd to postfix


[oracle@centos7 postfix]$ ll
合計 160
-rw-r--r--. 1 root root 20876  6月 10  2014 access
-rw-r--r--. 1 root root 11681  6月 10  2014 canonical
-rw-r--r--. 1 root root  9904  6月 10  2014 generic
-rw-r--r--. 1 root root 21545  6月 10  2014 header_checks
-rw-r--r--. 1 root root 27464 12月 29 07:46 main.cf
-rw-r--r--. 1 root root  6105  6月 10  2014 master.cf
-rw-r--r--. 1 root root  6816  6月 10  2014 relocated
-rw-------. 1 root root    65 12月 29 08:57 sasl_passwd
-rw-------. 1 root root 12288 12月 29 07:53 sasl_passwd.db
-rw-r--r--. 1 root root 12549  6月 10  2014 transport
-rw-r--r--. 1 root root 12494  6月 10  2014 virtual
[oracle@centos7 postfix]$ sudo postmap /etc/postfix/sasl_passwd
[oracle@centos7 postfix]$ ll
合計 160
-rw-r--r--. 1 root root 20876  6月 10  2014 access
-rw-r--r--. 1 root root 11681  6月 10  2014 canonical
-rw-r--r--. 1 root root  9904  6月 10  2014 generic
-rw-r--r--. 1 root root 21545  6月 10  2014 header_checks
-rw-r--r--. 1 root root 27464 12月 29 07:46 main.cf
-rw-r--r--. 1 root root  6105  6月 10  2014 master.cf
-rw-r--r--. 1 root root  6816  6月 10  2014 relocated
-rw-------. 1 root root    65 12月 29 08:57 sasl_passwd
-rw-------. 1 root root 12288 12月 29 08:59 sasl_passwd.db
-rw-r--r--. 1 root root 12549  6月 10  2014 transport
-rw-r--r--. 1 root root 12494  6月 10  2014 virtual

sudo service postfix restart


[oracle@centos7 postfix]$ sudo service postfix restart
Redirecting to /bin/systemctl restart postfix.service
[oracle@centos7 postfix]$ 

test sending


echo "hoge" | mail -s "test email" メールアドレス@gmail.com

crontab -e


MAILTO='メールアドレス@gmail.com'
22 9 * * * echo "hey"

docker network

独自ネットワーク作成


[oracle@centos7 docker]$ docker network create --subnet=192.168.200.0/24 user_defined_nw
94d83b03fa3f790af5de17af4a6fb396ce8ea9e7153a3720bf663f9629362ffb
[oracle@centos7 docker]$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
0e36d0bb7052        bridge              bridge              local
0bdba384a7be        host                host                local
483c017347fc        none                null                local
94d83b03fa3f        user_defined_nw     bridge              local

コンテナを作る


[oracle@centos7 docker]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
oracle/database     12.2.0.1-ee         bd737fd89ef9        5 days ago          5.97GB
oraclelinux         7-slim              b19454a5f17a        7 weeks ago         117MB
hello-world         latest              4ab4c602aa5e        3 months ago        1.84kB

[oracle@centos7 docker]$ docker run -it --name test1 --net=user_defined_nw -d oraclelinux:7-slim /bin/bash
[oracle@centos7 docker]$ docker run -it --name test2 --net=user_defined_nw -d oraclelinux:7-slim /bin/bash
[oracle@centos7 docker]$ docker run -it --name test3 --net=user_defined_nw -d oraclelinux:7-slim /bin/bash


CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                     PORTS               NAMES
1c10308b5238        oraclelinux:7-slim            "/bin/bash"              28 minutes ago      Up 28 minutes                                  test1
6bc6cd79c469        oraclelinux:7-slim            "/bin/bash"              42 minutes ago      Up 42 minutes                                  test3
2e7fbb790b46        oraclelinux:7-slim            "/bin/bash"              43 minutes ago      Up 43 minutes                                  test2

割り当てられたipの確認


[oracle@centos7 ~]$ docker network inspect $(docker network ls -q) | grep -E "Subnet|Name|IPv4"
        "Name": "bridge",
                    "Subnet": "172.17.0.0/16",
        "Name": "host",
        "Name": "none",
        "Name": "user_defined_nw",
                    "Subnet": "192.168.200.0/24"
                "Name": "test1",
                "IPv4Address": "192.168.200.2/24",
                "Name": "test2",
                "IPv4Address": "192.168.200.3/24",
                "Name": "test3",
                "IPv4Address": "192.168.200.4/24",

デフォルトゲートウェイは192.168.200.1にわりあてられています。


[oracle@centos7 ~]$ docker network inspect user_defined_nw | grep -E "Subnet|Name|IPv4"
        "Name": "user_defined_nw",
                    "Subnet": "192.168.200.0/24"
                "Name": "test1",
                "IPv4Address": "192.168.200.2/24",
                "Name": "test2",
                "IPv4Address": "192.168.200.3/24",
                "Name": "test3",
                "IPv4Address": "192.168.200.4/24",

コマンドいろいろインストール


[oracle@centos7 docker]$ docker exec -it test1 /bin/bash
bash-4.2# yum install -y iputils
bash-4.2# yum -y install net-tools
bash-4.2# yum install -y iproute 
bash-4.2# yum install -y vim
bash-4.2# yum install -y traceroute

bash-4.2# ifconfig
eth0: flags=4163  mtu 1500
        inet 192.168.200.2  netmask 255.255.255.0  broadcast 192.168.200.255
        ether 02:42:c0:a8:c8:02  txqueuelen 0  (Ethernet)
        RX packets 29283  bytes 41677592 (39.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13729  bytes 919089 (897.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 43  bytes 5079 (4.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 43  bytes 5079 (4.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



bash-4.2# ip route
default via 192.168.200.1 dev eth0 
192.168.200.0/24 dev eth0 proto kernel scope link src 192.168.200.2 


bash-4.2# ping -c 3 test2
PING test2 (192.168.200.3) 56(84) bytes of data.
64 bytes from test2.user_defined_nw (192.168.200.3): icmp_seq=1 ttl=64 time=0.432 ms
64 bytes from test2.user_defined_nw (192.168.200.3): icmp_seq=2 ttl=64 time=0.199 ms
64 bytes from test2.user_defined_nw (192.168.200.3): icmp_seq=3 ttl=64 time=0.204 ms

--- test2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.199/0.278/0.432/0.109 ms
bash-4.2# ping -c 3 test3
PING test3 (192.168.200.4) 56(84) bytes of data.
64 bytes from test3.user_defined_nw (192.168.200.4): icmp_seq=1 ttl=64 time=0.394 ms
64 bytes from test3.user_defined_nw (192.168.200.4): icmp_seq=2 ttl=64 time=0.200 ms
64 bytes from test3.user_defined_nw (192.168.200.4): icmp_seq=3 ttl=64 time=0.189 ms

--- test3 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.189/0.261/0.394/0.094 ms


bash-4.2# iptables -t nat -L -n
iptables v1.4.21: can't initialize iptables table `nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
bash-4.2# pwd                
/etc/sysconfig
bash-4.2# ls
64bit_strstr_via_64bit_strstr_sse2_unaligned  cbq  ip6tables-config  iptables-config  network  rdisc
bash-4.2# vim /etc/sysconfig/iptables-config





変更前


# Unload modules on restart and stop
#   Value: yes|no,  default: yes
# This option has to be 'yes' to get to a sane state for a firewall
# restart or stop. Only set to 'no' if there are problems unloading netfilter
# modules.
IPTABLES_MODULES_UNLOAD="yes"

変更後


# Unload modules on restart and stop
#   Value: yes|no,  default: yes
# This option has to be 'yes' to get to a sane state for a firewall
# restart or stop. Only set to 'no' if there are problems unloading netfilter
# modules.
IPTABLES_MODULES_UNLOAD="no"

bash-4.2# traceroute google.com
traceroute to google.com (172.217.26.110), 30 hops max, 60 byte packets
 1  gateway (192.168.200.1)  0.167 ms  0.085 ms  0.078 ms
 2  192.168.100.1 (192.168.100.1)  3.085 ms  5.109 ms  5.011 ms
 3  * * *
 4  * * *
 5  172.23.38.114 (172.23.38.114)  78.580 ms  78.440 ms  78.241 ms
 6  172.25.114.126 (172.25.114.126)  78.088 ms  33.786 ms  43.899 ms
 7  obpBBAC05.bb.kddi.ne.jp (27.93.199.137)  43.729 ms  56.664 ms  68.491 ms
 8  27.80.241.77 (27.80.241.77)  69.502 ms 27.85.133.125 (27.85.133.125)  69.375 ms 27.85.133.109 (27.85.133.109)  69.165 ms
 9  27.86.41.102 (27.86.41.102)  67.615 ms  67.501 ms  67.182 ms
10  72.14.202.237 (72.14.202.237)  67.110 ms  66.876 ms  59.708 ms
11  * * *
12  kix05s01-in-f110.1e100.net (172.217.26.110)  57.243 ms 108.170.235.44 (108.170.235.44)  59.557 ms 108.170.235.42 (108.170.235.42)  56.599 ms
bash-4.2# 

escape sequence play


#!/bin/bash


## color code const
readonly C_GREEN=32;
readonly C_YELLOW=33;
readonly C_BLUE=34;
readonly C_MAGENTA=35;
readonly C_CYAN=36;
readonly C_L_RED=91;
readonly C_L_GREEN=92;
readonly C_L_YELLOW=93;
readonly C_L_BLUE=94;
readonly C_L_MAGENTA=95;
readonly C_L_CYAN=96;

pre_color=$PS1

function f_c()
{
printf "\033[${1}m${2}\033[${1}m\n";
}

echo 'please input'
echo '1:GREEN 2:YELLOW 3:BLUE 4:MAGENTA 5:CYAN 6:L_RED 7:L_GREEN 8:L_YELLOW 9:L_BLUE 10:L_MAGENTA 11:L_CYAN'

read num

case "$num" in
1)
color=${C_GREEN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
2)
color=${C_YELLOW}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
3)
color=${C_BLUE}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
4)
color=${C_MAGENTA}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
5)
color=${C_CYAN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
6)
color=${C_L_RED}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
7)
color=${C_L_GREEN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
8)
color=${C_L_YELLOW}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
9)
color=${C_L_BLUE}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
10)
color=${C_L_MAGENTA}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
11)
color=${C_L_CYAN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
*)
;;
esac

f_c ${pre_color} ""
[oracle@centos7 lesson]$

ssh centos7 enable


[oracle@centos7 ~]$ pwd
/home/oracle
[oracle@centos7 ~]$ ll
合計 4
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 17:12 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 15:31 doclan
-rwxr-xr-x. 1 oracle docker 1299 12月 23 15:31 mkdir.sh
drwxr-xr-x. 2 oracle docker   24 12月 23 17:12 share
[oracle@centos7 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa): 
Created directory '/home/oracle/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:uZjgdcQyJLlUXxdr1Z/bqnLmKQVWDwRF9LclCEUNDKo oracle@centos7
The key's randomart image is:
+---[RSA 2048]----+
|    .oo   =@@+.. |
|    oo o o o+=. .|
|   . .o =  .+oo =|
|    .  = .o.  .++|
|    . E S. .   .o|
|   . o + .  .  ..|
|    . o .  .   . |
|          o o..  |
|           *+.   |
+----[SHA256]-----+
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ ll -a
合計 40
drwx------. 21 oracle docker 4096 12月 27 20:43 .
drwxr-xr-x.  3 root   root     20 12月 23 14:28 ..
-rw-------.  1 oracle docker 1864 12月 23 15:45 .ICEauthority
-rw-------.  1 oracle docker 3392 12月 27 20:39 .bash_history
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
drwx------. 17 oracle docker 4096 12月 23 14:55 .cache
drwxr-xr-x. 19 oracle docker 4096 12月 24 00:02 .config
drwx------.  3 oracle docker   25 12月 23 14:41 .dbus
-rw-------.  1 oracle docker   16 12月 23 14:41 .esd_auth
drwx------.  3 oracle docker   18 12月 23 14:55 .gnome
drwx------.  3 oracle docker   19 12月 23 14:41 .local
drwxr-xr-x.  5 oracle docker   54 12月 23 14:48 .mozilla
drwx------.  3 oracle docker   19 12月 23 14:55 .pki
drwx------.  2 oracle docker   38 12月 27 20:43 .ssh
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Downloads
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Videos
drwxr-xr-x.  3 oracle docker   66 12月 23 17:12 docker
drwxrwxrwx.  4 oracle docker   32 12月 23 15:31 doclan
-rwxr-xr-x.  1 oracle docker 1299 12月 23 15:31 mkdir.sh
drwxr-xr-x.  2 oracle docker   24 12月 23 17:12 share
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd .ssh
[oracle@centos7 .ssh]$ pwd
/home/oracle/.ssh
[oracle@centos7 .ssh]$ ll
合計 8
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
[oracle@centos7 .ssh]$ 

サーバー側


[oracle@centos7 ~]$ ip route
default via 192.168.100.1 dev wlp7s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp7s0 proto kernel scope link src 192.168.100.107 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
[oracle@centos7 ~]$ ll
合計 4
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 15:21 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x. 1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x. 2 oracle docker   42 12月 23 16:40 share
[oracle@centos7 ~]$ 

クライアント側


[oracle@centos7 .ssh]$ scp id_rsa.pub oracle@192.168.100.107:~
The authenticity of host '192.168.100.107 (192.168.100.107)' can't be established.
ECDSA key fingerprint is SHA256:lAUjRXceZduuHmiWxudjvCaspDoZb+klg+K1g40p/sI.
ECDSA key fingerprint is MD5:1d:f6:2b:f5:7e:8e:2d:b1:17:1d:b6:1b:b5:5d:c1:5f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.107' (ECDSA) to the list of known hosts.
oracle@192.168.100.107's password: 
id_rsa.pub                                                                                                    100%  396    43.1KB/s   00:00    
[oracle@centos7 .ssh]$ 

サーバー側


[oracle@centos7 ~]$ ll
合計 8
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 15:21 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 14:47 doclan
-rw-r--r--. 1 oracle docker  396 12月 28 20:07 id_rsa.pub
-rwxr-xr-x. 1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x. 2 oracle docker   42 12月 23 16:40 share
[oracle@centos7 ~]$ 


[oracle@centos7 .ssh]$ ip route
default via 192.168.100.1 dev wlp2s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp2s0 proto kernel scope link src 192.168.100.108 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
--ホスト名一緒やとぜんぜんわかね
[oracle@centos7 .ssh]$ ssh oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:22:43 2018 from 192.168.100.108
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd ~ && cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRelZ3eydODQTdFCzCZGd5DlH0SBUkWxkTodK30b1pk37D9WDsxDFF1iOTcFVZFsYlQzMUpn1R1fM2Dhjcu7WrBmwhxsfB09bpl+HK/ZlQNZgfysEnR1mOfilai30LioV84+VFKNdiQUP+4iG6pzXMNJaqyWytLFr9gYqWRgp0znakGB187XdOEhTkNWXcP4gQsHbrB02SSTPTn8Ern+bYAdzHfNEMm8yezJFOycF0vkWQbkYqg+uf5Ry/Cy3GB7Sf6H7q78vVR+6ambU0HDhYPY3dzQ02WQeab5clMy4A5zX8fDVqfV/mncNT1GxG1e8XInl4kHxqjWStm24S8sDr oracle@centos7
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ mkdir ~/.ssh
[oracle@centos7 ~]$ ll -at
合計 48
drwx------. 21 oracle docker 4096 12月 28 20:31 .
drwxr-xr-x.  2 oracle docker    6 12月 28 20:31 .ssh
-rw-------.  1 oracle docker 4925 12月 28 20:23 .bash_history
-rw-r--r--.  1 oracle docker  396 12月 28 20:07 id_rsa.pub
drwxr-xr-x. 19 oracle docker 4096 12月 23 21:56 .config
drwxr-xr-x.  2 oracle docker   42 12月 23 16:40 share
drwxr-xr-x.  3 oracle docker   66 12月 23 15:21 docker
-rw-------.  1 oracle docker 1554 12月 23 15:16 .ICEauthority
drwxrwxrwx.  4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x.  1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Downloads
drwx------.  3 oracle docker   18 12月 23 10:53 .gnome
drwx------.  3 oracle docker   19 12月 23 10:53 .pki
drwx------. 17 oracle docker 4096 12月 23 10:53 .cache
drwxr-xr-x.  5 oracle docker   54 12月 23 10:45 .mozilla
-rw-------.  1 oracle docker   16 12月 23 10:44 .esd_auth
drwx------.  3 oracle docker   19 12月 23 10:44 .local
drwx------.  3 oracle docker   25 12月 23 10:44 .dbus
drwxr-xr-x.  3 root   root     20 12月 23 10:39 ..
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
[oracle@centos7 ~]$ chmod 700 .ssh
[oracle@centos7 ~]$ ll -at
合計 48
drwx------. 21 oracle docker 4096 12月 28 20:31 .
drwx------.  2 oracle docker    6 12月 28 20:31 .ssh
-rw-------.  1 oracle docker 4925 12月 28 20:23 .bash_history
-rw-r--r--.  1 oracle docker  396 12月 28 20:07 id_rsa.pub
drwxr-xr-x. 19 oracle docker 4096 12月 23 21:56 .config
drwxr-xr-x.  2 oracle docker   42 12月 23 16:40 share
drwxr-xr-x.  3 oracle docker   66 12月 23 15:21 docker
-rw-------.  1 oracle docker 1554 12月 23 15:16 .ICEauthority
drwxrwxrwx.  4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x.  1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Downloads
drwx------.  3 oracle docker   18 12月 23 10:53 .gnome
drwx------.  3 oracle docker   19 12月 23 10:53 .pki
drwx------. 17 oracle docker 4096 12月 23 10:53 .cache
drwxr-xr-x.  5 oracle docker   54 12月 23 10:45 .mozilla
-rw-------.  1 oracle docker   16 12月 23 10:44 .esd_auth
drwx------.  3 oracle docker   19 12月 23 10:44 .local
drwx------.  3 oracle docker   25 12月 23 10:44 .dbus
drwxr-xr-x.  3 root   root     20 12月 23 10:39 ..
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd .ssh
[oracle@centos7 .ssh]$ ll
合計 0
[oracle@centos7 .ssh]$ touch ~/.ssh/authorized_keys
[oracle@centos7 .ssh]$ ll
合計 0
-rw-r--r--. 1 oracle docker 0 12月 28 20:35 authorized_keys
[oracle@centos7 .ssh]$ chmod 600 ~/.ssh/authorized_keys
[oracle@centos7 .ssh]$ ll
合計 0
-rw-------. 1 oracle docker 0 12月 28 20:35 authorized_keys
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ログアウト
Connection to 192.168.100.107 closed.
[oracle@centos7 .ssh]$ ip route
default via 192.168.100.1 dev wlp2s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp2s0 proto kernel scope link src 192.168.100.108 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ll
合計 12
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
-rw-r--r--. 1 oracle docker  177 12月 28 20:07 known_hosts
[oracle@centos7 .ssh]$ cat known_hosts
192.168.100.107 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCVDRp3jReHwU4wAxBVo4Aat+UHtKLl4VVpKA3x8k+nTygk4odsn01Zrj8PDzSGd1zGT1DTXFZqYF2C+kYzkd3s=
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ssh oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:23:22 2018 from 192.168.100.108
[oracle@centos7 ~]$ ifconfig
docker0: flags=4163  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:e6ff:fe51:a6d6  prefixlen 64  scopeid 0x20 	 	 	 	
        ether 02:42:e6:51:a6:d6  txqueuelen 0  (Ethernet)
        RX packets 72756  bytes 34705340 (33.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 133133  bytes 158851749 (151.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp25s0: flags=4099  mtu 1500
        ether fc:61:98:4f:19:5f  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8138  bytes 614263 (599.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8138  bytes 614263 (599.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth24ff817: flags=4163  mtu 1500
        inet6 fe80::707d:b1ff:fe06:274b  prefixlen 64  scopeid 0x20 	 	 	 	
        ether 72:7d:b1:06:27:4b  txqueuelen 0  (Ethernet)
        RX packets 24877  bytes 18606254 (17.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 39457  bytes 38601382 (36.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:78:5b:56  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp7s0: flags=4163  mtu 1500
        inet 192.168.100.107  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 2001:268:c031:29e9:98e7:f562:4ec4:3  prefixlen 128  scopeid 0x0
        inet6 fe80::4bff:9d03:eef7:9a10  prefixlen 64  scopeid 0x20 	 	 	 	
        inet6 2001:268:c031:29e9:1a2b:1bda:f699:4627  prefixlen 64  scopeid 0x0
        ether 74:e5:0b:ba:d1:ac  txqueuelen 1000  (Ethernet)
        RX packets 917681  bytes 975680107 (930.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 599486  bytes 167522088 (159.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[oracle@centos7 ~]$ 


[oracle@centos7 .ssh]$ ll
合計 12
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
-rw-r--r--. 1 oracle docker  177 12月 28 20:07 known_hosts
[oracle@centos7 .ssh]$ ssh -i id_rsa.pub oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:38:26 2018 from 192.168.100.108
[oracle@centos7 ~]$ ログアウト
Connection to 192.168.100.107 closed.

sudo user add docker oracle


[oracle@centos7 ~]$ docker exec -it orcl_12cr2 /bin/bash
[oracle@609a69bc0b21 ~]$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
[oracle@609a69bc0b21 ~]$ 

[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# visudo
bash-4.2# exit

#--これはいけない
## Allows people in group wheel to run all commands
#%wheel ALL=(ALL)       ALL
oinstall ALL=(ALL)      ALL
#--これはいけるはず
## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
oracle          ALL=(ALL)       ALL

[oracle@centos7 ~]$ docker exec -it orcl_12cr2 /bin/bash
[oracle@609a69bc0b21 ~]$ whoami
oracle
[oracle@609a69bc0b21 ~]$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
[oracle@609a69bc0b21 ~]$ sudo echo "hey"
[sudo] password for oracle: 
hey
[oracle@609a69bc0b21 ~]$ 

docker oracle passwd install


[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# whereis passwd
passwd: /etc/passwd
bash-4.2# passwd
bash: passwd: command not found
bash-4.2# yum install -y passwd
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package passwd.x86_64 0:0.79-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                          Arch                             Version                                 Repository                            Size
======================================================================================================================================================
Installing:
 passwd                           x86_64                           0.79-4.el7                              ol7_latest                           104 k

Transaction Summary
======================================================================================================================================================
Install  1 Package

Total download size: 104 k
Installed size: 420 k
Downloading packages:
passwd-0.79-4.el7.x86_64.rpm                                                                                                   | 104 kB  00:00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : passwd-0.79-4.el7.x86_64                                                                                                           1/1 
  Verifying  : passwd-0.79-4.el7.x86_64                                                                                                           1/1 

Installed:
  passwd.x86_64 0:0.79-4.el7                                                                                                                          

Complete!
bash-4.2# whereis passwd
passwd: /usr/bin/passwd /etc/passwd
bash-4.2# 

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>