Utiliser Ranger avec la mise en cache et la réduction du champ d'application
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Activer la mise en cache
Cette section décrit les étapes à suivre pour activer la mise en cache avec Ranger afin de réduire les allers-retours du système de gestion des clés (KMS) Ranger pour chiffrer et déchiffrer les jetons.
Installez memcached sur les VM du cluster Dataproc. Par défaut, le serveur Memcached démarre sur le port 11211 de la VM (localhost:11211).
sudo apt-get install -y memcached
Définissez les propriétés suivantes dans le fichier de configuration /etc/dataproc-ranger-gcs-plugin/conf/ranger-gcs-site.xml de Ranger sur les VM du cluster Dataproc.
Réduire le champ d'application des jetons d'accès Cloud Storage
Vous devrez peut-être réduire le champ d'application des jetons d'accès Ranger pour augmenter le champ d'application (upscope) des chemins Cloud Storage vers lesquels pointe une table Hive externe.
Pour déplacer toutes les partitions et sous-partitions au niveau de la table, définissez la propriété downscope.table.partition-name.pruning.enabled sur true dans le fichier de configuration ranger-gcs-site.xml sur les VM du cluster Dataproc.
Chemin d'accès d'origine du jeton : warehouse/hive/table/type=debit/year=2017/month=Aug/day=01/
Après avoir défini downscope.table.partition-name.pruning.enabled sur true, chemin d'accès au jeton d'accès étendu : warehouse/hive/table/
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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`."]]