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 addAdd 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 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 (expand_more), and select a
Data encryption method.
Click Create.
Fazer backup de um esquema do Ranger
Use SSH para se conectar
ao nó mestre do Dataproc do cluster com o esquema do Ranger.
Execute os comandos desta seção na sessão do terminal SSH em execução no nó mestre.
Defina variáveis de ambiente.
BUCKET_NAME=bucket name \
MYSQL_PASSWORD=MySQL password
SCHEMA_FILE=schema filename
Substitua:
MySQL password: abra /etc/mysql/my.cnf no nó principal do cluster para copiar a senha do MySQL.
bucket name: o nome do bucket do Cloud Storage a ser usado para armazenar o esquema do Ranger.
schema filename: especifique um nome de arquivo sem a extensão .sql. O esquema do Ranger é salvo
nesse arquivo no nó principal e depois em bucket name
no Cloud Storage .
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;
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;
Use SSH para se conectar
ao nó mestre do Dataproc do cluster em que você
vai restaurar o esquema do cluster.
Execute os comandos desta seção na sessão do terminal SSH em execução no nó mestre.
Defina variáveis de ambiente.
BUCKET_NAME=bucket name \
MYSQL_PASSWORD=MySQL password
SCHEMA_FILE=schema filename
Substitua:
MySQL password: abra /etc/mysql/my.cnf no nó principal do cluster para copiar a senha do MySQL.
bucket name: o nome do bucket do Cloud Storage
que contém o esquema salvo do Ranger.
schema filename: o nome do arquivo de esquema do Ranger
sem a extensão .sql, salvo em
bucket name no Cloud Storage.
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;
Copie o arquivo de esquema do Ranger .sql no Cloud Storage para o nó principal do cluster.
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;
Atualize os arquivos de configuração do Ranger. Mude o host do banco de dados do Ranger para um novo nome de host do banco de dados nos seguintes arquivos com as seguintes propriedades:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-22 UTC."],[[["\u003cp\u003eThis page details how to back up and restore a Ranger schema on Dataproc with Ranger clusters, requiring a Cloud Storage bucket for storage.\u003c/p\u003e\n"],["\u003cp\u003eBacking up involves connecting to the Dataproc master node via SSH, setting environment variables, stopping Hive services, saving the schema to an \u003ccode\u003e.sql\u003c/code\u003e file, and copying it to Cloud Storage.\u003c/p\u003e\n"],["\u003cp\u003eRestoring requires connecting to the Dataproc master node via SSH, setting environment variables, stopping Hive services, and copying the schema \u003ccode\u003e.sql\u003c/code\u003e file from Cloud Storage to the cluster.\u003c/p\u003e\n"],["\u003cp\u003eBoth processes involve temporarily preventing changes to the Ranger schema tables and resetting Ranger privileges, and restarting Hive and Ranger services.\u003c/p\u003e\n"],["\u003cp\u003eRestoring the Ranger schema will overwrite the contents of the existing Ranger schema, and it may be required to update ranger configuration files.\u003c/p\u003e\n"]]],[],null,["# Back up and restore a Ranger schema\n\nThis page shows you how to back up and restore a Ranger schema on\n[Dataproc with Ranger clusters](/dataproc/docs/concepts/components/ranger).\n\nBefore you begin\n----------------\n\n1. Create a bucket if needed. You must have access to a Cloud Storage bucket,\n which you will use to store and restore a Ranger schema.\n\n To create a bucket:\n\n\n 1. In the Google Cloud console, go to the Cloud Storage **Buckets** page.\n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n 2. Click add_box **Create**.\n 3. On the **Create a bucket** page, enter your bucket information. To go to the next step, click **Continue** .\n 1. In the **Get started** section, do the following:\n - Enter a globally unique name that meets the [bucket naming requirements](/storage/docs/bucket-naming#requirements).\n - To add a [bucket label](/storage/docs/tags-and-labels#bucket-labels), expand the **Labels** section (expand_more), click *add_box* **Add label** , and specify a `key` and a `value` for your label.\n 2. In the **Choose where to store your data** section, do the following:\n 1. Select a [Location type](/storage/docs/locations).\n 2. Choose a location where your bucket's data is permanently stored from the **[Location type](/storage/docs/locations#available-locations)** drop-down menu.\n - If you select the [dual-region](/storage/docs/locations#location-dr) location type, you can also choose to enable [turbo replication](/storage/docs/availability-durability#turbo-replication) by using the relevant checkbox.\n 3. To set up [cross-bucket replication](/storage/docs/availability-durability#cross-bucket-replication), select **Add cross-bucket replication via Storage Transfer Service** and follow these steps: \n\n #### Set up cross-bucket replication\n\n 1. In the **Bucket** menu, select a bucket.\n 2. In the **Replication settings** section,\n click **Configure** to configure settings for the\n replication job.\n\n The **Configure cross-bucket replication** pane\n appears.\n - To filter objects to replicate by object name prefix, enter a prefix that you want to include or exclude objects from, then click add **Add a prefix**.\n - 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.\n - Click **Done**.\n 3. In the **Choose how to store your data** section, do the following:\n 1. Select a [default storage class](/storage/docs/storage-classes) for the bucket or [Autoclass](/storage/docs/autoclass) for automatic storage class management of your bucket's data.\n 2. To enable [hierarchical namespace](/storage/docs/hns-overview), in the **Optimize storage for data-intensive workloads** section, select **Enable hierarchical namespace on this bucket** . **Note:** You cannot enable hierarchical namespace in existing buckets.\n 4. In the **Choose how to control access to objects** section, select whether or not your bucket enforces [public access prevention](/storage/docs/public-access-prevention), and select an [access control method](/storage/docs/access-control) for your bucket's objects. **Note:** You cannot change the **Prevent public access** setting if this setting is enforced at an [organization policy](/storage/docs/org-policy-constraints#public-access-prevention).\n 5. In the **Choose how to protect object data** section, do the following:\n - Select any of the options under **Data protection** that you want to set for your bucket.\n - To enable [soft delete](/storage/docs/soft-delete), click the **Soft delete policy (For data recovery)** checkbox, and specify the number of days you want to retain objects after deletion.\n - To set [Object Versioning](/storage/docs/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.\n - To enable the retention policy on objects and buckets, click the **Retention (For compliance)** checkbox, and then do the following:\n - To enable [Object Retention Lock](/storage/docs/object-lock), click the **Enable object retention** checkbox.\n - To enable [Bucket Lock](/storage/docs/bucket-lock), click the **Set bucket retention policy** checkbox, and choose a unit of time and a length of time for your retention period.\n - To choose how your object data will be encrypted, expand the **Data encryption** section (expand_more), and select a [**Data encryption** method](/storage/docs/encryption).\n 4. Click **Create**.\n\n \u003cbr /\u003e\n\nBack up a Ranger schema\n-----------------------\n\n1. Use [SSH](/dataproc/docs/concepts/accessing/ssh) to connect\n to the Dataproc master node of the cluster with the Ranger schema.\n **Run the commands in this section in the SSH terminal session running on\n the master node.**\n\n2. Set environment variables.\n\n ```\n BUCKET_NAME=bucket name \\\n MYSQL_PASSWORD=MySQL password\n SCHEMA_FILE=schema filename\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eMySQL password\u003c/var\u003e: You can open `/etc/mysql/my.cnf` on the cluster\n master node to copy the MySQL password.\n\n - \u003cvar translate=\"no\"\u003ebucket name\u003c/var\u003e: The name of the Cloud Storage bucket to\n use to store the Ranger schema.\n\n - \u003cvar translate=\"no\"\u003eschema filename\u003c/var\u003e: Specify a filename,\n without the `.sql` filename extension. The Ranger schema is saved\n to this file on the master node, then saved in \u003cvar translate=\"no\"\u003ebucket name\u003c/var\u003e\n in Cloud Storage .\n\n3. Stop Hive services.\n\n ```\n sudo systemctl stop hive-metastore.service\n sudo systemctl stop hive-server2.service\n ```\n\n \u003cbr /\u003e\n\n4. Prevent changes to the Ranger schema tables.\n\n ```\n mysql -u root -p${MYSQL_PASSWORD}\n REVOKE ALL PRIVILEGES ON ranger.* from 'rangeradmin'@'localhost';\n GRANT SELECT ON ranger.* TO 'rangeradmin'@'localhost';\n FLUSH PRIVILEGES;\n SHOW GRANTS FOR 'rangeradmin'@'localhost';\n exit;\n ```\n5. Save the Ranger schema to an `.sql` file.\n\n ```\n mysqldump -u root -p${MYSQL_PASSWORD} ranger \u003e ${SCHEMA_FILE}.sql\n ```\n6. Reset Ranger privileges.\n\n ```\n mysql -u root -p${MYSQL_PASSWORD}\n REVOKE SELECT ON ranger.* from 'rangeradmin'@'localhost';\n GRANT ALL PRIVILEGES ON ranger.* to 'rangeradmin'@'localhost';\n FLUSH PRIVILEGES;\n SHOW GRANTS FOR 'rangeradmin'@'localhost';\n exit;\n ```\n7. Restart Hive and Ranger services.\n\n ```\n sudo systemctl start hive-metastore.service\n sudo systemctl start hive-server2.service\n sudo systemctl restart ranger-admin.service\n sudo systemctl restart ranger-usersync.service\n ```\n8. Copy the Ranger schema to Cloud Storage.\n\n ```\n gcloud storage cp ${SCHEMA_FILE}.sql gs://${BUCKET_NAME}\n ```\n\nRestore a Ranger schema\n-----------------------\n\n| **Note:** If you back up then restore the schema to same cluster, you may be able to use the SSH session and environment variables used in your [Ranger schema backup session](#back_up_a_ranger_schema).\n\n1. Use [SSH](/dataproc/docs/concepts/accessing/ssh) to connect\n to the Dataproc master node of the cluster where you\n will restore the cluster schema.\n **Run the commands in this section in the SSH terminal session running on\n the master node.**\n\n2. Set environment variables.\n\n ```\n BUCKET_NAME=bucket name \\\n MYSQL_PASSWORD=MySQL password\n SCHEMA_FILE=schema filename\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eMySQL password\u003c/var\u003e: You can open `/etc/mysql/my.cnf` on the cluster\n master node to copy the MySQL password.\n\n - \u003cvar translate=\"no\"\u003ebucket name\u003c/var\u003e: The name of the Cloud Storage bucket\n that contains the saved Ranger schema.\n\n - \u003cvar translate=\"no\"\u003eschema filename\u003c/var\u003e: The name of the Ranger schema\n filename, without the `.sql` filename extension, saved in\n \u003cvar translate=\"no\"\u003ebucket name\u003c/var\u003e in Cloud Storage.\n\n3. Stop Hive services.\n\n ```\n sudo systemctl stop hive-metastore.service\n sudo systemctl stop hive-server2.service\n ```\n\n \u003cbr /\u003e\n\n4. Prevent changes to the Ranger schema tables.\n\n ```\n mysql -u root -p${MYSQL_PASSWORD}\n REVOKE ALL PRIVILEGES ON ranger.* from 'rangeradmin'@'localhost';\n GRANT SELECT ON ranger.* TO 'rangeradmin'@'localhost';\n FLUSH PRIVILEGES;\n SHOW GRANTS FOR 'rangeradmin'@'localhost';\n exit;\n ```\n5. Copy the Ranger schema `.sql` file in Cloud Storage to the cluster\n master node.\n\n ```\n gcloud storage cp ${BUCKET_NAME}/${SCHEMA_FILE}.sql .\n ```\n6. Restore the Ranger schema. **This step overwrites the contents of the\n existing Ranger schema.**\n\n ```\n mysqldump -u root -p${MYSQL_PASSWORD} ranger \u003c ${SCHEMA_FILE}.sql\n ```\n7. Reset Ranger privileges.\n\n ```\n mysql -u root -p${MYSQL_PASSWORD}\n REVOKE SELECT ON ranger.* from 'rangeradmin'@'localhost';\n GRANT ALL PRIVILEGES ON ranger.* to 'rangeradmin'@'localhost';\n FLUSH PRIVILEGES;\n SHOW GRANTS FOR 'rangeradmin'@'localhost';\n exit;\n ```\n8. Update Ranger configuration files. Change the Ranger DB host to a new\n database hostname in the following files with the following properties:\n\n9. Restart Hive and Ranger services.\n\n ```\n sudo systemctl start hive-metastore.service\n sudo systemctl start hive-server2.service\n sudo systemctl restart ranger-admin.service\n sudo systemctl restart ranger-usersync.service\n ```"]]