Halaman ini menunjukkan cara mencadangkan dan memulihkan skema Ranger di cluster Dataproc dengan Ranger.
Sebelum memulai
Buat bucket jika perlu. Anda harus memiliki akses ke bucket Cloud Storage, yang akan Anda gunakan untuk menyimpan dan memulihkan skema Ranger.
Untuk membuat bucket:
- 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.
Mencadangkan skema Ranger
Gunakan SSH untuk terhubung ke node master Dataproc dari cluster dengan skema Ranger. Jalankan perintah di bagian ini dalam sesi terminal SSH yang berjalan di node master.
Menetapkan variabel lingkungan.
BUCKET_NAME=bucket name \ MYSQL_PASSWORD=MySQL password SCHEMA_FILE=schema filename
Ganti kode berikut:
MySQL password: Anda dapat membuka
/etc/mysql/my.cnf
di node master cluster untuk menyalin sandi MySQL.bucket name: Nama bucket Cloud Storage yang akan digunakan untuk menyimpan skema Ranger.
schema filename: Tentukan nama file, tanpa ekstensi nama file
.sql
. Skema Ranger disimpan ke file ini di node master, lalu disimpan di bucket name di Cloud Storage .
Hentikan layanan Hive.
sudo systemctl stop hive-metastore.service sudo systemctl stop hive-server2.service
Mencegah perubahan pada tabel skema 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;
Simpan skema Ranger ke file
.sql
.mysqldump -u root -p${MYSQL_PASSWORD} ranger > ${SCHEMA_FILE}.sql
Reset hak istimewa 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;
Mulai ulang layanan Hive dan 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
Salin skema Ranger ke Cloud Storage.
gcloud storage cp ${SCHEMA_FILE}.sql gs://${BUCKET_NAME}
Memulihkan skema Ranger
Gunakan SSH untuk terhubung ke node master Dataproc dari cluster tempat Anda akan memulihkan skema cluster. Jalankan perintah di bagian ini dalam sesi terminal SSH yang berjalan di node master.
Menetapkan variabel lingkungan.
BUCKET_NAME=bucket name \ MYSQL_PASSWORD=MySQL password SCHEMA_FILE=schema filename
Ganti kode berikut:
MySQL password: Anda dapat membuka
/etc/mysql/my.cnf
di node master cluster untuk menyalin sandi MySQL.bucket name: Nama bucket Cloud Storage yang berisi skema Ranger yang disimpan.
schema filename: Nama file skema Ranger, tanpa ekstensi nama file
.sql
, yang disimpan di bucket name di Cloud Storage.
Hentikan layanan Hive.
sudo systemctl stop hive-metastore.service sudo systemctl stop hive-server2.service
Mencegah perubahan pada tabel skema 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;
Salin file skema Ranger
.sql
di Cloud Storage ke node master cluster.gcloud storage cp ${BUCKET_NAME}/${SCHEMA_FILE}.sql .
Pulihkan skema Ranger. Langkah ini akan menggantikan konten skema Ranger yang ada.
mysqldump -u root -p${MYSQL_PASSWORD} ranger < ${SCHEMA_FILE}.sql
Reset hak istimewa 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;
Perbarui file konfigurasi Ranger. Ubah host Ranger DB ke nama host database baru di file berikut dengan properti berikut:
File Properti ranger-hdfs-security.xml
ranger.plugin.hdfs.policy.rest.url
ranger-yarn-security.xml
ranger.plugin.yarn.policy.rest.url
Mulai ulang layanan Hive dan 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