|
| 1 | +#start afresh processes and db |
| 2 | +./cleanup.sh |
| 3 | +mysql -h 127.0.0.1 -P 19327 -u msandbox --password=msandbox commerce < sql/create_commerce_schema.sql |
| 4 | +mysql -h 127.0.0.1 -P 19327 -u msandbox --password=msandbox commerce < sql/insert_commerce_data.sql |
| 5 | + |
| 6 | + |
| 7 | +#asciinema demo starts |
| 8 | +source ./env.sh |
| 9 | +mysql -h 127.0.0.1 -P 19327 -u msandbox --password=msandbox commerce -e "select * from corder;select * from customer;select * from product;" |
| 10 | + |
| 11 | +# start topology, vtctld and vtgate |
| 12 | +scripts/etcd-up.sh |
| 13 | +scripts/vtctld-up.sh |
| 14 | +scripts/vtgate-up.sh |
| 15 | + |
| 16 | +#Start unmanaged tablet in keyspace commerce |
| 17 | +scripts/unmanaged.sh |
| 18 | + |
| 19 | +#Start vitess cluster in keyspace customer |
| 20 | +for i in 200 201 202; do |
| 21 | + CELL=zone1 TABLET_UID=$i ./scripts/mysqlctl-up.sh |
| 22 | + CELL=zone1 KEYSPACE=customer TABLET_UID=$i ./scripts/vttablet-up.sh |
| 23 | +done |
| 24 | + |
| 25 | +vtctlclient InitShardMaster -force customer/0 zone1-200 |
| 26 | + |
| 27 | +# start vreplication workflow |
| 28 | +vtctlclient MoveTables -tablet_types=MASTER -workflow=commerce2customer commerce customer customer,corder |
| 29 | + |
| 30 | +# use vdiff to confirm replication has taken plae |
| 31 | +vtctlclient VDiff customer.commerce2customer |
| 32 | + |
| 33 | +# insert row and show that we are syncing |
| 34 | +vtctlclient VExec customer.commerce2customer "select id,workflow,state,pos from _vt.vreplication" |
| 35 | + |
| 36 | +mysql -h 127.0.0.1 -P 19327 -u msandbox --password=msandbox commerce -e "insert into customer(email) values ('[email protected]');" |
| 37 | +vtctlclient VExec customer.commerce2customer "select id,workflow,state,pos from _vt.vreplication" |
| 38 | + |
| 39 | + |
| 40 | +echo ">>>>>> Step 6. Calling SwitchReads" |
| 41 | +vtctlclient SwitchReads -tablet_type=rdonly customer.commerce2customer |
| 42 | +vtctlclient SwitchReads -tablet_type=replica customer.commerce2customer |
| 43 | +sleep 5 |
| 44 | +echo ">>>>>> Step 7. Calling SwitchWrites" |
| 45 | +vtctlclient SwitchWrites customer.commerce2customer |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +vtctlclient VExec commerce.commerce2customer_reverse "select id,workflow,state,pos from _vt.vreplication" |
| 50 | + |
| 51 | +echo ">>>>> Step 8. Run VDiff after inserting data into the customer keyspace" |
| 52 | +sleep 15 |
| 53 | +mysql -h 127.0.0.1 -P 15306 -u msandbox --password=msandbox customer < sql/insert_commerce_data_after_switch.sql |
| 54 | + |
| 55 | + |
| 56 | +echo "Steps for rolling back" |
| 57 | +vtctlclient VExec commerce.commerce2customer_reverse "select id,workflow,state,pos from _vt.vreplication" |
| 58 | + |
| 59 | +echo ">>>>>> Step 9. Rollback SwitchReads" |
| 60 | +vtctlclient SwitchReads -tablet_type=rdonly commerce.commerce2customer_reverse |
| 61 | +vtctlclient SwitchReads -tablet_type=replica commerce.commerce2customer_reverse |
| 62 | + |
| 63 | +echo ">>>>>> Step 10. Rollback SwitchWrites" |
| 64 | +vtctlclient SwitchWrites commerce.commerce2customer_reverse |
| 65 | + |
| 66 | +echo ">>>>>> Rolled back to original setup. VReplication is still running on Vitess cluster, so you can still move forward ..." |
| 67 | + |
| 68 | + |
| 69 | +mysql -h 127.0.0.1 -P 19327 -u msandbox --password=msandbox commerce < sql/insert_commerce_data_after_rollback.sql |
| 70 | + |
| 71 | +vtctlclient VDiff customer.commerce2customer |
| 72 | + |
| 73 | +echo ">>>>>>>>> ALL DONE" |
0 commit comments