10.3. S3 액세스 테스트
S3 액세스를 확인하기 위해 Python 테스트 스크립트를 작성하고 실행해야 합니다. S3 액세스 테스트 스크립트는 radosgw 에 연결하고 새 버킷을 생성하고 모든 버킷을 나열합니다. aws_access_key_id 및 aws_secret_access_key 의 값은 radosgw_admin 명령에서 반환된 access_key 및 secret_key 값에서 가져옵니다.
사전 요구 사항
- 실행 중인 Red Hat Ceph Storage 클러스터.
- 노드에 대한 루트 수준 액세스.
프로세스
Red Hat Enterprise Linux 9용 High Availability 리포지토리를 활성화합니다.
subscription-manager repos --enable=rhel-9-for-x86_64-highavailability-rpmspython3-boto3패키지를 설치합니다.dnf install python3-boto3Python 스크립트를 생성합니다.
vi s3test.py파일에 다음 내용을 추가합니다.
구문
import boto3 endpoint = "" # enter the endpoint URL along with the port "http://URL:PORT" access_key = 'ACCESS' secret_key = 'SECRET' s3 = boto3.client( 's3', endpoint_url=endpoint, aws_access_key_id=access_key, aws_secret_access_key=secret_key ) s3.create_bucket(Bucket='my-new-bucket') response = s3.list_buckets() for bucket in response['Buckets']: print("{name}\t{created}".format( name = bucket['Name'], created = bucket['CreationDate'] ))-
endpoint를 게이트웨이 서비스를 구성한 호스트의 URL로 바꿉니다. 즉,게이트웨이 호스트입니다.호스트설정이 DNS로 확인되는지 확인합니다.PORT를 게이트웨이의 포트 번호로 바꿉니다. -
ACCESS및SECRET을 Red Hat Ceph Storage Object Gateway 가이드 의 S3 사용자 만들기 섹션의access_key및secret_key값으로 바꿉니다.
-
스크립트를 실행합니다.
python3 s3test.py출력은 다음과 같습니다.
my-new-bucket 2022-05-31T17:09:10.000Z