이 페이지에서는 Ranger 클러스터의 Dataproc에서 Ranger 스키마를 백업하고 복원하는 방법을 보여줍니다.
시작하기 전에
필요한 경우 버킷을 만듭니다. Ranger 스키마를 저장하고 복원하는 데 사용할 Cloud Storage 버킷에 액세스할 수 있어야 합니다.
버킷을 만드는 방법은 다음과 같습니다.
- In the Google Cloud console, go to the Cloud Storage Buckets page.
- Click Create.
- On the Create a bucket page, enter your bucket information. To go to the next
step, click Continue.
-
In the Get started section, do the following:
- Enter a globally unique name that meets the bucket naming requirements.
- To add a
bucket label,
expand the Labels section ( ),
click add_box
Add label, and specify a
key
and avalue
for your label.
-
In the Choose where to store your data section, do the following:
- Select a Location type.
- Choose a location where your bucket's data is permanently stored from the Location type drop-down menu.
- If you select the dual-region location type, you can also choose to enable turbo replication by using the relevant checkbox.
- To set up cross-bucket replication, select
Add cross-bucket replication via Storage Transfer Service and
follow these steps:
Set up cross-bucket replication
- In the Bucket menu, select a bucket.
In the Replication settings section, click Configure to configure settings for the replication job.
The Configure cross-bucket replication pane appears.
- To filter objects to replicate by object name prefix, enter a prefix that you want to include or exclude objects from, then click Add a prefix.
- To set a storage class for the replicated objects, select a storage class from the Storage class menu. If you skip this step, the replicated objects will use the destination bucket's storage class by default.
- Click Done.
-
In the Choose how to store your data section, do the following:
- Select a default storage class for the bucket or Autoclass for automatic storage class management of your bucket's data.
- To enable hierarchical namespace, in the Optimize storage for data-intensive workloads section, select Enable hierarchical namespace on this bucket.
- In the Choose how to control access to objects section, select whether or not your bucket enforces public access prevention, and select an access control method for your bucket's objects.
-
In the Choose how to protect object data section, do the
following:
- Select any of the options under Data protection that you
want to set for your bucket.
- To enable soft delete, click the Soft delete policy (For data recovery) checkbox, and specify the number of days you want to retain objects after deletion.
- To set Object Versioning, click the Object versioning (For version control) checkbox, and specify the maximum number of versions per object and the number of days after which the noncurrent versions expire.
- To enable the retention policy on objects and buckets, click the Retention (For compliance) checkbox, and then do the following:
- To enable Object Retention Lock, click the Enable object retention checkbox.
- To enable Bucket Lock, click the Set bucket retention policy checkbox, and choose a unit of time and a length of time for your retention period.
- To choose how your object data will be encrypted, expand the Data encryption section (Data encryption method. ), and select a
- Select any of the options under Data protection that you
want to set for your bucket.
-
In the Get started section, do the following:
- Click Create.
Ranger 스키마 백업
SSH를 사용하여 Ranger 스키마가 있는 클러스터의 Dataproc 마스터 노드에 연결합니다. 마스터 노드에서 실행 중인 SSH 터미널 세션에서 이 섹션의 명령어를 실행합니다.
환경 변수를 설정합니다.
BUCKET_NAME=bucket name \ MYSQL_PASSWORD=MySQL password SCHEMA_FILE=schema filename
다음을 바꿉니다.
MySQL password: 클러스터 마스터 노드에서
/etc/mysql/my.cnf
를 열어 MySQL 비밀번호를 복사할 수 있습니다.bucket name: Ranger 스키마를 저장하는 데 사용할 Cloud Storage 버킷의 이름입니다.
schema filename:
.sql
파일 이름 확장자가 없는 파일 이름을 지정합니다. Ranger 스키마는 마스터 노드에서 이 파일에 저장된 다음, Cloud Storage의 bucket name에 저장됩니다.
Hive 서비스를 중지합니다.
sudo systemctl stop hive-metastore.service sudo systemctl stop hive-server2.service
Ranger 스키마 테이블 변경을 방지합니다.
mysql -u root -p${MYSQL_PASSWORD} REVOKE ALL PRIVILEGES ON ranger.* from 'rangeradmin'@'localhost'; GRANT SELECT ON ranger.* TO 'rangeradmin'@'localhost'; FLUSH PRIVILEGES; SHOW GRANTS FOR 'rangeradmin'@'localhost'; exit;
Ranger 스키마를
.sql
파일에 저장합니다.mysqldump -u root -p${MYSQL_PASSWORD} ranger > ${SCHEMA_FILE}.sql
Ranger 권한을 재설정합니다.
mysql -u root -p${MYSQL_PASSWORD} REVOKE SELECT ON ranger.* from 'rangeradmin'@'localhost'; GRANT ALL PRIVILEGES ON ranger.* to 'rangeradmin'@'localhost'; FLUSH PRIVILEGES; SHOW GRANTS FOR 'rangeradmin'@'localhost'; exit;
Hive 및 Ranger 서비스를 다시 시작합니다.
sudo systemctl start hive-metastore.service sudo systemctl start hive-server2.service sudo systemctl restart ranger-admin.service sudo systemctl restart ranger-usersync.service
Ranger 스키마를 Cloud Storage에 복사합니다.
gcloud storage cp ${SCHEMA_FILE}.sql gs://${BUCKET_NAME}
Ranger 스키마 복원
SSH를 사용하여 클러스터 스키마를 복원할 클러스터의 Dataproc 마스터 노드에 연결합니다. 마스터 노드에서 실행 중인 SSH 터미널 세션에서 이 섹션의 명령어를 실행합니다.
환경 변수를 설정합니다.
BUCKET_NAME=bucket name \ MYSQL_PASSWORD=MySQL password SCHEMA_FILE=schema filename
다음을 바꿉니다.
MySQL password: 클러스터 마스터 노드에서
/etc/mysql/my.cnf
를 열어 MySQL 비밀번호를 복사할 수 있습니다.bucket name: 저장된 Ranger 스키마가 포함된 Cloud Storage 버킷의 이름입니다.
schema filename: Cloud Storage의 bucket name에 저장된
.sql
파일 확장자가 없는 Ranger 스키마 파일 이름입니다.
Hive 서비스를 중지합니다.
sudo systemctl stop hive-metastore.service sudo systemctl stop hive-server2.service
Ranger 스키마 테이블 변경을 방지합니다.
mysql -u root -p${MYSQL_PASSWORD} REVOKE ALL PRIVILEGES ON ranger.* from 'rangeradmin'@'localhost'; GRANT SELECT ON ranger.* TO 'rangeradmin'@'localhost'; FLUSH PRIVILEGES; SHOW GRANTS FOR 'rangeradmin'@'localhost'; exit;
Cloud Storage의 Ranger 스키마
.sql
파일을 클러스터 마스터 노드에 복사합니다.gcloud storage cp ${BUCKET_NAME}/${SCHEMA_FILE}.sql .
Ranger 스키마를 복원합니다. 이 단계에서는 기존 Ranger 스키마의 콘텐츠를 덮어씁니다.
mysqldump -u root -p${MYSQL_PASSWORD} ranger < ${SCHEMA_FILE}.sql
Ranger 권한을 재설정합니다.
mysql -u root -p${MYSQL_PASSWORD} REVOKE SELECT ON ranger.* from 'rangeradmin'@'localhost'; GRANT ALL PRIVILEGES ON ranger.* to 'rangeradmin'@'localhost'; FLUSH PRIVILEGES; SHOW GRANTS FOR 'rangeradmin'@'localhost'; exit;
Ranger 구성 파일을 업데이트합니다. 다음 파일에서 다음 속성으로 Ranger DB 호스트를 새 데이터베이스 호스트 이름으로 변경합니다.
파일 속성 ranger-hdfs-security.xml
ranger.plugin.hdfs.policy.rest.url
ranger-yarn-security.xml
ranger.plugin.yarn.policy.rest.url
Hive 및 Ranger 서비스를 다시 시작합니다.
sudo systemctl start hive-metastore.service sudo systemctl start hive-server2.service sudo systemctl restart ranger-admin.service sudo systemctl restart ranger-usersync.service