gcloud CLI를 사용하여 Filestore 인스턴스 만들기
이 빠른 시작에서는 Google Cloud CLI를 사용하여 Filestore를 빠르게 시작하고 실행하는 방법을 보여줍니다. 이 빠른 시작에서 설명하는 사항은 다음과 같습니다.
- Filestore 인스턴스를 만듭니다.
- 해당 인스턴스의 파일 공유를 Compute Engine 클라이언트 VM에 마운트합니다.
- 마운트된 파일 공유에서 파일을 만듭니다.
- Filestore 인스턴스를 삭제합니다.
시작하기 전에
프로젝트 선택 또는 생성:
프로젝트 만들기
gcloud projects create project-id
프로젝트 선택
gcloud config set project project-id
여기서 project-id는 Google Cloud 프로젝트의 ID입니다.
프로젝트에 결제가 사용 설정되어 있는지 확인하세요. 결제 사용 설정 방법을 알아봅니다.
-
gcloud CLI가 이미 설치되어 있으면 다음 명령어를 실행하여 업데이트합니다.
gcloud components update
이 문서에 설명된 태스크를 완료했으면 만든 리소스를 삭제하여 청구가 계속되는 것을 방지할 수 있습니다. 자세한 내용은 삭제를 참조하세요.
클라이언트로 사용할 Compute Engine VM 만들기
Linux
-
Create a Compute Engine instance. Configure the instance as follows:
-
Name the instance
nfs-client
. --zone
플래그를us-central1-c
로 설정합니다.--image-project
플래그를debian-cloud
로 설정합니다.--image-family
플래그를debian-11
로 설정합니다.-
--tags
플래그를http-server,
로 설정합니다.
gcloud compute instances create nfs-client --zone=us-central1-c --image-project=debian-cloud --image-family=debian-11 --tags=http-server,
-
Name the instance
Windows
-
Create a Compute Engine instance. Configure the instance as follows:
-
Name the instance
nfs-client
. --zone
플래그를us-central1-c
로 설정합니다.--image-project
플래그를windows-cloud
로 설정합니다.--image-family
플래그를windows-2012-r2
로 설정합니다.-
--tags
플래그를http-server,http-server,
로 설정합니다.
gcloud compute instances create nfs-client --zone=us-central1-c --image-project=windows-cloud --image-family=windows-2012-r2 --tags=http-server,http-server,
-
Name the instance
Filestore 인스턴스 만들기
Filestore 인스턴스를 만듭니다. 다음과 같이 인스턴스를 구성합니다.
- 인스턴스 이름을
nfs-server
로 지정합니다. --zone
플래그를us-central1-c
로 설정합니다.--tier
플래그를BASIC_HDD
로 설정합니다.--file-share
플래그를name="vol1",capacity=1TB
로 설정합니다.--network
플래그를name="default"
로 설정합니다.
gcloud filestore instances create nfs-server --zone=us-central1-c --tier=BASIC_HDD --file-share=name="vol1",capacity=1TB --network=name="default"
- 인스턴스 이름을
만든 Filestore 인스턴스에 대한 정보를 가져옵니다.
gcloud filestore instances describe nfs-server --zone=us-central1-c
이 명령어는 다음과 비슷한 결과를 반환합니다.
createTime: '2019-10-11T17:28:23.340943077Z' fileShares: - capacityGb: '1024' name: vol1 name: projects/yourproject/locations/us-central1-c/instances/nfs-server networks: - ipAddresses: - 10.0.0.2 network: default reservedIpRange: 10.0.0.0/29 state: READY tier: BASIC_HDD
파일 공유를 마운트할 때 사용하기 위해 인스턴스의 IP 주소를 복사합니다. 이 빠른 시작에서는 IP 주소
10.0.0.2
가 사용됩니다.
Filestore 파일 공유를 nfs-client
인스턴스에 마운트
Linux
-
Establish an SSH connection to the
nfs-client
인스턴스:gcloud compute ssh nfs-client
nfs-client
의 터미널 창에서 다음 명령어를 실행하여 NFS를 설치합니다.sudo apt-get -y update && sudo apt-get -y install nfs-common
Filestore 파일 공유에 대해
nfs-client
인스턴스에 마운트 디렉터리를 만듭니다.sudo mkdir /mnt/test
Filestore 인스턴스의 IP 주소, 파일 공유 이름, 마운트할 마운트 디렉터리를 지정하여
mount
명령어로nfs-client
인스턴스에 파일 공유를 마운트합니다.sudo mount 10.0.0.2:/vol1 /mnt/test
파일 공유 액세스가 가능하도록 권한을 변경합니다.
sudo chmod go+rw /mnt/test
Windows
nfs-client
인스턴스에 로그인하고 관리자로 명령 프롬프트를 엽니다.
계정을 만들고
nfs-client
인스턴스에 대해 초기 비밀번호를 설정합니다.gcloud compute reset-windows-password nfs-client
직렬 포트에 연결할 수 있도록 인스턴스를 구성합니다.
gcloud compute instances add-metadata nfs-client --metadata=serial-port-enable=1
대화형 세션을 입력합니다.
gcloud compute connect-to-serial-port nfs-client --port=2
SAC>
프롬프트에서 새 채널을 만듭니다.cmd
이름이
Cmd0001
인 채널이 생성됩니다.채널에 연결합니다.
ch -sn Cmd0001
nfs-client
인스턴스의 사용자 이름과 비밀번호를 입력하고Domain
필드를 비워 둡니다.nfs-client
인스턴스의Command Prompt
인터페이스에 연결됩니다.
NFS 클라이언트 설치
nfs-client
의Command Prompt
에서Windows PowerShell
로 전환합니다.powershell
NFS
클라이언트를 설치합니다.Install-WindowsFeature -Name NFS-Client
메시지가 표시되면
nfs-client
인스턴스를 다시 시작합니다.restart-computer
SAC>
프롬프트에서 다음 알림이 표시될 때까지 기다립니다.EVENT: The CMD command is now available.
그런 후 이전 안내에 따라
cmd
및ch -sn
명령어를 실행하여 로그인하고nfs-client
인스턴스에 다시 연결합니다.
NFS 클라이언트에 사용되는 사용자 ID 구성
- 명령 프롬프트에서
powershell
을 실행하여 Windows PowerShell로 전환합니다. PowerShell
에서 다음 명령어를 실행하여 2개의 새 레지스트리 항목AnonymousUid
및AnonymousGid
를 만듭니다.New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" ` -Name "AnonymousUid" -Value "0" -PropertyType DWORD New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" ` -Name "AnonymousGid" -Value "0" -PropertyType DWORD
NFS 클라이언트 서비스를 다시 시작합니다.
nfsadmin client stop nfsadmin client start
vol1
파일 공유를 nfs-client
인스턴스에 매핑
PowerShell
을 종료합니다.exit
Command Prompt
에서 Filestore 인스턴스의 IP 주소, 파일 공유 이름, 마운트할 드라이브 문자를 지정하여mount
명령어로nfs-client
인스턴스에 파일 공유를 마운트합니다.mount -o mtype=hard 10.0.0.2:/vol1 z:
마운트된 파일 공유에서 파일 만들기
Linux
nfs-client
터미널 창에서 다음 명령어를 실행하여 이름이testfile
인 파일을 만듭니다.echo 'This is a test' > /mnt/test/testfile
다음 명령어를 실행하고
testfile
이 반환된 디렉터리 콘텐츠에 있는지 확인하여 파일이 생성되었는지 확인합니다.ls /mnt/test
Windows
nfs-client
인스턴스의 명령 프롬프트 창에서 이름이testfile
인 파일을 만듭니다.echo 'This is a test' > Z:\testfile
다음 명령어를 실행하여 파일이 생성되었는지 확인합니다.
dir Z:
그리고
testfile
이 반환된 디렉터리 콘텐츠에 있는지 확인합니다.
삭제
이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 리소스가 포함된 Google Cloud 프로젝트를 삭제합니다.
Google Cloud 프로젝트 삭제
Delete a Google Cloud project:
gcloud projects delete PROJECT_ID
Filestore 인스턴스 삭제
nfs-server
인스턴스를 삭제합니다.
gcloud filestore instances delete nfs-server --zone=us-central1-c
Compute Engine 인스턴스 삭제
인스턴스를 삭제합니다.gcloud compute instances delete nfs-client
다음 단계
- Filestore 개요를 읽고 Filestore의 기본 사항에 대해 자세히 알아봅니다.
- 인스턴스 만들기의 안내에 따라 직접 Filestore 인스턴스를 설정합니다.
- 액세스 제어를 읽어 Filestore 작업 및 인스턴스의 리소스에 대한 액세스를 제어하는 방법을 알아봅니다.
- Filestore 인스턴스 간 데이터 복사 방법을 알아보세요.
- Cloud Storage에서 Filestore로 대규모 데이터 세트를 전송하는 방법을 알아보세요.