Guest User

Untitled

a guest
Jan 17th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. # NoSQL Docker demo
  2.  
  3. Here is a Docker compose file which starts redis, mongo, cassandra and neo4j containers for demonstration purposes.
  4.  
  5. ## Cluster
  6.  
  7. If you want to start all at once !
  8.  
  9. Start : `docker-compose up`
  10.  
  11. Dismount : `docker-compose down`
  12.  
  13. ## Redis
  14.  
  15. Run Redis server : `docker-compose run --rm --name myredis redis`
  16.  
  17. Connect to redis : `docker exec -it myredis redis-cli`
  18.  
  19. Interact :
  20.  
  21. ```
  22. ping
  23. ping "hello world"
  24.  
  25. set hello world
  26. get hello
  27.  
  28. keys *
  29.  
  30. incr next.recordings.id
  31.  
  32. sadd recordings:1:artist "Rolling Stones"
  33. sadd recordings:1:title "Beggars banquet"
  34. sadd recordings:1:price 9.99
  35.  
  36. keys *
  37.  
  38. smembers recordings:1:artist
  39. srem recordings:1:artist “Rolling Stones”
  40. ```
  41.  
  42. ## Mongo
  43.  
  44. Run Mongo server : `docker-compose run --rm --name mymongo mongo`
  45.  
  46. Connect to mongo : `docker exec -it mymongo mongo`
  47.  
  48. ```
  49. use rainforest
  50. album ={
  51. id:1,
  52. artist: "Rolling Stones",
  53. price: 9.99
  54. }
  55. db.recordings.insert(album)
  56. db.recordings.find()
  57. db.recordings.remove({id:1})
  58. db.recordings.find()
  59. ```
  60.  
  61. ## Cassandra
  62.  
  63. Run Cassandra server : `docker-compose run --rm --name mycassandra cassandra`
  64.  
  65. Connect to Cassandra : `docker exec -it mycassandra cqlsh`
  66.  
  67. ```
  68. CREATE KEYSPACE rainforest WITH replication = {'class':'SimpleStrategy', 'replication_factor':'1'};
  69. USE rainforest;
  70. CREATE COLUMNFAMILY recordings(
  71. title varchar PRIMARY KEY,
  72. artist varchar,
  73. price double);
  74. INSERT INTO recordings (title, artist, price) values ('Tattoo You', 'Stones', 9.99);
  75. Select * from recordings;
  76. CREATE INDEX ON recordings(artist);
  77. SELECT * from recordings where artist='Stones';
  78. ```
  79.  
  80. ## Neo4j
  81.  
  82. Run Neo4j server : `docker-compose run --rm --service-ports --name myneo4j neo4j`
  83.  
  84. Connect to Neo4j : `docker exec -it myneo4j cypher-shell`
  85.  
  86. ```
  87. CREATE (a { artist: 'Rolling Stones' });
  88. CREATE (t { title: 'Beggars Banquet' });
  89.  
  90. MATCH (a),(t)
  91. WHERE a.artist = 'Rolling Stones' AND t.title = 'Beggars Banquet'
  92. CREATE (a)-[r:ARTIST]->(t)
  93. RETURN r;
  94.  
  95. MATCH (rolling_stones)-[:ARTIST]-(recordings)
  96. WHERE rolling_stones.artist = 'Rolling Stones'
  97. RETURN recordings.title;
  98. ```
Add Comment
Please, Sign In to add comment