Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Caching aktivieren
In diesem Abschnitt werden die Schritte zum Aktivieren des Cachings mit Ranger aufgeführt, um die Anzahl der Roundtrips des Ranger Key Management System (KMS) zum Verschlüsseln und Entschlüsseln von Tokens zu reduzieren.
Installieren Sie memcached auf Dataproc-Cluster-VMs. Standardmäßig wird der Memcached-Server auf dem VM-Port 11211 (localhost:11211) gestartet.
sudo apt-get install -y memcached
Legen Sie die folgenden Attribute in der Ranger-Konfigurationsdatei /etc/dataproc-ranger-gcs-plugin/conf/ranger-gcs-site.xml auf den VMs des Dataproc-Clusters fest.
Möglicherweise müssen Sie Ranger-Zugriffstokens einschränken, um die Cloud Storage-Pfade, auf die eine externe Hive-Tabelle verweist, zu erweitern.
Wenn Sie alle Partitionen und Unterpartitionen auf die Tabellenebene verschieben möchten, legen Sie die Eigenschaft downscope.table.partition-name.pruning.enabled in der Konfigurationsdatei ranger-gcs-site.xml auf Dataproc-Cluster-VMs auf true fest.
Pfad des ursprünglichen Zugriffstokens: warehouse/hive/table/type=debit/year=2017/month=Aug/day=01/
Nachdem Sie downscope.table.partition-name.pruning.enabled auf true festgelegt haben, ist der Pfad zum Zugriffstoken mit erweitertem Umfang: warehouse/hive/table/
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eRanger caching, available on Dataproc Compute Engine image versions 2.0.92 and later, can be enabled by installing \u003ccode\u003ememcached\u003c/code\u003e, configuring the \u003ccode\u003eranger-gcs-site.xml\u003c/code\u003e file with caching properties, and restarting the authorization service.\u003c/p\u003e\n"],["\u003cp\u003eYou can check the status of the Ranger cache using \u003ccode\u003etelnet\u003c/code\u003e to connect to \u003ccode\u003ememcached\u003c/code\u003e, then use commands like \u003ccode\u003estats items\u003c/code\u003e and \u003ccode\u003estats cachedump\u003c/code\u003e to get details about the cache content and \u003ccode\u003eflush_all\u003c/code\u003e to invalidate the cache.\u003c/p\u003e\n"],["\u003cp\u003eRanger access tokens for Cloud Storage can be downscoped by setting the \u003ccode\u003edownscope.table.partition-name.pruning.enabled\u003c/code\u003e property to \u003ccode\u003etrue\u003c/code\u003e in the \u003ccode\u003eranger-gcs-site.xml\u003c/code\u003e file to move partitions and subpartitions up to the table level.\u003c/p\u003e\n"]]],[],null,["# Use Ranger with caching and downscoping\n\n| **Objective:** Learn how to use Ranger properties to enable caching and downscoping on a Dataproc cluster.\n\nEnable caching\n--------------\n\nThis section lists the steps to enable caching with Ranger in order to reduce\nRanger Key Management System (KMS) round trips to encrypt and decrypt\ntokens.\n| **Note:** Ranger caching is available with Dataproc on Compute Engine image versions starting with image version `2.0.92`.\n\n1. Install [`memcached`](https://memcached.org/) on Dataproc\n cluster VMs. By default, the memcached server starts on VM port 11211 (`localhost:11211`).\n\n ```\n sudo apt-get install -y memcached\n ```\n\n \u003cbr /\u003e\n\n2. Set the following properties in the `/etc/dataproc-ranger-gcs-plugin/conf/ranger-gcs-site.xml`\n Ranger config file on Dataproc cluster VMs.\n\n ```\n \u003cproperty\u003e\n \u003cname\u003eauthorization.service.remoteCaching.address\u003c/name\u003e\n \u003cvalue\u003elocalhost:11211\u003c/value\u003e\n \u003c/property\u003e\n\n \u003cproperty\u003e\n \u003cname\u003eauthorization.service.remoteCaching.class\u003c/name\u003e\n \u003cvalue\u003ecom.google.cloud.hadoop.ranger.gcs.authorization.caching.MemcachedCache\u003c/value\u003e\n \u003c/property\u003e\n\n \u003cproperty\u003e\n \u003cname\u003eauthorization.service.remoteCaching.encryption.key.uri\u003c/name\u003e\n \u003cvalue\u003egcp-kms://projects/PROJECT_ID_OF_KMS_KEY/locations/REGION/keyRings/KEYRING_NAME/cryptoKeys/KEY_NAME\u003c/value\u003e\n \u003c/property\u003e\n ```\n\n \u003cbr /\u003e\n\n3. Restart the authorization service.\n\n ```\n sudo systemctl restart ranger-gcs-plugin-authorization-server\n ```\n\n \u003cbr /\u003e\n\n### View cache status\n\nYou can use [`telnet`](https://en.wikipedia.org/wiki/Telnet) to view Ranger\ncache status.\n\n1. Install `telnet`.\n\n ```\n sudo apt-get install -y telnet\n ```\n\n \u003cbr /\u003e\n\n2. Use telnet to connect to `memcache` on VM port `11211`.\n\n ```\n sudo telnet 127.0.0.1 11211\n ```\n\n \u003cbr /\u003e\n\n3. Use `telnet` commands to view cache status, including the following commands:\n\n - `stats items`: List the status of cache items. Sample output: \n\n ```\n STAT items:17:number 2\n STAT items:17:number_hot 0\n STAT items:17:number_warm 0\n STAT items:17:number_cold 2\n ```\n - `stats cachedump`: List keys stored in the cache. Sample output: \n\n ```\n stats cachedump 17 2\n ITEM 0616eeeeb54e23a09505da5bf75cd7fafe733eacf0d07bd7b1ac9cf46d17c188 [3051 b; 1707948281 s]\n ITEM d23645df9c79290d59ddb1b9710ff04fee37aa0b5de866b9b6d56b54641d68b4 [3078 b; 1707948281 s]\n ```\n - `flush_all`: Invalidate cache items.\n\nDownscope Cloud Storage access tokens\n-------------------------------------\n\nYou might need to downscope Ranger access tokens to move up (upscope) the\nCloud Storage paths that an external Hive table points to.\n\nTo move all partitions and subpartitions up to the table level,\nset the `downscope.table.partition-name.pruning.enabled`\nproperty to `true` in the `ranger-gcs-site.xml` config file on Dataproc\ncluster VMs. \n\n```\n\u003cproperty\u003e\n \u003cname\u003edownscope.table.partition-name.pruning.enabled\u003c/name\u003e\n \u003cvalue\u003etrue\u003c/value\u003e\n\u003c/property\u003e\n```\n\nExample:\n\n- Cloud Storage bucket name: `gs://warehouse`\n- Original access token path: `warehouse/hive/table/type=debit/year=2017/month=Aug/day=01/`\n- After setting `downscope.table.partition-name.pruning.enabled` to `true`, upscoped access token path: `warehouse/hive/table/`\n\n| **Note:** You can verify access token paths in the `/var/log/ranger-gcs-plugin-authorization-server.log` when `log4j.properties` is set to `debug`."]]