always freeにdockerをいれてみる

Oracle Cloud always free Advent Calendar 2019の4日です。

 

今回は特に地味で申し訳ないのですが、Docker/Docker Composeのインストール方法を毎回ググって確認しているので、記載することにします。対象はOracle 7.7です。(CentOSでも同じだと思います)

 

#Dockerのインストール/サービス有効化/起動/ユーザへの権限付与

sudo yum -y install docker-engine
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER

#SELINUX無効化(石川さんごめんなさい)
sudo sed -i "s/\(^SELINUX=\).*/\1disabled/" /etc/selinux/config

#再起動
sudo reboot

 


#動作確認

docker run --rm ubuntu:14.04 /bin/echo 'Hello world'

#Hello worldと表示されればOK

 

#Docker Composeのインストール
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose


ざっとですが以上です。

<参考文献>
https://qiita.com/ymasaoka/items/4e6deca0ad2b4cae87b8

always freeでunixbenchをとってみる

Oracle Cloud always free 2019 Advent Calendar 2019の3日目です。
1日目では各種コマンドから分かる内容を記載しましたが、本日はCPUベンチマークをとってみようと思います。
ベンチマークツールにunixbenchを使います。

 

#必要なモジュールのインストール
sudo yum install make gcc perl perl-Time-HiRes git

 

#unixbenchのインストール
git clone https://github.com/kdlucas/byte-unixbench.git

 

unixbenchの実行
cd byte-unixbench/UnixBench/
$ ./Run

