Oracle Cloud Infrastructureまとめ
OCI Object StorageをOracle Linuxにマウントしてみる
過去記事より
はじめに
Oracle Linuxは既に構築済みとします。それからObject Storageも構築済みとします。
Storage Gatewayについて
Object StorageをOracle LinuxにマウントするにはStorage Gatewayが必要です。
下記OCIドキュメントより抜粋
ストレージ・ゲートウェイは、オンプレミス・アプリケーションをOracle Cloud Infrastructureに接続できるクラウド・ストレージ・ゲートウェイです。データをNFSターゲットに書き込むことができるアプリケーションでは、REST APIを取り込むためにアプリケーションを変更しなくても、Oracle Cloud Infrastructure Object Storageにデータを書き込むことができます。
前提条件
2つのデュアルコアCPU以上。4コアCPUを推奨します。
メモリーの最小要件:
- ストレージ・ゲートウェイのどのファイル・システムでも16GBが必須。
- ファイル数が5000万個までのファイル・システムでは32GB。
- ファイル数が1億個までのファイル・システムでは64GB。
推奨されるローカル・ストレージのディスク・サイズは600GBです(ファイル・システム・キャッシュに500GB、メタデータ・ストレージに80GB、ログ・ストレージに20GBを含みます)。
モジュールの入手
■モジュール取得用のURL
作業順序
- Selinuxの無効化
- モジュールのインストール
- Storage Gatewayコンソールでの作業
- Oracle Linuxにマウント
実際に作業してみる
Selinuxの無効化
要再起動
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
モジュールのインストール
インスタンス上にモジュールを配置する
[root@oracle-linux ~]# ls
ocisg-1.4.tar.gz
[root@oracle-linux ~]#
ocisg-1.4.tar.gzの解凍
[root@oracle-linux ~]# tar -xvzf ocisg-1.4.tar.gz
ocisg-1.4/
ocisg-1.4/helper-install-ocisg.sh
ocisg-1.4/ocisg:1.4.tar
ocisg-1.4/ocisg-install.sh
ocisg-1.4/connect-fs.sh
ocisg-1.4/ocisg-control.sh
ocisg-1.4/health-check.sh
ocisg-1.4/support-bundle.sh
ocisg-1.4/test-bandwidth.sh
ocisg-1.4/ocisg-config.sh
ocisg-1.4/ocisg
ocisg-1.4/OCISG_README.txt
ocisg-install.shの実行
[root@oracle-linux-207830 ocisg-1.4]# ./ocisg-install.sh
dockerのインストールを確認
Docker does not appear to be installed. Do you want to install docker engine with yum? [y/N] y
NFSの有効化の確認
NFS server does not appear to be enabled. Do you want to enable NFS? [y/N] y
インストールパスの確認
デフォルトのままエンターを押します。
Enter the install location press enter for default (/opt/ocisg/) :
ファイル・システム・キャッシュのパス指定
Enter the path for OCISG file system cache : /mnt/ocisg/sg/cache
メタデータ領域のパス指定
Enter the path for OCISG metadata storage : /mnt/ocisg/sg/metadata
ログ領域のパス指定
Enter the path for OCISG log storage : /mnt/ocisg/sg/log
インストールOKの確認
Management Console: https://oracle-linux-207830:32770
If you have already configured an OCISG FileSystem via the Management Console,
you can access the NFS share using the following port.
NFS Port: 32771
Example: mount -t nfs -o vers=4,port=32771 oracle-linux-207830:/<OCISG FileSystem name> /local_mount_point
Storage Gatewayコンソールでの作業
コンソールへのアクセス
下記URLにアクセスします。
Management Console: https://oracle-linux-207830:32770
ブラウザで下記の画面が表示されればOKです。
※一番最初アクセスすると、パスワードの設定画面が表示されます。
ファイルシステムの作成
「Create File System」をクリックします。
下記イメージのとおりパラメータを入力していきます。
File System Name:オブジェクトストレージ名を入力します。
Object Storage API Endpoint:東京リージョン使っているなら「https://objectstorage.ap-tokyo-1.oraclecloud.com」でOK
Compartment OCID:自身のコンパートメントIDを入力します。
Tenant OCID:自身のテナントIDを入力します。
User OCID:自身のユーザIDを入力します。
Public Key's Finger Print:コンソールのユーザ画面で作成するAPIのフィンガープリント
Private Key:フィンガープリントを作成した時の秘密鍵の情報
Private Key Passphrase:設定なければ空白でOK
入力できましたら、画面下部「save」をクリックします。
オブジェクトストレージへテスト接続してみる
下記イメージのとおりにファイルシステムを設定できましたら
「Connect」をクリックします。
無事接続できると下記イメージのように緑のマークが付きます。
Oracle Linuxにマウント
マウントポイントの作成
[root@oracle-linux ~]# mkdir /mnt/test
マウントコマンドの実行
[root@oracle-linux ~]# mount -t nfs -o vers=4,port=32771 10.0.5.173:/test /mnt/test/
portはocisg-1.4モジュールをインストールしたログに記載があります。
マウント出来ている事を確認
[root@oracle-linux~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 8.9M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda3 39G 11G 28G 29% /
/dev/sda1 200M 7.5M 193M 4% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/0
tmpfs 1.6G 0 1.6G 0% /run/user/1000
/dev/dm-1 10G 2.0G 8.1G 20% /var/lib/docker/devicemapper/mnt/412a8481dd4113916fa27887c6561b5395f907e1c01ea0433a321ec005983284
tmpfs 1.6G 0 1.6G 0% /run/user/994
jfuse 8.0E 0 8.0E 0% /var/lib/docker/volumes/02f15a370195cdd8575ed437aa0a3524574c62cd21f9986897d87565aecc13bc/_data/test
10.0.5.173:/test 8.0E 0 8.0E 0% /mnt/test ★ここに注目
[root@oracle-linux ~]#
何かファイルを置いてみる
[root@oracle-linux ~]# cd /mnt/test/
[root@oracle-linux test]# touch test.txt
[root@oracle-linux test]# ls test.txt
test.txt
[root@oracle-linux test]#
この通り問題なくファイルを置けました。
Oracle Linux8にDockerをインストールしてみる
過去記事より
はじめに
Oracle Linuxは構築済みです。スペックはFreeTierです。
Oracle Linuxの概要
NAME="Oracle Linux Server"
VERSION="8.5"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.5"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.5"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:5:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.5
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.5
Dockerのインストール
OSを最新に保つ
yum update -y
yum upgrade -y
旧バージョンのアンインストール
[opc@oracle-linux ~]$ sudo yum remove docker docker-client docker-client-latest
docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engi
ne
No match for argument: docker
No match for argument: docker-client
No match for argument: docker-client-latest
No match for argument: docker-common
No match for argument: docker-latest
No match for argument: docker-latest-logrotate
No match for argument: docker-logrotate
No match for argument: docker-engine
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
[opc@oracle-linux ~]$
その他必要なモジュールのインストール
[root@oracle-linux ~]# dnf install -y dnf-utils zip unzip
Last metadata expiration check: 0:20:03 ago on Fri 15 Apr 2022 02:29:37 AM GMT.
Package yum-utils-4.0.21-4.0.1.el8_5.noarch is already installed.
Package zip-3.0-23.el8.x86_64 is already installed.
Package unzip-6.0-45.el8_4.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@oracle-linux ~]#
リポジトリのインストール
[root@oracle-linux ~]# dnf config-manager --add-repo=https://download.docker.com/linux/centos/d
ocker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
DOCKER CE のインストール
[root@oracle-linux ~]# dnf install -y docker-ce --nobest
Docker CE Stable - x86_64 211 kB/s | 23 kB 00:00
Dependencies resolved.
======================================================================================================
Package Arch Version Repository Size
======================================================================================================
Installing:
docker-ce x86_64 3:20.10.14-3.el8 docker-ce-stable 22 M
Installing dependencies:
container-selinux noarch 2:2.173.0-1.module+el8.5.0+20494+0311868c ol8_appstream 57 k
containerd.io x86_64 1.5.11-3.1.el8 docker-ce-stable 29 M
docker-ce-cli x86_64 1:20.10.14-3.el8 docker-ce-stable 30 M
docker-ce-rootless-extras x86_64 20.10.14-3.el8 docker-ce-stable 4.6 M
docker-scan-plugin x86_64 0.17.0-3.el8 docker-ce-stable 3.8 M
fuse-common x86_64 3.2.1-12.0.3.el8 ol8_baseos_latest 22 k
fuse-overlayfs x86_64 1.8-1.module+el8.5.0+20494+0311868c ol8_appstream 73 k
fuse3 x86_64 3.2.1-12.0.3.el8 ol8_baseos_latest 51 k
fuse3-libs x86_64 3.2.1-12.0.3.el8 ol8_baseos_latest 95 k
libcgroup x86_64 0.41-19.el8 ol8_baseos_latest 70 k
libslirp x86_64 4.4.0-1.module+el8.5.0+20416+d687fed7 ol8_appstream 70 k
policycoreutils-python-utils
noarch 2.9-16.0.1.el8 ol8_baseos_latest 252 k
slirp4netns x86_64 1.1.8-1.module+el8.5.0+20416+d687fed7 ol8_appstream 51 k
Enabling module streams:
container-tools ol8
Transaction Summary
======================================================================================================
Install 14 Packages
Total download size: 90 M
Installed size: 374 M
Downloading Packages:
(1/14): containerd.io-1.5.11-3.1.el8.x86_64.rpm 17 MB/s | 29 MB 00:01
(2/14): docker-ce-cli-20.10.14-3.el8.x86_64.rpm 16 MB/s | 30 MB 00:01
(3/14): docker-ce-rootless-extras-20.10.14-3.el8.x86_64.rpm 11 MB/s | 4.6 MB 00:00
(4/14): docker-scan-plugin-0.17.0-3.el8.x86_64.rpm 14 MB/s | 3.8 MB 00:00
(5/14): fuse-common-3.2.1-12.0.3.el8.x86_64.rpm 158 kB/s | 22 kB 00:00
(6/14): fuse3-3.2.1-12.0.3.el8.x86_64.rpm 520 kB/s | 51 kB 00:00
(7/14): docker-ce-20.10.14-3.el8.x86_64.rpm 8.2 MB/s | 22 MB 00:02
(8/14): libcgroup-0.41-19.el8.x86_64.rpm 196 kB/s | 70 kB 00:00
(9/14): fuse3-libs-3.2.1-12.0.3.el8.x86_64.rpm 230 kB/s | 95 kB 00:00
(10/14): policycoreutils-python-utils-2.9-16.0.1.el8.noarch.rpm 3.1 MB/s | 252 kB 00:00
(11/14): fuse-overlayfs-1.8-1.module+el8.5.0+20494+0311868c.x86_64.rp 1.0 MB/s | 73 kB 00:00
(12/14): libslirp-4.4.0-1.module+el8.5.0+20416+d687fed7.x86_64.rpm 3.3 MB/s | 70 kB 00:00
(13/14): container-selinux-2.173.0-1.module+el8.5.0+20494+0311868c.no 613 kB/s | 57 kB 00:00
(14/14): slirp4netns-1.1.8-1.module+el8.5.0+20416+d687fed7.x86_64.rpm 583 kB/s | 51 kB 00:00
------------------------------------------------------------------------------------------------------
Total 32 MB/s | 90 MB 00:02
Docker CE Stable - x86_64 22 kB/s | 1.6 kB 00:00
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
From : https://download.docker.com/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : docker-scan-plugin-0.17.0-3.el8.x86_64 1/14
Running scriptlet: docker-scan-plugin-0.17.0-3.el8.x86_64 1/14
Installing : docker-ce-cli-1:20.10.14-3.el8.x86_64 2/14
Running scriptlet: docker-ce-cli-1:20.10.14-3.el8.x86_64 2/14
Installing : libslirp-4.4.0-1.module+el8.5.0+20416+d687fed7.x86_64 3/14
Installing : slirp4netns-1.1.8-1.module+el8.5.0+20416+d687fed7.x86_64 4/14
Installing : policycoreutils-python-utils-2.9-16.0.1.el8.noarch 5/14
Running scriptlet: container-selinux-2:2.173.0-1.module+el8.5.0+20494+0311868c.noarch 6/14
Installing : container-selinux-2:2.173.0-1.module+el8.5.0+20494+0311868c.noarch 6/14
Running scriptlet: container-selinux-2:2.173.0-1.module+el8.5.0+20494+0311868c.noarch 6/14
Installing : containerd.io-1.5.11-3.1.el8.x86_64 7/14
Running scriptlet: containerd.io-1.5.11-3.1.el8.x86_64 7/14
Running scriptlet: libcgroup-0.41-19.el8.x86_64 8/14
Installing : libcgroup-0.41-19.el8.x86_64 8/14
Running scriptlet: libcgroup-0.41-19.el8.x86_64 8/14
Installing : fuse3-libs-3.2.1-12.0.3.el8.x86_64 9/14
Running scriptlet: fuse3-libs-3.2.1-12.0.3.el8.x86_64 9/14
Installing : fuse-common-3.2.1-12.0.3.el8.x86_64 10/14
Installing : fuse3-3.2.1-12.0.3.el8.x86_64 11/14
Installing : fuse-overlayfs-1.8-1.module+el8.5.0+20494+0311868c.x86_64 12/14
Running scriptlet: fuse-overlayfs-1.8-1.module+el8.5.0+20494+0311868c.x86_64 12/14
Installing : docker-ce-rootless-extras-20.10.14-3.el8.x86_64 13/14
Running scriptlet: docker-ce-rootless-extras-20.10.14-3.el8.x86_64 13/14
Installing : docker-ce-3:20.10.14-3.el8.x86_64 14/14
Running scriptlet: docker-ce-3:20.10.14-3.el8.x86_64 14/14
Running scriptlet: container-selinux-2:2.173.0-1.module+el8.5.0+20494+0311868c.noarch 14/14
Running scriptlet: docker-ce-3:20.10.14-3.el8.x86_64 14/14
Verifying : containerd.io-1.5.11-3.1.el8.x86_64 1/14
Verifying : docker-ce-3:20.10.14-3.el8.x86_64 2/14
Verifying : docker-ce-cli-1:20.10.14-3.el8.x86_64 3/14
Verifying : docker-ce-rootless-extras-20.10.14-3.el8.x86_64 4/14
Verifying : docker-scan-plugin-0.17.0-3.el8.x86_64 5/14
Verifying : fuse-common-3.2.1-12.0.3.el8.x86_64 6/14
Verifying : fuse3-3.2.1-12.0.3.el8.x86_64 7/14
Verifying : fuse3-libs-3.2.1-12.0.3.el8.x86_64 8/14
Verifying : libcgroup-0.41-19.el8.x86_64 9/14
Verifying : policycoreutils-python-utils-2.9-16.0.1.el8.noarch 10/14
Verifying : container-selinux-2:2.173.0-1.module+el8.5.0+20494+0311868c.noarch 11/14
Verifying : fuse-overlayfs-1.8-1.module+el8.5.0+20494+0311868c.x86_64 12/14
Verifying : libslirp-4.4.0-1.module+el8.5.0+20416+d687fed7.x86_64 13/14
Verifying : slirp4netns-1.1.8-1.module+el8.5.0+20416+d687fed7.x86_64 14/14
Installed:
container-selinux-2:2.173.0-1.module+el8.5.0+20494+0311868c.noarch
containerd.io-1.5.11-3.1.el8.x86_64
docker-ce-3:20.10.14-3.el8.x86_64
docker-ce-cli-1:20.10.14-3.el8.x86_64
docker-ce-rootless-extras-20.10.14-3.el8.x86_64
docker-scan-plugin-0.17.0-3.el8.x86_64
fuse-common-3.2.1-12.0.3.el8.x86_64
fuse-overlayfs-1.8-1.module+el8.5.0+20494+0311868c.x86_64
fuse3-3.2.1-12.0.3.el8.x86_64
fuse3-libs-3.2.1-12.0.3.el8.x86_64
libcgroup-0.41-19.el8.x86_64
libslirp-4.4.0-1.module+el8.5.0+20416+d687fed7.x86_64
policycoreutils-python-utils-2.9-16.0.1.el8.noarch
slirp4netns-1.1.8-1.module+el8.5.0+20416+d687fed7.x86_64
Complete!
dockerの起動
[root@oracle-linux ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://docs.docker.com
[root@oracle-linux ~]# systemctl start docker
[root@oracle-linux ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2022-04-15 03:13:23 GMT; 1s ago
Docs: https://docs.docker.com
Main PID: 13979 (dockerd)
Tasks: 8
Memory: 94.6M
CGroup: /system.slice/docker.service
mq13979 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Apr 15 03:13:17 oracle-linux dockerd[13979]: time="2022-04-15T03:13:17.385173449Z" level=warni>
Apr 15 03:13:17 oracle-linux dockerd[13979]: time="2022-04-15T03:13:17.387403632Z" level=info >
Apr 15 03:13:21 oracle-linux dockerd[13979]: time="2022-04-15T03:13:21.605179435Z" level=info >
Apr 15 03:13:22 oracle-linux dockerd[13979]: time="2022-04-15T03:13:22.104739721Z" level=info >
Apr 15 03:13:22 oracle-linux dockerd[13979]: time="2022-04-15T03:13:22.587164200Z" level=info >
Apr 15 03:13:23 oracle-linux dockerd[13979]: time="2022-04-15T03:13:23.074562959Z" level=warni>
Apr 15 03:13:23 oracle-linux dockerd[13979]: time="2022-04-15T03:13:23.074996939Z" level=info >
Apr 15 03:13:23 oracle-linux dockerd[13979]: time="2022-04-15T03:13:23.076170917Z" level=info >
Apr 15 03:13:23 oracle-linux systemd[1]: Started Docker Application Container Engine.
Apr 15 03:13:23 oracle-linux dockerd[13979]: time="2022-04-15T03:13:23.289822830Z" level=info >
[root@oracle-linux ~]#
info情報
[root@oracle-linux ~]# docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.1-docker)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 20.10.14
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: false
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc version: v1.0.3-0-gf46b6ba
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.4.17-2136.306.1.3.el8uek.x86_64
Operating System: Oracle Linux Server 8.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 682.7MiB
Name: oracle-linux
ID: CFPC:X4AC:YELO:YCUL:GS23:PJUY:4QSJ:SDTD:YSPK:VXFP:QV7A:7PET
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
バージョン情報
[root@oracle-linux ~]# docker --version
Docker version 20.10.14, build a224086
OCI Log AnalyticsでVCN Flow Logを可視化する
過去記事より
作業の流れ
- 1.Log Analyticsの有効化
- 2.ロググループの作成
- 3.VCN Flow Logの有効化
- 4.Log Analyticsのグループ作成
- 5.コネクターハブの作成
1.Log Analyticsの有効化
OCIコンソールにログインし、画面左上のハンバーガーメニューより【監視および管理】->【ログアナリティクス】を選択します。
その後下記イメージの【ログ・アナリティクスの仕様の開始】をクリックします。
【取得の設定】をクリックします。
私はオンプレのログも収集したいので、このままで【次へ】をクリックしました。
もう一度【取得の設定】をクリックします。
無事ログ・アナリティクスが有効にできたら、ダッシュボードに移動します。
2.ロググループの作成
OCIコンソールのハンバーガーメニューより【監視および管理】->【ログ・グループ】を選択します。
【ログ・グループの作成】より下記イメージのとおりグループを作成します。
3.VCN Flow Logの有効化
Flowログを取得したいサブネットにアクセスし、ログ項目にてログの有効化を【有効】にします。
下記イメージのとおりFlowログの有効化を行います。
4.Log Analyticsのグループ作成
OCIコンソールのハンバーガーメニューより【監視および管理】->【管理】より【ログ・グループの作成】を行います。
適当に名前を付けてグループを作成します。
5.コネクターハブの作成
OCIコンソールのハンバーガーメニューより【ロギング】->【サービス・コネクタ】より【サービス・コネクタの作成】を行います。
設定ページが長いので設定する箇所は下記イメージをご参照ください。
コネクタ名を入力します。
作成したログ・グループを指定します。
作成したグループを指定します。
ログ・アナリティクスでFlowログを確認する
いくつかサブネットを追加しました。
ログ・アナリティクスを有効化するとFlowログのダッシュボードがデフォルトで作られます。
次はオンプレのWindowsのログを収集可視化したいですね。
Oracle Linux7でSyslogサーバ構築
過去記事より
会社に散らばるログ関連を一か所に集めるためにSyslogサーバを構築しようと思います。
OS情報
NAME="Oracle Linux Server"
VERSION="7.9"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Oracle Linux Server 7.9"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:9:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.9
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.9
準備
yum update -y
rsyslogのインストール
ubuntu20.04は既にインストールされているのでスキップします。
/etc/rsyslog.confの編集
vim /etc/rsyslog.conf
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
Firewallのポート開放
firewall-cmd --zone=public --add-port=514/udp
rsyslogの再起動
systemctl restart rsyslog
機器別に出力振り分け
このままだといくつかの機器からのログが一緒に出力されて非常に見辛いので機器別(ホスト別)にしたいと思います。
とりあえず下記を/etc/rsyslog.confに追記します。
多分場所はどこでもOK
RTX1200シリーズの場合
ルータで側の設定
syslog host 10.0.5.31
syslog facility local1
syslogサーバ側の設定
*.info;mail.none;authpriv.none;cron.none;local1.none /var/log/messages
# RTX1200
local1.* /var/log/rtx1210.log
FrotiGate60Fの場合
FortiGate側の設定
facility値がlocal7であることを覚えておきます。
FGT60FTK2109BTDP # show full-configuration log syslogd setting
config log syslogd setting
set status enable
set server "10.0.5.31"
set mode udp
set port 514
set facility local7
set source-ip ''
set format default
set priority default
set max-log-rate 0
set interface-select-method auto
end
FGT60FTK2109BTDP #
syslogサーバ側の設定
*.info;mail.none;authpriv.none;cron.none;local1.none /var/log/messages
#FortiGate
local7.* /var/log/fortigate.log
rsyslogの再起動
systemctl restart rsyslog
Oracle Linuxのcron実行時間を変更する
過去記事より
logrotateのdailyの実行時間はデフォルトで3:11~3:50らしく、このタイミングで実行されると日付が跨ってしまい余計な時間が含まれてしまいます。
なので23:59にlogrotateが実行されるよう変更したいと思います。
/etc/anacrontabの編集
1 5 cron.daily nice run-parts /etc/cron.daily
↑をコメントアウトします。
これで3時台に実行されるのを防ぎます。
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22
#period in days delay in minutes job-identifier command
#1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly
/etc/crontabの編集
最終行に59 23 * * * root run-parts /etc/cron.dailyを追加します。
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
59 23 * * * root run-parts /etc/cron.daily
cronの再起動を実施
systemctl restart crond.service
OracleLinux8にElasticsearch/Kibana/Logstashをインストールしてみる
過去記事より
yumのアップデートを実施
yum update -y
OpenJDKのインストール
yum install java-1.8.0-openjdk-devel -y
JDKのバージョン確認
[root@ekl ~]# java -version
openjdk version "1.8.0_332"
OpenJDK Runtime Environment (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode)
[root@ekl ~]#
Elasticsearch PGPキーのインストール
[root@ekl ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
リポジトリの登録
[root@ekl ~]# vi /etc/yum.repos.d/elasticsearch.repo
[root@ekl ~]# cat /etc/yum.repos.d/elasticsearch.repo
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md
[root@ekl ~]#
Elasticsearch/Kibana/Logstashのインストール
[root@ekl ~]# yum install --enablerepo=elasticsearch elasticsearch kibana logstash
Elastricsearchに利用するIPアドレスの設定
network.host: 0.0.0.0をelasticsearch.ymlに追記する
[root@ekl ~]# vi /etc/elasticsearch/elasticsearch.yml
[root@ekl ~]# cat /etc/elasticsearch/elasticsearch.yml | grep "network.host"
#network.host: 192.168.0.1
network.host: 0.0.0.0
[root@ekl ~]#
Kibanaに利用するIPアドレスの設定
server.host: 0.0.0.0をkibana.ymlに追記する
[root@ekl ~]# vi /etc/kibana/kibana.yml
[root@ekl ~]# cat /etc/kibana/kibana.yml| grep "server.host"
#server.host: "localhost"
server.host: "0.0.0.0"
[root@ekl ~]#
FireWallのポート開放
[root@ekl ~]# firewall-cmd --add-port=5601/tcp --zone=public --permanent
success
[root@ekl ~]# firewall-cmd --add-port=9200/tcp --zone=public --permanent
success
[root@ekl ~]# firewall-cmd --add-port=9600/tcp --zone=public --permanent
success
[root@ekl ~]# firewall-cmd --reload
success
起動
[root@ekl ~]# systemctl restart elasticsearch kibana logstash
Job for elasticsearch.service failed because the control process exited with error code.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.
どれかが起動失敗してしまいました。
[root@ekl ~]# systemctl status kibana
● kibana.service - Kibana
Loaded: loaded (/etc/systemd/system/kibana.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2022-05-17 05:00:13 GMT; 1min 16s ago
Docs: https://www.elastic.co
Main PID: 117831 (node)
Tasks: 11 (limit: 100054)
Memory: 255.2M
CGroup: /system.slice/kibana.service
mq117831 /usr/share/kibana/bin/../node/bin/node /usr/share/kibana/bin/../src/cli/dist --logging.dest=/var/>
May 17 05:00:13 ekl systemd[1]: Started Kibana.
[root@ekl ~]# systemctl status logstash
● logstash.service - logstash
Loaded: loaded (/etc/systemd/system/logstash.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2022-05-17 05:01:40 GMT; 23s ago
Main PID: 118515 (java)
Tasks: 19 (limit: 100054)
Memory: 498.2M
CGroup: /system.slice/logstash.service
mq118515 /usr/share/logstash/jdk/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancy>
May 17 05:01:40 ekl systemd[1]: Started logstash.
May 17 05:01:40 ekl logstash[118515]: Using bundled JDK: /usr/share/logstash/jdk
May 17 05:01:40 ekl logstash[118515]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in v>
May 17 05:02:02 ekl logstash[118515]: Sending Logstash logs to /var/log/logstash which is now configured via log4j2.p>
May 17 05:02:02 ekl logstash[118515]: [2022-05-17T05:02:02,150][INFO ][logstash.runner ] Log4j configuration>
May 17 05:02:02 ekl logstash[118515]: [2022-05-17T05:02:02,159][INFO ][logstash.runner ] Starting Logstash {>
May 17 05:02:02 ekl logstash[118515]: [2022-05-17T05:02:02,161][INFO ][logstash.runner ] JVM bootstrap flags>
May 17 05:02:03 ekl logstash[118515]: [2022-05-17T05:02:03,826][INFO ][logstash.agent ] Successfully starte>
May 17 05:02:03 ekl logstash[118515]: [2022-05-17T05:02:03,858][INFO ][logstash.config.source.local.configpathloader]>
May 17 05:02:03 ekl logstash[118515]: [2022-05-17T05:02:03,875][ERROR][logstash.config.sourceloader] No configuration>
[root@ekl ~]#
kibanaとlogstashは起動しているのでElasticsearchが起動に失敗していると思うので確認してみる。
[root@ekl ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2022-05-17 05:00:59 GMT; 2min 22s ago
Docs: https://www.elastic.co
Process: 117832 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (>
Main PID: 117832 (code=exited, status=78)
May 17 05:00:13 ekl systemd[1]: Starting Elasticsearch...
May 17 05:00:59 ekl systemd-entrypoint[117832]: ERROR: [1] bootstrap checks failed. You must address the points descr>
May 17 05:00:59 ekl systemd-entrypoint[117832]: bootstrap check failure [1] of [1]: the default discovery settings ar>
May 17 05:00:59 ekl systemd-entrypoint[117832]: ERROR: Elasticsearch did not exit normally - check the logs at /var/l>
May 17 05:00:59 ekl systemd[1]: elasticsearch.service: Main process exited, code=exited, status=78/CONFIG
May 17 05:00:59 ekl systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
May 17 05:00:59 ekl systemd[1]: Failed to start Elasticsearch.
[root@ekl ~]#
やっぱりElasticsearchが起動失敗しています。
エラーログより
[1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
このエラーは下記記事を参照し解決しました。
こちらの記事
[root@ekl ~]# vi /etc/elasticsearch/elasticsearch.yml
[root@ekl ~]# cat /etc/elasticsearch/elasticsearch.yml | grep "transport"
transport.host: localhost
transport.tcp.port: 9300
[root@ekl ~]# systemctl stop elasticsearch
[root@ekl ~]# systemctl start elasticsearch
[root@ekl ~]#
Elasticsearchへアクセス確認
[root@ekl ~]# curl http://localhost:9200
{
"name" : "ekl",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "1cfwFXA1SgmhqHsEFxu9uw",
"version" : {
"number" : "7.17.3",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "5ad023604c8d7416c9eb6c0eadb62b14e766caff",
"build_date" : "2022-04-19T08:11:19.070913226Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[root@ekl ~]#
Kibanaへアクセス確認
ブラウザで http://<Server IP Address>:5601 と入力しアクセス出来るか確認してみます。
ElasticStack8系をOracle Linux7にインストールしてみた
過去記事より
前回記事ではElastic Stack(ElasticSearch,Kibana,Logstash)のバージョンが7系をインストールしていたと思います前回記事ではElastic Stack(ElasticSearch,Kibana,Logstash)のバージョン7系をインストールしていたとと思います。
今回は8系をインストールしていきます。
事前準備
yum update
yum update -y
Selinuxの無効化
[root@elastic-181174 ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
Firewallのポート開放
firewall-cmd --add-port=5601/tcp --zone=public --permanent
firewall-cmd --add-port=9200/tcp --zone=public --permanent
firewall-cmd --add-port=9600/tcp --zone=public --permanent
firewall-cmd --reload
RPMのインポート
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
リポジトリの登録
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md
ElasticStackインストール
yum install --enablerepo=elasticsearch elasticsearch kibana logstash
下記のようにログが出ればOK
Installed:
elasticsearch.x86_64 0:8.2.1-1 kibana.x86_64 0:8.2.1-1 logstash.x86_64 1:8.2.1-1
Complete!
ElasticsearchとKibanaの設定
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
network.host: 0.0.0.0 ★追加
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
http.port: 9200 ★追加
# =================== System: Kibana Server ===================
# Kibana is served by a back end server. This setting specifies the port to use.
#server.port: 5601
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
#server.host: "localhost"
server.host: "0.0.0.0" ★追加
ElasticStackの再起動
systemctl restart elasticsearch kibana logstash
ブラウザでkibanaにアクセスする
Enrollment token
アクセスするとEnrollment tokenの入力を求められます。
8系からなのか分かりませんが、このようなステップが必要となります。
ElasticStackを簡単インストールする方法だとログにtokenが出力されるのですが、RPM経由でインストールすると、tokenが自動発行されません(もしかすると発行されるかもしれません)
なので、再発行します。
Enrollment tokenの再発行
cd /usr/share/elasticsearch/
bin/elasticsearch-create-enrollment-token -s node
ユーザでのログイン
ユーザのパスワードを再発行します。
$ cd /usr/share/elasticsearch/bin/
$ ./elasticsearch-reset-password -u elastic
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]y
Password for the [elastic] user successfully reset.
New value: 7A67uSbHDBraeuhqO9td
以上でElastiStack8系のインストール完了です。
OCI PythonSDKをインストールしてPARを取得するまでやってみる
過去記事より
OCI PythonSDKをインストールしてPARを取得してみました。
※PARとはPreAuthenticationRequestの略です。事前認証リクエストURLですね。
※PythonSDKのバージョンはv2.70.0です。
驚きの事実
1年前までoci-curlでREST APIを実行しており、もう一度設定しようとページを探したのですが、見つからずサポートに問い合わせるとoci-curlはサポートされなくなったと言われてしまいました・・・
PythonSDKの環境構築
前提条件
- OCI CLIがインストールされている
- Python3系がインストールされている
$ pip3 -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
$ python3 -V
Python 3.8.10
$ oci --version
3.9.0
s-kaneko@S19076:~$
インストーラをダウンロードします。
wget https://github.com/oracle/oci-python-sdk/releases/download/v2.70.0/oci-python-sdk-2.70.0.zip
解凍し階層移動します
unzip oci-python-sdk-2.70.0.zip
cd oci-python-sdk/
PytonSDKをpipインストール
pip3 install oci-2.70.0-py2.py3-none-any.whl
PythonSDKを使ってPARの作成
基本となるコード
こちらのコードはオラクルのドキュメントに記載されています。
# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
import oci
from datetime import datetime
# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()
# Initialize service client with default config file
object_storage_client = oci.object_storage.ObjectStorageClient(config)
# Send the request to service, some parameters are not required, see API
# doc for more info
create_preauthenticated_request_response = object_storage_client.create_preauthenticated_request(
namespace_name="EXAMPLE-namespaceName-Value",
bucket_name="EXAMPLE-bucketName-Value",
create_preauthenticated_request_details=oci.object_storage.models.CreatePreauthenticatedRequestDetails(
name="EXAMPLE-name-Value",
access_type="AnyObjectWrite",
time_expires=datetime.strptime(
"2007-03-21T15:52:36.708Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
bucket_listing_action="Deny",
object_name="EXAMPLE-objectName-Value"),
opc_client_request_id="ocid1.test.oc1..<unique_ID>EXAMPLE-opcClientRequestId-Value")
# Get the data from response
print(create_preauthenticated_request_response.data)
ちょこっとコードを修正
私の場合「opc_client_request_id」
object_storage_client.create_preauthenticated_request(
namespace_name="*********", #バケットのネームスペース
bucket_name="*********", #PARを発行するバケットの名前を指定
create_preauthenticated_request_details=oci.object_storage.models.CreatePreauthenticatedRequestDetails(
name="test_bucket", #PARに付ける名前なんでもOK
access_type="AnyObjectWrite", #バケットorオブジェクトに対する権限設定
time_expires=datetime.strptime( #PARの有効期限を指定
"2007-03-21T15:52:36.708Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
bucket_listing_action="Deny", #バケット内部のファイルのリスト参照を禁止
object_name="********"), 接頭辞付きURLにする場合の設定
opc_client_request_id="ocid1.test.oc1..<unique_ID>EXAMPLE-opcClientRequestId-Value")
実行してみる
$ python3 oci_python_sdk.py
{
"access_type": "AnyObjectWrite",
"access_uri": "/p/E*************G10Tn/n/***********/b/*******/o/",
"bucket_listing_action": "Deny",
"id": "T8LNbvBhpzXN********************IjFOGS5DRjZqzns",
"name": "par",
"object_name": "object",
"time_created": "2022-06-02T01:07:42.695000+00:00",
"time_expires": "2022-06-04T15:52:36.708000+00:00"
}
$
OCIコンソールで確認して分かったのですが、このコードだと「接頭辞付きURL」になっています。
バケット単位のPARを作成してみる
object_nameをコメントアウトします
create_preauthenticated_request_details=oci.object_storage.models.CreatePreauthenticatedRequestDetails(
name="par",
access_type="AnyObjectWrite",
time_expires=datetime.strptime(
"2022-06-4T15:52:36.708Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
bucket_listing_action="Deny",
#object_name="object"
),
)
オブジェクト単位のPARを作成してみる
access_typeを「ObjectWrite」に変更します。
create_preauthenticated_request_details=oci.object_storage.models.CreatePreauthenticatedRequestDetails(
name="par",
access_type="ObjectWrite",
time_expires=datetime.strptime(
"2022-06-4T15:52:36.708Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
bucket_listing_action="Deny",
object_name="object"
),
)
最後に
セキュリティが気になる方は「accessType」を活用されることをお勧めします。
accessTypeのパラメータ
- ObjectRead
- ObjectWrite
- ObjectReadWrite
- AnyObjectWrite
- AnyObjectRead
- AnyObjectReadWrite
AirflowでOCIのPythonSDKをインポートする方法
過去記事より
前提
こちらの方法でインストールしている環境を前提としています。
公式ドキュメント
とても参考になりました。
インポートする方法
現在の環境にはいくつかDockerが起動しています。
[opc@airflow5 dags]$ sudo docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------------------
opc_airflow-init_1 /usr/bin/dumb-init -- /ent Exit 0
...
opc_airflow-scheduler_1 /usr/bin/dumb-init -- /ent Up (healthy) 8080/tcp
...
opc_airflow-webserver_1 /usr/bin/dumb-init -- /ent Up (healthy) 0.0.0.0:8080->8080/tcp,:::
... 8080->8080/tcp
opc_airflow-worker_1 /usr/bin/dumb-init -- /ent Up (healthy) 8080/tcp
...
opc_flower_1 /usr/bin/dumb-init -- /ent Up (healthy) 0.0.0.0:5555->5555/tcp,:::
... 5555->5555/tcp, 8080/tcp
opc_postgres_1 docker-entrypoint.sh Up (healthy) 5432/tcp
postgres
opc_redis_1 docker-entrypoint.sh redis Up (healthy) 0.0.0.0:6379->6379/tcp,:::
... 6379->6379/tcp
[opc@airflow5 dags]$
DAGのジョブはこのいずれかのDocker上で動作します。
その為、PythonSDKの環境をDocker上に構築します。
どのDockerにインストールするのか?
opc_airflow-scheduler_1にインストールします。
その他のopc_airflow-webserver_1やopc_airflow-worker_1でも試しましたが、下記エラーとなりました。
Broken DAG: [/opt/airflow/dags/test_dag.py] Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/opt/airflow/dags/test_dag.py", line 9, in <module>
import oci
ModuleNotFoundError: No module named 'oci'
opc_airflow-scheduler_1へPythonSDKをインストール
以前の記事を参考にしました。
Discussion