Guest User

GR Docker

a guest
Mar 8th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.04 KB | None | 0 0
  1. wfranchi@computer:~$ for N in 1 2 3
  2. > do docker run -d --name=node$N --net=groupnet --hostname=node$N \
  3. > -e MYSQL_ROOT_PASSWORD=mypass \
  4. > mysql/mysql-server:8.0.15 \
  5. > --server-id=$N \
  6. > --log-bin=binlog \
  7. > --relay-log=node$N-relay-bin \
  8. > --binlog-format=ROW \
  9. > --enforce-gtid-consistency='ON' \
  10. > --log-slave-updates='ON' \
  11. > --gtid-mode='ON' \
  12. > --transaction-write-set-extraction='XXHASH64' \
  13. > --binlog-checksum='NONE' \
  14. > --master-info-repository='TABLE' \
  15. > --relay-log-info-repository='TABLE' \
  16. > --plugin-load='group_replication.so' \
  17. > --relay-log-recovery='ON' \
  18. > --group-replication-start-on-boot='OFF' \
  19. > --group-replication-group-name='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' \
  20. > --group-replication-local-address="node$N:33061" \
  21. > --group-replication-group-seeds='node1:33061,node2:33061,node3:33061'
  22. > done
  23. f934008c98b30f7eb696fc1088b6881f4d8e329d7a2d088e2e3b2388499a1f16
  24. 8dda0dc7a1b9d0c04eea30640736f061bfc42a0c010af9809f578e0b2658baa0
  25. e492dd28e84b1afb767bc03d72138143bfe387c98867a8c8476379e873163faf
  26.  
  27. wfranchi@computer:~$ docker ps -a
  28. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  29. e492dd28e84b mysql/mysql-server:8.0.15 "/entrypoint.sh --se…" 6 seconds ago Up 4 seconds (health: starting) 3306/tcp, 33060/tcp node3
  30. 8dda0dc7a1b9 mysql/mysql-server:8.0.15 "/entrypoint.sh --se…" 8 seconds ago Up 6 seconds (health: starting) 3306/tcp, 33060/tcp node2
  31. f934008c98b3 mysql/mysql-server:8.0.15 "/entrypoint.sh --se…" 9 seconds ago Up 8 seconds (health: starting) 3306/tcp, 33060/tcp node1
  32.  
  33. wfranchi@computer:~$ docker ps -a
  34. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  35. e492dd28e84b mysql/mysql-server:8.0.15 "/entrypoint.sh --se…" About a minute ago Up 59 seconds (healthy) 3306/tcp, 33060/tcp node3
  36. 8dda0dc7a1b9 mysql/mysql-server:8.0.15 "/entrypoint.sh --se…" About a minute ago Up About a minute (healthy) 3306/tcp, 33060/tcp node2
  37. f934008c98b3 mysql/mysql-server:8.0.15 "/entrypoint.sh --se…" About a minute ago Up About a minute (healthy) 3306/tcp, 33060/tcp node1
  38.  
  39. wfranchi@computer:~$ docker exec -it node1 mysql -uroot -pmypass \
  40. > -e "SET @@GLOBAL.group_replication_bootstrap_group=1;" \
  41. > -e "create user 'repl'@'%';" \
  42. > -e "GRANT REPLICATION SLAVE ON *.* TO repl@'%';" \
  43. > -e "flush privileges;" \
  44. > -e "change master to master_user='repl' for channel 'group_replication_recovery';" \
  45. > -e "START GROUP_REPLICATION;" \
  46. > -e "SET @@GLOBAL.group_replication_bootstrap_group=0;" \
  47. > -e "SELECT * FROM performance_schema.replication_group_members;"
  48. mysql: [Warning] Using a password on the command line interface can be insecure.
  49. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  50. | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
  51. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  52. | group_replication_applier | 956cb149-418d-11e9-a833-0242ac130002 | node1 | 3306 | RECOVERING | SECONDARY | 8.0.15 |
  53. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  54.  
  55. wfranchi@computer:~$ for N in 2 3
  56. > do docker exec -it node$N mysql -uroot -pmypass \
  57. > -e "change master to master_user='repl' for channel 'group_replication_recovery';" \
  58. > -e "START GROUP_REPLICATION;"
  59. > done
  60. mysql: [Warning] Using a password on the command line interface can be insecure.
  61. mysql: [Warning] Using a password on the command line interface can be insecure.
  62.  
  63. wfranchi@computer:~$ docker exec -it node1 mysql -uroot -pmypass \
  64. > -e "SELECT * FROM performance_schema.replication_group_members;"
  65. mysql: [Warning] Using a password on the command line interface can be insecure.
  66. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  67. | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
  68. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  69. | group_replication_applier | 956cb149-418d-11e9-a833-0242ac130002 | node1 | 3306 | ONLINE | PRIMARY | 8.0.15 |
  70. | group_replication_applier | 96d53dd7-418d-11e9-a3d9-0242ac130003 | node2 | 3306 | ONLINE | SECONDARY | 8.0.15 |
  71. | group_replication_applier | 9783f50c-418d-11e9-9ffc-0242ac130004 | node3 | 3306 | ONLINE | SECONDARY | 8.0.15 |
  72. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  73.  
  74. wfranchi@computer:~$ docker kill node3
  75. node3
  76.  
  77. wfranchi@computer:~$ docker exec -it node1 mysql -uroot -pmypass -e "SELECT * FROM performance_schema.replication_group_members;"
  78. mysql: [Warning] Using a password on the command line interface can be insecure.
  79. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  80. | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
  81. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  82. | group_replication_applier | 956cb149-418d-11e9-a833-0242ac130002 | node1 | 3306 | ONLINE | PRIMARY | 8.0.15 |
  83. | group_replication_applier | 96d53dd7-418d-11e9-a3d9-0242ac130003 | node2 | 3306 | ONLINE | SECONDARY | 8.0.15 |
  84. | group_replication_applier | 9783f50c-418d-11e9-9ffc-0242ac130004 | node3 | 3306 | ONLINE | SECONDARY | 8.0.15 |
  85. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  86.  
  87. wfranchi@computer:~$ docker exec -it node1 mysql -uroot -pmypass -e "SELECT * FROM performance_schema.replication_group_members;"
  88. mysql: [Warning] Using a password on the command line interface can be insecure.
  89. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  90. | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
  91. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  92. | group_replication_applier | 956cb149-418d-11e9-a833-0242ac130002 | node1 | 3306 | ONLINE | PRIMARY | 8.0.15 |
  93. | group_replication_applier | 96d53dd7-418d-11e9-a3d9-0242ac130003 | node2 | 3306 | ONLINE | SECONDARY | 8.0.15 |
  94. | group_replication_applier | 9783f50c-418d-11e9-9ffc-0242ac130004 | node3 | 3306 | UNREACHABLE | SECONDARY | 8.0.15 |
  95. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  96.  
  97. wfranchi@computer:~$ docker exec -it node1 mysql -uroot -pmypass -e "SELECT * FROM performance_schema.replication_group_members;"
  98. mysql: [Warning] Using a password on the command line interface can be insecure.
  99. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  100. | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
  101. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  102. | group_replication_applier | 956cb149-418d-11e9-a833-0242ac130002 | node1 | 3306 | ONLINE | PRIMARY | 8.0.15 |
  103. | group_replication_applier | 96d53dd7-418d-11e9-a3d9-0242ac130003 | node2 | 3306 | ONLINE | SECONDARY | 8.0.15 |
  104. +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
  105.  
  106. wfranchi@computer:~$ docker exec -it node1 mysql -uroot -pmypass -e "create database TEST; use TEST; CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, title VARCHAR(255) NOT NULL) ENGINE=InnoDB; show tables;"
  107. mysql: [Warning] Using a password on the command line interface can be insecure.
  108. +----------------+
  109. | Tables_in_TEST |
  110. +----------------+
  111. | t1 |
  112. +----------------+
  113.  
  114. wfranchi@computer:~$ docker exec -it node1 mysql -uroot -pmypass -e "INSERT INTO TEST.t1 VALUES(2,'hws2');"
  115. mysql: [Warning] Using a password on the command line interface can be insecure.
  116.  
  117. wfranchi@computer:~$ for N in 1 2
  118. > do docker exec -it node$N mysql -uroot -pmypass \
  119. > -e "SHOW VARIABLES WHERE Variable_name = 'hostname';" \
  120. > -e "SELECT * FROM TEST.t1;"
  121. > done
  122. mysql: [Warning] Using a password on the command line interface can be insecure.
  123. +---------------+-------+
  124. | Variable_name | Value |
  125. +---------------+-------+
  126. | hostname | node1 |
  127. +---------------+-------+
  128. +----+-------+
  129. | id | title |
  130. +----+-------+
  131. | 2 | hws2 |
  132. +----+-------+
  133. mysql: [Warning] Using a password on the command line interface can be insecure.
  134. +---------------+-------+
  135. | Variable_name | Value |
  136. +---------------+-------+
  137. | hostname | node2 |
  138. +---------------+-------+
  139. +----+-------+
  140. | id | title |
  141. +----+-------+
  142. | 2 | hws2 |
  143. +----+-------+
  144.  
  145. wfranchi@computer:~$
Add Comment
Please, Sign In to add comment