構成
※東京リージョン - 大阪リージョン間のリモートピアリングの設定は完了済
未設定の場合は、以下のドキュメントから作成を行う必要がある
環境(NFSサーバ、NFSクライアント共通)
- OS:Oracle Linux 9
-
ストレージ:50GB
使用量に応じて、ストレージ・サイズの拡張を行う必要がある - root権限を使用できる事
NFSサーバの共有
NFSサーバにSSHログイン後、NFSのユーティリティ・パッケージをインストール
[opc@nfs-sv ~]$ sudo dnf install -y nfs-utils
メタデータの期限切れの最終確認: 0:02:18 前の 2024年02月09日 16時28分55秒 に実施しました。
パッケージ nfs-utils-1:2.5.4-20.0.1.el9.x86_64 は既にインストールされています。
依存関係が解決しました。
===================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
===================================================================================================================================================
アップグレード:
nfs-utils x86_64 1:2.5.4-20.0.1.el9 ol9_baseos_latest 513 k
トランザクションの概要
===================================================================================================================================================
アップグレード 1 パッケージ
合計サイズ: 513 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
[SKIPPED] nfs-utils-2.5.4-20.0.1.el9.x86_64.rpm: Already downloaded
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
準備 : 1/1
scriptletの実行中: nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
アップグレード中 : nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
scriptletの実行中: nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
scriptletの実行中: nfs-utils-1:2.5.4-20.el9.x86_64 2/2
整理 : nfs-utils-1:2.5.4-20.el9.x86_64 2/2
scriptletの実行中: nfs-utils-1:2.5.4-20.el9.x86_64 2/2
検証 : nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
検証 : nfs-utils-1:2.5.4-20.el9.x86_64 2/2
アップグレード済み:
nfs-utils-1:2.5.4-20.0.1.el9.x86_64
完了しました!
共有ストレージ用のディレクトリ(ここでは/nfs-share
)を作成。
[opc@nfs-sv ~]$ sudo mkdir /nfs-share
10MBの空ファイルを作成
[opc@nfs-sv ~]$ sudo fallocate -l 10MB /nfs-share/testfile
ls -lh
コマンドを使用して、nfs-share
配下にtestfile
が作成されている事を確認
[opc@nfs-sv ~]$ ls -lh /nfs-share
合計 9.6M
-rw-r--r-- 1 root root 9.6M 2月 9 16:38 testfile
/nfs-share
の権限を777に変更
# 権限を変更
[opc@nfs-sv ~]$ sudo chmod -R 777 /nfs-share
# 権限を確認
[opc@nfs-sv ~]$ ls -l / | grep nfs-share && ls -lh /nfs-share
drwxrwxrwx 2 root root 22 2月 9 16:38 nfs-share
合計 9.6M
-rwxrwxrwx 1 root root 9.6M 2月 9 16:38 testfile
/etc/exports
に以下を記述
[opc@nfs-sv ~]$ cat /etc/exports
#共有ストレージ用のディレクトリ 共有先NFSクライアントのIPアドレス(権限)
/nfs-share 172.16.1.55(rw)
nfs-server
の自動起動を実行
# nfs-serverを自動起動
[opc@nfs-sv ~]sudo systemctl enable --now nfs-server
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.
# nfs-serverのステータス確認
[opc@nfs-sv ~]$ sudo systemctl status nfs-server
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; preset: disabled)
Drop-In: /run/systemd/generator/nfs-server.service.d
└─order-with-mounts.conf
Active: active (exited) since Fri 2024-02-09 16:51:26 JST; 10s ago
Process: 4842 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Process: 4843 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
Process: 4868 ExecStart=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited, status=0/SUCCESS)
Main PID: 4868 (code=exited, status=0/SUCCESS)
CPU: 12ms
2月 09 16:51:26 nfs-sv systemd[1]: Starting NFS server and services...
2月 09 16:51:26 nfs-sv systemd[1]: Finished NFS server and services.
showmount -e
コマンドで共有ストレージ用ディレクトリと共有先NFSクライアントのIPアドレスが表示される事を確認
[opc@nfs-sv ~]$ showmount -e
Export list for nfs-sv:
/nfs-share 172.16.1.55
NFSクライアントの共有
NFSクライアントにSSHログイン後、NFSのユーティリティ・パッケージをインストール
[opc@nfs-client ~]$ sudo dnf install -y nfs-utils
メタデータの期限切れの最終確認: 4:18:04 前の 2024年02月12日 11時48分10秒 に実施しました。
パッケージ nfs-utils-1:2.5.4-20.el9.x86_64 は既にインストールされています。
依存関係が解決しました。
===================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
===================================================================================================================================================
アップグレード:
nfs-utils x86_64 1:2.5.4-20.0.1.el9 ol9_baseos_latest 513 k
トランザクションの概要
===================================================================================================================================================
アップグレード 1 パッケージ
合計サイズ: 513 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
[SKIPPED] nfs-utils-2.5.4-20.0.1.el9.x86_64.rpm: Already downloaded
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
準備 : 1/1
scriptletの実行中: nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
アップグレード中 : nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
scriptletの実行中: nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
scriptletの実行中: nfs-utils-1:2.5.4-20.el9.x86_64 2/2
整理 : nfs-utils-1:2.5.4-20.el9.x86_64 2/2
scriptletの実行中: nfs-utils-1:2.5.4-20.el9.x86_64 2/2
検証 : nfs-utils-1:2.5.4-20.0.1.el9.x86_64 1/2
検証 : nfs-utils-1:2.5.4-20.el9.x86_64 2/2
アップグレード済み:
nfs-utils-1:2.5.4-20.0.1.el9.x86_64
完了しました!
[opc@nfs-client ~]$
マウントを行う共有ストレージ用のディレクトリ(ここではnfs-mount
)を作成
[opc@nfs-client ~]$ sudo mkdir /nfs-mount
mount
コマンドを使用して、共有ストレージをマウント
[opc@nfs-client ~]$ sudo mount 10.0.1.95:/nfs-share /nfs-mount
mount: (hint) your fstab has been modified, but systemd still uses
the old version; use 'systemctl daemon-reload' to reload.
[opc@nfs-client ~]$
nfs-server
を自動起動
# nfs-serverを自動起動
[opc@nfs-client ~]$ sudo systemctl enable nfs-server
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.
[opc@nfs-client ~]$
# nfs-serverのステータス確認
[opc@nfs-client ~]$ sudo systemctl status nfs-server
○ nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; preset: disabled)
Active: inactive (dead) since Mon 2024-02-12 10:37:30 JST; 10s ago
Duration: 54.849s
Main PID: 5566 (code=exited, status=0/SUCCESS)
CPU: 3ms
2月 12 10:36:35 nfs-client systemd[1]: Starting NFS server and services...
2月 12 10:36:35 nfs-client systemd[1]: Finished NFS server and services.
2月 12 10:37:30 nfs-client systemd[1]: Stopping NFS server and services...
2月 12 10:37:30 nfs-client systemd[1]: nfs-server.service: Deactivated successfully.
2月 12 10:37:30 nfs-client systemd[1]: Stopped NFS server and services.
ls -lh
コマンドで /nfs-mount
を表示、NFSサーバで作成した空ファイル(ここではtestfile
)が共有されている事を確認
[opc@nfs-client ~]$ ls -lh /nfs-mount
合計 9.6M
-rwxrwxrwx 1 root root 9.6M 2月 9 16:38 testfile
[opc@nfs-client ~]$
共有ストレージのマウント時、以下のエラーが発生した場合、
[opc@nfs-client ~]$ ls -lh /nfs-mount
ls:'/nfs-mount/testfile'にアクセスできません:許可がありません
合計 0
?????????? ???? ? testfile
[opc@nfs-client ~]$
NFSサーバの方の/etc/exports
にルートスクワッシングの権限を追加、nfs-server
を再起動
※ルートスクワッシング...root ユーザーからのアクセスを一般ユーザーとして扱い、セキュリティを高める手法。
- /nfs-share 10.0.1.95(rw)
+ /nfs-share 10.0.1.95(rw,no_root_squash)
また、マウントを永続化させる場合、NFSクライアントの/etc/fstab
に以下の内容を記述
(記述後、nfs-server
の再起動は不要)
#
# /etc/fstab
# Created by anaconda on Wed Jan 17 23:30:31 2024
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/ocivolume-root / xfs defaults 0 0
UUID=ae8aa5f6-a42a-424c-ad09-dce07c781808 /boot xfs defaults 0 0
UUID=3121-1E67 /boot/efi vfat defaults,uid=0,gid=0,umask=077,shortname=winnt 0 2
/dev/mapper/ocivolume-oled /var/oled xfs defaults 0 0
tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0
######################################
## ORACLE CLOUD INFRASTRUCTURE CUSTOMERS
##
## If you are adding an iSCSI remote block volume to this file you MUST
## include the '_netdev' mount option or your instance will become
## unavailable after the next reboot.
## SCSI device names are not stable across reboots; please use the device UUID instead of /dev path.
##
## Example:
## UUID="94c5aade-8bb1-4d55-ad0c-388bb8aa716a" /data1 xfs defaults,noatime,_netdev 0 2
##
## More information:
## https://docs.us-phoenix-1.oraclecloud.com/Content/Block/Tasks/connectingtoavolume.htm
/.swapfile none swap sw,comment=cloudconfig 0 0
+ 10.0.1.95:/nfs-share /nfs-mount nfs rw 0 0
以上
参考サイト