make[2]: Nothing to be done for `programs'.
make[2]: Leaving directory `/home/opc/byte-unixbench/UnixBench'
make[1]: Leaving directory `/home/opc/byte-unixbench/UnixBench'
sh: 3dinfo: command not found

# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #

Version 5.1.3 Based on the Byte Magazine Unix Benchmark

Multi-CPU version Version 5 revisions by Ian Smith,
Sunnyvale, CA, USA
January 13, 2011 johantheghost at yahoo period com

------------------------------------------------------------------------------
Use directories for:
* File I/O tests (named fs***) = /home/opc/byte-unixbench/UnixBench/tmp
* Results = /home/opc/byte-unixbench/UnixBench/results
------------------------------------------------------------------------------

1 x Dhrystone 2 using register variables 1 2 3 4 5 6 7 8 9 10

1 x Double-Precision Whetstone 1 2 3 4 5 6 7 8 9 10

1 x Execl Throughput 1 2 3

1 x File Copy 1024 bufsize 2000 maxblocks 1 2 3

1 x File Copy 256 bufsize 500 maxblocks 1 2 3

1 x File Copy 4096 bufsize 8000 maxblocks 1
2 3

1 x Pipe Throughput 1 2 3 4 5 6 7 8 9 10

1 x Pipe-based Context Switching 1 2 3 4 5 6 7 8 9 10

1 x Process Creation 1 2 3

1 x System Call Overhead 1 2 3 4 5 6 7 8 9 10

1 x Shell Scripts (1 concurrent) 1 2 3

1 x Shell Scripts (8 concurrent) 1 2 3

2 x Dhrystone 2 using register variables 1 2 3 4 5 6 7 8 9 10

2 x Double-Precision Whetstone 1 2 3 4 5 6 7 8 9 10

2 x Execl Throughput 1 2 3

2 x File Copy 1024 bufsize 2000 maxblocks 1 2 3

2 x File Copy 256 bufsize 500 maxblocks 1 2 3

2 x File Copy 4096 bufsize 8000 maxblocks 1 2

Hyper-Threading, x86-64, MMX, AMD MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
02:32:14 up 18:07, 2 users, load average: 0.17, 0.20, 0.15; runlevel 2019-11-14

------------------------------------------------------------------------
Benchmark Run: Fri Nov 15 2019 02:32:14 - 03:00:12
2 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables 12136071.4 lps (10.0 s, 7 samples)
Double-Precision Whetstone 1806.8 MWIPS (9.8 s, 7 samples)
Execl Throughput 1349.5 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 291074.3 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 81481.6 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 827083.9 KBps (30.0 s, 2 samples)
Pipe Throughput 471659.7 lps (10.0 s, 7 samples)
Pipe-based Context Switching 22063.5 lps (10.0 s, 7 samples)
Process Creation 2229.4 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 2043.0 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 315.3 lpm (60.0 s, 2 samples)
System Call Overhead 666622.7 lps (10.0 s, 7 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 12136071.4 1039.9
Double-Precision Whetstone 55.0 1806.8 328.5
Execl Throughput 43.0 1349.5 313.8
File Copy 1024 bufsize 2000 maxblocks 3960.0 291074.3 735.0
File Copy 256 bufsize 500 maxblocks 1655.0 81481.6 492.3
File Copy 4096 bufsize 8000 maxblocks 5800.0 827083.9 1426.0
Pipe Throughput 12440.0 471659.7 379.1
Pipe-based Context Switching 4000.0 22063.5 55.2
Process Creation 126.0 2229.4 176.9
Shell Scripts (1 concurrent) 42.4 2043.0 481.8
Shell Scripts (8 concurrent) 6.0 315.3 525.5
Hyper-Threading, x86-64, MMX, AMD MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
02:32:14 up 18:07, 2 users, load average: 0.17, 0.20, 0.15; runlevel 2019-11-14

------------------------------------------------------------------------
Benchmark Run: Fri Nov 15 2019 02:32:14 - 03:00:12
2 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables 12136071.4 lps (10.0 s, 7 samples)
Double-Precision Whetstone 1806.8 MWIPS (9.8 s, 7 samples)
Execl Throughput 1349.5 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 291074.3 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 81481.6 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 827083.9 KBps (30.0 s, 2 samples)
Pipe Throughput 471659.7 lps (10.0 s, 7 samples)
Pipe-based Context Switching 22063.5 lps (10.0 s, 7 samples)
Process Creation 2229.4 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 2043.0 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 315.3 lpm (60.0 s, 2 samples)
System Call Overhead 666622.7 lps (10.0 s, 7 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 12136071.4 1039.9
Double-Precision Whetstone 55.0 1806.8 328.5
Execl Throughput 43.0 1349.5 313.8
File Copy 1024 bufsize 2000 maxblocks 3960.0 291074.3 735.0
File Copy 256 bufsize 500 maxblocks 1655.0 81481.6 492.3
File Copy 4096 bufsize 8000 maxblocks 5800.0 827083.9 1426.0
Pipe Throughput 12440.0 471659.7 379.1
Pipe-based Context Switching 4000.0 22063.5 55.2
Process Creation 126.0 2229.4 176.9
Shell Scripts (1 concurrent) 42.4 2043.0 481.8
Shell Scripts (8 concurrent) 6.0 315.3 525.5
System Call Overhead 15000.0 666622.7 444.4
========
System Benchmarks Index Score 410.7

------------------------------------------------------------------------
Benchmark Run: Fri Nov 15 2019 03:00:12 - 03:28:20
2 CPUs in system; running 2 parallel copies of tests

Dhrystone 2 using register variables 14044499.3 lps (10.0 s, 7 samples)
Double-Precision Whetstone 2050.7 MWIPS (9.9 s, 7 samples)
Execl Throughput 1827.5 lps (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 318033.4 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 87118.8 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 919732.0 KBps (30.0 s, 2 samples)
Pipe Throughput 534172.6 lps (10.0 s, 7 samples)
Pipe-based Context Switching 93540.3 lps (10.0 s, 7 samples)
Process Creation 3884.0 lps (30.1 s, 2 samples)
Shell Scripts (1 concurrent) 1971.0 lpm (60.1 s, 2 samples)
Shell Scripts (8 concurrent) 347.6 lpm (60.2 s, 2 samples)
System Call Overhead 751110.5 lps (10.0 s, 7 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 14044499.3 1203.5
Double-Precision Whetstone 55.0 2050.7 372.8
Execl Throughput 43.0 1827.5 425.0
File Copy 1024 bufsize 2000 maxblocks 3960.0 318033.4 803.1
File Copy 256 bufsize 500 maxblocks 1655.0 87118.8 526.4
File Copy 4096 bufsize 8000 maxblocks 5800.0 919732.0 1585.7
Pipe Throughput 12440.0 534172.6 429.4
Pipe-based Context Switching 4000.0 93540.3 233.9
Process Creation 126.0 3884.0 308.3
Shell Scripts (1 concurrent) 42.4 1971.0 464.8
Shell Scripts (8 concurrent) 6.0 347.6 579.3
System Call Overhead 15000.0 751110.5 500.7
========
System Benchmarks Index Score 533.7

 

スコアは533.7です。
AWSのt3.microよりもスコアが低く、GCPのf1-microよりもスコアが高いようです。

<参考>
unixbenchの使い方
https://kanpapa.com/today/2018/09/nano-pi-neo-nas-unixbench.html
https://qiita.com/CloudRemix/items/f82e22b3727a88520cc3
t3.microのunixbench
https://gb-j.com/column/amazonec2-t3instance/
f1-microのunixbench
https://www.m0de.ml/c0d3man/posts/l8vt274k36520n9woxsl/

Computeインスタンスのsshポート変更(2日目)

Oracle Cloud always free Advent Calendar 2019の二日目です。

always freeのcomputeインスタンスですが、基本起動しっぱなしです。
SSH接続は秘密鍵での認証されていますが、それだけでは心元ないので、SSH接続のポートを変えることにします。


以前ポート22のままサーバを運用していた時に猛烈にアタックを受けたことがあり、軽くトラウマになっています。

 

今回はssh の待ち受けポートを22から54222に変更するために必要なセキュリティ設定を行い、その後、ssh待ち受けポートを変更します。

失敗するとコンソール接続しか出来なくなるので注意してください。

 

Firewalledの設定変更

#firewalldの受信ポート(54222)追加
sudo cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/ssh-54222.xml
sudo vi /etc/firewalld/services/ssh-54222.xml

#<port protocol="tcp" port="22"/>
<port protocol="tcp" port="54222"/>

sudo firewall-cmd --permanent --add-service=ssh-54222
#設定のリロード
sudo firewall-cmd --reload

#変更の状態確認
sudo firewall-cmd --list-all

#servicesにssh-54222があればOK

#sshdのポート番号変更
sudo vi /etc/ssh/sshd_config
# Port 22
Port 54222

#sshdのリロード
sudo systemctl restart sshd

 

 

#セキュリティリストの追加
oracle cloudコンソールから
ネットワーキング-仮想クラウド・ネットワーク-VirtualCloudNetwork-XXXXXXXを選択
パブリック・パブリックサブネットをクリック
Default Security List for VirtualCloudNetwork-XXXXXXXXXをクリック

 

#イングレス・ルールに以下を追加
ソース 0.0.0.0/0
IPプロトコル TCP
宛先ポート範囲 54222

 

#変更したポートで接続できることを確認
#別のコンソールから接続する。

 

ssh -i <接続用のキー> -P 54222 opc@<インスタンスのIP>

 

#firewalldの設定からポート22を削除
sudo firewall-cmd --permanent --remove-service=ssh

#設定のリロード
sudo firewall-cmd --reload

#変更の状態確認
sudo firewall-cmd --list-all

#servicesにsshがなければOK

 

ポートを変えるだけでアタックの頻度はかなり下がります。

 

<参考文献>
https://qiita.com/fk_2000/items/019b62818e34be973227

Computeインスタンス環境調べてみる(1日目)

Oracle Cloud always free 2019 Advent Calendar 2019の1日目です。

本日は軽く、always free computeインスタンスの基本情報をあさっていきたいと思います。

インスタンスOracle Linux 7.7をデフォルトの状態で起動しています。

 

カーネル情報

uname -r
4.14.35-1902.6.6.el7uek.x86_64

UEKが起動していますね。defaultのOracle Linux 7.7のUEKともちょっと違う気がします。(未確認)

 

CPU情報
[opc@docker ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 23
model : 1
model name : AMD EPYC 7551 32-Core Processor
stepping : 2
microcode : 0x1000065
cpu MHz : 1996.243
cache size : 512 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gbrdtscp lm rep_good nopl xtopology cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core ssbd ibpb vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 virt_ssbd arat
bugs : fxsave_leak sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass
bogomips : 3992.48
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : AuthenticAMD
cpu family : 23
model : 1
model name : AMD EPYC 7551 32-Core Processor
stepping : 2
microcode : 0x1000065
cpu MHz : 1996.243
cache size : 512 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gbrdtscp lm rep_good nopl xtopology cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core ssbd ibpb vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 virt_ssbd arat
bugs : fxsave_leak sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass
bogomips : 3992.48
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:

 

AMD EPYC を使っており、2CPU割り振られています。残念?ながら再仮想化(svm)はできないようです。


メモリ情報

[opc@docker ~]$ free
total used free shared buff/cache available
Mem: 994512 366304 96568 6760 531640 431208
Swap: 8388604 2572 8386032

物理メモリ1GB弱,スワップで8GBほどあるようです。

 

ディスク/マウント状況

[opc@docker ~]$ df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 469088 0 469088 0% /dev
tmpfs 497256 0 497256 0% /dev/shm
tmpfs 497256 6788 490468 2% /run
tmpfs 497256 0 497256 0% /sys/fs/cgroup
/dev/sda3 40223552 9288936 30934616 24% /
/dev/sda1 204580 9864 194716 5% /boot/efi
tmpfs 99452 0 99452 0% /run/user/1000

#
# /etc/fstab
# Created by anaconda on Wed Oct 16 22:10:30 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=73d43745-261c-49e4-94b0-054d3e145417 / xfs defaults,_netdev,_netdev 0 0
UUID=5564-9A64 /boot/efi vfat defaults,uid=0,gid=0,umask=0077,shortname=winnt,_netdev,_netdev,x-initrd.mount 0 0
UUID=0a17f302-6a4b-4f6e-b792-13ca8b4c9418 swap swap defaults,_netdev,x-initrd.mount 0 0

SCSI情報
cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 01
Vendor: ORACLE Model: BlockVolume Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 06

 


ディスクは一本だけ接続されていますね。VENDARはOracleです。

 

ISCSI接続情報

[opc@ol77 ~]$ sudo iscsiadm -m session show
iscsiadm: No active sessions.

Oracle Cloudでは、ISCSI接続でDISK見せてた気がしましたが、rootデバイスISCSI接続ではないようです。

 

IP情報

[opc@ol77 ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:00:17:00:58:2a brd ff:ff:ff:ff:ff:ff
inet 10.0.0.5/24 brd 10.0.0.255 scope global dynamic ens3
valid_lft 80406sec preferred_lft 80406sec


NICが一つ(ens3)にローカルIPが降られています。 いきなりMTU 9000(ジャンボフレーム有効化)は珍しい気がします。

 

ルーティング情報

[opc@ol77 ~]$ ip route
default via 10.0.0.1 dev ens3
10.0.0.0/24 dev ens3 proto kernel scope link src 10.0.0.5
169.254.0.0/16 dev ens3 proto static scope link
169.254.0.0/16 dev ens3 scope link metric 1002

 

他のクラウド環境と同じように169.254.XXX.XXXへのネットワークを内部管理用に使用しているようです。

 

名前解決

[opc@ol77 ~]$ cat /etc/resolv.conf
; Any changes made to this file will be overwritten whenever the
; DHCP lease is renewed. To persist changes you must update the
; /etc/oci-hostname.conf file. For more information see
;https://docs.cloud.oracle.com/iaas/Content/Network/Tasks/managingDHCP.htm#notes
;
; generated by /usr/sbin/dhclient-script
search vcn.oraclevcn.com subnet.vcn.oraclevcn.com
nameserver 169.254.169.254

DNSは内部ネットワークから引っ張ってきていますね。

 

本日はこれくらいで。

Oracle Database 18c XE をDockerで動かしてみる。

このエントリは Oracle Database or GoldenGate Advent Calendar 2018 の Day 16 の記事となります。

 

みなさん、Oracle Database 18c XEを使ってますか?
私はまだ触っていないので、この機会に触ってみようと思います。

ただ、インストールするだけではつまらないので、Docker上で試してみようと思います。


Dockerで使用するには、以下の手順が必要です。

1.OTNからOracle Database 18c XEのrpmをダウンロード
2.githubからDockerイメージビルド用のスクリプトをダウンロード
3.イメージビルド用のスクリプトを実行
4.作成したイメージからコンテナ起動

 

以下手順となります。

#イメージビルド用のスクリプトをダウンロード

git clone https://github.com/oracle/docker-images

###OTNからoracle-database-xe-18c-1.0-1.x86_64.rpm をダウンロード後,docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0にコピーする

#ビルド用ディレクトリに移動
cd docker-images/OracleDatabase/SingleInstance/dockerfiles

#ビルド用スクリプトの実行

 ./buildDockerImage.sh -v 18.4.0 -x
Checking if required packages are present and valid...
oracle-database-xe-18c-1.0-1.x86_64.rpm: OK
==========================
DOCKER info:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.09.0
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-1021-azure
Operating System: Ubuntu 16.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.67GiB
Name: ubuntu
ID: UMRP:RMHM:6DWI:WKXZ:SP7X:OTU2:2RPM:HEPS:ZUBX:UHOC:XTM5:EWGE
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support
==========================
Building image 'oracle/database:18.4.0-xe' ...
Sending build context to Docker daemon 2.574GB
Step 1/11 : FROM oraclelinux:7-slim
7-slim: Pulling from library/oraclelinux
f25d82609194: Pull complete
Digest: sha256:2ed2820810409491b0d8fced14b5f6b3fd8206eb8fbf5f9138d825c5a98db020
Status: Downloaded newer image for oraclelinux:7-slim
---> b19454a5f17a
Step 2/11 : MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
---> Running in 37ba5ba2c6bb
Removing intermediate container 37ba5ba2c6bb
---> 0748a837c0e0
Step 3/11 : ENV ORACLE_BASE=/opt/oracle ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE ORACLE_SID=XE INSTALL_FILE_1="oracle-d
atabase-xe-18c-1.0-1.x86_64.rpm" RUN_FILE="runOracle.sh" PWD_FILE="setPassword.sh" CONF_FILE="oracle-xe-18c.conf" CHECK
_DB_FILE="checkDBStatus.sh" INSTALL_DIR="$HOME/install" ORACLE_DOCKER_INSTALL="true"
---> Running in 4cdf61b6978f
Removing intermediate container 4cdf61b6978f
---> 96cf7c299f79
Step 4/11 : ENV PATH=$ORACLE_HOME/bin:$PATH
---> Running in 9b8829c378bf
Removing intermediate container 9b8829c378bf
---> 024269c36e3a
Step 5/11 : COPY $INSTALL_FILE_1 $RUN_FILE $PWD_FILE $CHECK_DB_FILE $INSTALL_DIR/
---> 55182b72d69b
Step 6/11 : COPY $CONF_FILE $INSTALL_DIR/
---> eb5cfe6434a6
Step 7/11 : RUN cd $INSTALL_DIR && yum -y install oracle-database-preinstall-18c file openssl $INSTALL_FILE_1 && rm -rf /var/ca
che/yum && mkdir -p $ORACLE_BASE/scripts/setup && mkdir $ORACLE_BASE/scripts/startup && ln -s $ORACLE_BASE/scripts /docker-
entrypoint-initdb.d && mkdir -p $ORACLE_BASE/oradata /home/oracle && chown -R oracle:oinstall $ORACLE_BASE/oradata /home/oracle
&& mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ && mv $INSTALL_DIR/$CHECK_DB_FILE $O
RACLE_BASE/ && mv $INSTALL_DIR/$CONF_FILE /etc/sysconfig/ && ln -s $ORACLE_BASE/$PWD_FILE / && cd $HOME && rm -rf $INST
ALL_DIR && target_txt=$(cat /etc/security/limits.d/oracle-database-preinstall-18c.conf | grep -e 'oracle *hard *memlock*') && s
ed -i "/^$target_txt/ c#$target_txt" /etc/security/limits.d/oracle-database-preinstall-18c.conf && chmod ug+x $ORACLE_BASE/*.sh
---> Running in 7a576c1cc0ae
Loaded plugins: ovl
Examining oracle-database-xe-18c-1.0-1.x86_64.rpm: oracle-database-xe-18c-1.0-1.x86_64
Marking oracle-database-xe-18c-1.0-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package file.x86_64 0:5.11-35.el7 will be installed
---> Package openssl.x86_64 1:1.0.2k-16.0.1.el7 will be installed
~~~~~~~~
xorg-x11-utils.x86_64 0:7.5-23.el7
xorg-x11-xauth.x86_64 1:1.0.9-1.el7
xz.x86_64 0:5.2.2-1.el7

Complete!

Removing intermediate container 7a576c1cc0ae
---> cd3099f0db97
Step 8/11 : VOLUME ["$ORACLE_BASE/oradata"]
---> Running in 8f34c92a369d
Removing intermediate container 8f34c92a369d
---> be8fc9066c53
Step 9/11 : EXPOSE 1521 8080 5500
---> Running in 2720d5113806
Removing intermediate container 2720d5113806
---> 0bf8facf860f
Step 10/11 : HEALTHCHECK --interval=1m --start-period=5m CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
---> Running in 8119ffac1a9a
Removing intermediate container 8119ffac1a9a
---> 1677191ded41
Step 11/11 : CMD exec $ORACLE_BASE/$RUN_FILE
---> Running in 58f63241b643
Removing intermediate container 58f63241b643
---> 99a04dbc81a6
[Warning] One or more build-args [DB_EDITION] were not consumed
Successfully built 99a04dbc81a6
Successfully tagged oracle/database:18.4.0-xe

Oracle Database Docker Image for 'xe' version 18.4.0 is ready to be extended:

--> oracle/database:18.4.0-xe

Build completed in 985 seconds.

#docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
oracle/database 18.4.0-xe 99a04dbc81a6 8 minutes ago 8.43GB
oraclelinux 7-slim b19454a5f17a 4 weeks ago 117MB


###### コンテナの起動 メモリの割り当ては1GB パスワードはoracle123 マウントポイントは /docker/oracle
docker run -d -v /dev/shm --tmpfs /dev/shm:rw,nosuid,nodev,exec,size=1g
--name xe-18c --hostname xe-18c 
-p 1521:1521 -p 8080:8080 -p 5500:5500  
-e ORACLE_PWD=oracle123 
-v /docker/oracle:/opt/oracle/oradata 
oracle/database:18.4.0-xe

#databaseの作成状況の確認
docker logs xe-18c

##以下のような出力があれば、databaseを使用可能

#########################
DATABASE IS READY TO USE!
#########################

#コンテナの操作はsshではなく、docker execで行う

docker exec -ti xe-18c /bin/bash

#DBへの接続

sqlplus sys/oracle123@//localhost:1521/XE as sysdba
sqlplus system/oracle123@//localhost:1521/XE
sqlplus pdbadmin/oracle123@//localhost:1521/XEPDB1

 

皆さん、良いクリスマスを!

Oracle RAC on Kubernetes

JPOUG Advent Calendar 2017の9日目のエントリーです。

今回は Oracle RAC on Kubernetesについて書きます。

 

情報はKubernetes 1.7ベースです

 

Oracle RAC on XXを作る際に共通して考慮する必要があるのが

 

です。

 

  • 共有ディスク

検証用途ではiscsinfsが使われていると思います。

Kubernetes(docker含む)では「コンテナ内」からiscsiを扱うことは難しいため、nfsを使います。

 

クラウド環境やコンテナ環境ではネットワークが一本しかない、固定IPを指定できない、マルチキャスト対応してない など様々な制約があります 。

これらの制約に対応する為、仮想ネットワーク(vxlan)を使います。vxlanはユニキャストモード使用します。

 

  • ホスト名

一般的なホスト名変更方法(/etc/hostname 変更)でうまくいかないことが多い(再起動すると環境側でホスト名がリセットされたり、/etc/hostnameが編集不可だったり)ので、ホスト名を変更するサービスを作成して対応しています。

 

  • 名前解決

 クラウド環境やコンテナ環境側のDNSに仮想ネットワーク(vxlan)に対応したDNSレコードを追加出来ないことが多いので

各ノードにローカルDNS(dnsmasq)を作成し、本来のDNSにforwardしています

 

Oracle RAC on Kubernetesでは上記に加え、

 

  • コンテナの配置
  • コンテナ間の名前解決
  • systemd
  • 特権モード
  • /dev/shm

 

で対応が必要です。

 

  • コンテナの配置

1ホストにつき、1DBコンテナ起動してほしいのですべてのコンテナでcontainerPortとhostPortを同一にして1ホストにつき、1コンテナ起動するようにしています。

 

  • コンテナ間の名前解決

 コンテナ(pod)間で名前解決するにはsubdomainを使用する必要があるようです。(自信ないのでくわしい人教えて下さい)

 

  • systemd

 公式Oracle Linuxのイメージはsystemdが含まれていませんので、systemdが含まれたイメージを自作する必要があります。

 

  • 特権モード

 systemdやvxlanを動作させるために特権モード

(securityContext:
privileged: true)

 でコンテナを起動します

 

  • /dev/shm

 デフォルトは64MBで、ASMインスタンスが起動出来ません。

そのため/dev/shmを1200mでマウントし直すsystemdサービスを作成して対応しています

 


f:id:KNOPP:20171208212018j:image


f:id:KNOPP:20171208212030j:image

手順は、今後以下URLで公開予定です

 https://github.com/s4ragent/rac_on_xx/tree/master/k8s

 

その他

 JPOUG in 15 minutes #6で使用した資料(Oracle RAC on Docker)はこちら

https://www.slideshare.net/ohshimamasaki/oracle-rac-on-docker

 

手順はこちら

https://github.com/s4ragent/rac_on_xx/tree/master/docker

 

Oracle Linux 7でyumコマンド実行時の注意点

本エントリとは直接関連しませんが、まずは宣伝から。

宣伝その1

JPOUGのイベントが11月17日にあります
http://www.jpoug.org/2017/09https://jpoug.doorkeeper.jp/events/65435

テーマは「Docker」。Dockerized Sessionのみです。

 今回は私も、Oracle RAC on Dockerというタイトルで登壇致します。まだ席に余裕がありますので、興味がある方は是非。

 

宣伝その2

今年もAdvent Calendaerやります
https://jpoug.doorkeeper.jp/events/67051

 

一年の終わりにOracleというキーワードで記事を書いてみませんか?

 

ここで本題です。

Oracle Linux 7で環境構築するときにCentOS7の手順を参考にすると思いますが、たまにyum コマンドでそんなパッケージないよ とエラーがでるときがあります。

 

 そんなときは

--enablerepo=ol7_addons --enablerepo=ol7_optional_latest

をつけて実行します

 

自分もちょいちょい忘れて、ドハマリするのでメモ用でした