nodestore.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. Node Storage
  2. ============
  3. Sentry provides an abstraction called 'nodestore' which is used for
  4. storing key/value blobs.
  5. The default backend simply stores them as gzipped blobs in in the
  6. 'nodestore_node' table of your default database.
  7. Django Backend
  8. --------------
  9. The Django backend stores all data in the 'nodestore_node' table, using a
  10. the gzipped json blob-as-text pattern.
  11. The backend provides no options, so it should simply be set to an empty
  12. dict.
  13. .. code-block:: python
  14. SENTRY_NODESTORE = 'sentry.nodestore.django.DjangoNodeStorage'
  15. SENTRY_NODESTORE_OPTIONS = {}
  16. Riak Backend
  17. ------------
  18. Riak is the recommended backend for installations which have a large data
  19. consumption pattern, and would prefer to scale out, rather than scale up a
  20. single SQL node.
  21. Some notes on your Riak installation:
  22. - You will want to the ``leveldb`` backend as blobs are larger, and
  23. compression helps greatly.
  24. - Reads explicitly use ``r=1``.
  25. - We recommend ``n=2`` for replicas, but if the data isn't extremely
  26. important, ``n=1`` is fine.
  27. .. code-block:: python
  28. SENTRY_NODESTORE = 'sentry.nodestore.riak.RiakNodeStorage'
  29. SENTRY_NODESTORE_OPTIONS = {
  30. # specify each of your Riak nodes, or the address of your load balancer
  31. 'nodes': [
  32. {'host':'127.0.0.1','http_port':8098},
  33. ],
  34. # (optional) specify an alternative bucket name
  35. # 'bucket': 'nodes',
  36. # (optional) change the default resolver
  37. # 'resolver': riak.resolver.last_written_resolver
  38. }
  39. Cassandra Backend
  40. -----------------
  41. Cassandra is a horizontally scalable datastore in many of the same ways as
  42. Riak.
  43. The Sentry Cassandra backend only operates over the native CQL interface,
  44. so requires Cassandra 1.2+.
  45. .. code-block:: sql
  46. CREATE KEYSPACE sentry WITH replication = {
  47. 'class': 'SimpleStrategy',
  48. 'replication_factor': '2'
  49. };
  50. USE sentry;
  51. CREATE TABLE nodestore (
  52. key text PRIMARY KEY,
  53. flags int,
  54. value blob
  55. ) WITH
  56. compaction={'sstable_size_in_mb': '160', 'class': 'LeveledCompactionStrategy'} AND
  57. compression={'sstable_compression': 'SnappyCompressor'};
  58. .. code-block:: python
  59. SENTRY_NODESTORE = 'sentry.nodestore.cassandra.CassandraNodeStorage'
  60. SENTRY_NODESTORE_OPTIONS = {
  61. 'servers': [
  62. '127.0.0.1:9042',
  63. ],
  64. # (optional) specify an alternative keyspace
  65. # 'keyspace': 'sentry',
  66. # (optional) specify an alternative columnfamily
  67. # 'columnfamily': 'nodestore',
  68. }
  69. Custom Backends
  70. ---------------
  71. If you have a favorite data storage solution, it only has to operate under
  72. a few rules for it to work w/ Sentry's blob storage:
  73. - set key to value
  74. - get key
  75. - delete key
  76. For more information on implementating your own backend, take a look at
  77. ``sentry.nodestore.base.NodeStorage``.