Guest User

Untitled

a guest
Dec 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. *********************************
  2.  
  3. ### Step one: bring up the cluster
  4.  
  5. asciinema rec
  6.  
  7. docker run --name Node_X -d scylladb/scylla
  8.  
  9. docker exec -it Node_X nodetool status
  10.  
  11. docker run --name Node_Y -d scylladb/scylla --seeds="$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' Node_X)"
  12.  
  13. docker exec -it Node_Y nodetool status
  14.  
  15. docker run --name Node_Z -d scylladb/scylla --seeds="$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' Node_X)"
  16.  
  17. docker exec -it Node_Z nodetool status
  18.  
  19. <CTRL + D>
  20.  
  21.  
  22.  
  23. *********************************
  24.  
  25. ### Note: Step two: Switch on tracing, create a new keyspace, switch to the keyspace, write with **CL=ALL** and read with **CL=QUORUM**
  26.  
  27. asciinema rec
  28.  
  29. docker exec -it Node_Z cqlsh
  30.  
  31. CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
  32.  
  33. use mykeyspace
  34.  
  35. ### WRITE CL = ALL
  36.  
  37. CONSISTENCY ALL
  38.  
  39. CREATE TABLE users(user_id int PRIMARY KEY, fname text, lname text);
  40. TRACING ON
  41. insert into users (user_id , fname, lname) values (1, 'tzach', 'livyatan'
  42.  
  43. ### WRITE CL = QUORUM
  44. CONSISTENCY QUORUM
  45. insert into users (user_id , fname, lname) values (2, 'john', 'hammink');
  46.  
  47. ### READ CL = QUORUM
  48. select * from users where user_id = 1;
  49. <CTRL + D>
  50.  
  51.  
  52. **********************************
  53.  
  54.  
  55. ### Step three: take a single node down, check status with ``nodetool``, attempt a write with different consistency levels
  56.  
  57. asciinema rec
  58.  
  59. docker stop Node_Y
  60.  
  61. sudo docker exec -it Node_Z nodetool status
  62.  
  63. docker exec -it Node_Z cqlsh
  64.  
  65. use mykeyspace;
  66.  
  67.  
  68. #### WRITE CL = ALL (fail)
  69.  
  70. CONSISTENCY ALL
  71.  
  72. insert into users (user_id , fname, lname) values (3, 'dor', 'laor');
  73.  
  74.  
  75. #### WRITE CL = QUORUM (maybe fail, maybe succeeds)
  76.  
  77. CONSISTENCY QUORUM
  78.  
  79. insert into users (user_id , fname, lname) values (4, 'philip', 'pribble');
  80.  
  81. <CTRL + D>
  82.  
  83.  
  84.  
  85.  
  86.  
  87. *********************************
  88.  
  89.  
  90. ### Step four: 2 nodes down, read and write with **QUORUM** and **One** consistency levels
  91.  
  92. asciinema rec
  93.  
  94. docker ps -a
  95.  
  96. docker stop Node_X
  97.  
  98. docker ps -a # Verify that there are two nodes down
  99.  
  100. docker exec -it Node_Z nodetool status
  101.  
  102. docker exec -it Node_Z cqlsh
  103.  
  104. #### WRITE CL = QUORUM (fail)
  105.  
  106. CONSISTENCY QUORUM
  107.  
  108. use mykeyspace;
  109.  
  110. insert into users (user_id , fname, lname) values (5, 'snarf', 'johnson');
  111.  
  112.  
  113. #### WRITE CL = ONE
  114.  
  115. CONSISTENCY ONE
  116.  
  117. insert into users (user_id , fname, lname) values (6, 'eric', 'cartman');
  118.  
  119. #### READ CL = ONE
  120.  
  121. select * from users;
  122.  
  123. select * from users where user_id = 1;
  124.  
  125. <CTRL + D>
  126.  
  127. ******************************************
  128. ##Environment:
  129. ##Clean up environment:
  130. docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
  131.  
  132. ##Or delete row
  133. cqlsh:mykeyspace> DELETE FROM users where user_id = 6;
  134. ##Or Drop table
  135. cqlsh:mykeyspace> drop table users;
  136. ##Or drop keyspace
  137. use system;
  138. DROP KEYSPACE mykeyspace;
Add Comment
Please, Sign In to add comment