|
| 1 | +# Run ArangoDB Starter with DC2DC locally |
| 2 | + |
| 3 | +This example shows how to run an ArangoDB cluster using the Starter locally (twice) with datacenter |
| 4 | +to datacenter replication between the 2 clusters. |
| 5 | + |
| 6 | +Note: This example shares secrets between clusters, so it is NOT suitable for any kind of production use! |
| 7 | + |
| 8 | +## Step 1: Create certificates & tokens |
| 9 | + |
| 10 | +```bash |
| 11 | +export CERTDIR=<directories where to store certificates & tokens> |
| 12 | +export IP=<IP address of this machine> |
| 13 | +mkdir -p ${CERTDIR} |
| 14 | + |
| 15 | +# Create TLS certificates |
| 16 | +arangodb create tls ca --cert=${CERTDIR}/tls-ca.crt --key=${CERTDIR}/tls-ca.key |
| 17 | +arangodb create tls keyfile --cacert=${CERTDIR}/tls-ca.crt --cakey=${CERTDIR}/tls-ca.key --keyfile=${CERTDIR}/cluster1/tls.keyfile --host=${IP} --host=localhost |
| 18 | +arangodb create tls keyfile --cacert=${CERTDIR}/tls-ca.crt --cakey=${CERTDIR}/tls-ca.key --keyfile=${CERTDIR}/cluster2/tls.keyfile --host=${IP} --host=localhost |
| 19 | + |
| 20 | +# Create client authentication certificates |
| 21 | +arangodb create client-auth ca --cert=${CERTDIR}/client-auth-ca.crt --key=${CERTDIR}/client-auth-ca.key |
| 22 | +arangodb create client-auth keyfile --cacert=${CERTDIR}/client-auth-ca.crt --cakey=${CERTDIR}/client-auth-ca.key --keyfile=${CERTDIR}/client-auth-ca.keyfile |
| 23 | + |
| 24 | +# Create JWT secrets |
| 25 | +arangodb create jwt-secret --secret=${CERTDIR}/cluster1/syncmaster.jwtsecret |
| 26 | +arangodb create jwt-secret --secret=${CERTDIR}/cluster1/arangodb.jwtsecret |
| 27 | +arangodb create jwt-secret --secret=${CERTDIR}/cluster2/syncmaster.jwtsecret |
| 28 | +arangodb create jwt-secret --secret=${CERTDIR}/cluster2/arangodb.jwtsecret |
| 29 | +``` |
| 30 | + |
| 31 | +## Step 2: Start first & second cluster |
| 32 | + |
| 33 | +```bash |
| 34 | +export DATADIR=<directories where to store database files> |
| 35 | +mkdir -p ${DATADIR} |
| 36 | + |
| 37 | +arangodb --starter.data-dir=/${DATADIR}/cluster1 \ |
| 38 | + --starter.sync \ |
| 39 | + --starter.local \ |
| 40 | + --auth.jwt-secret=${CERTDIR}/cluster1/arangodb.jwtsecret \ |
| 41 | + --sync.server.keyfile=${CERTDIR}/cluster1/tls.keyfile \ |
| 42 | + --sync.server.client-cafile=${CERTDIR}/client-auth-ca.crt \ |
| 43 | + --sync.master.jwt-secret=${CERTDIR}/cluster1/syncmaster.jwtsecret \ |
| 44 | + --starter.address=${IP} |
| 45 | + |
| 46 | +## In another terminal |
| 47 | +export DATADIR=<directories where to store database files> |
| 48 | + |
| 49 | +arangodb --starter.data-dir=/${DATADIR}/cluster2 \ |
| 50 | + --starter.sync \ |
| 51 | + --starter.local \ |
| 52 | + --auth.jwt-secret=${CERTDIR}/cluster2/arangodb.jwtsecret \ |
| 53 | + --sync.server.keyfile=${CERTDIR}/cluster2/tls.keyfile \ |
| 54 | + --sync.server.client-cafile=${CERTDIR}/client-auth-ca.crt \ |
| 55 | + --sync.master.jwt-secret=${CERTDIR}/cluster2/syncmaster.jwtsecret \ |
| 56 | + --starter.address=${IP} \ |
| 57 | + --starter.port=9528 |
| 58 | +``` |
| 59 | + |
| 60 | +Note that it is not uncommon for a syncmaster to restart, since the cluster is not yet ready when it is started. |
| 61 | + |
| 62 | +## Step 3: Configure synchronization from cluster 1 to cluster 2 |
| 63 | + |
| 64 | +```bash |
| 65 | +arangosync configure sync \ |
| 66 | + --master.endpoint=https://${IP}:9542 \ |
| 67 | + --master.keyfile=${CERTDIR}/client-auth-ca.keyfile \ |
| 68 | + --source.endpoint=https://${IP}:8542 \ |
| 69 | + --source.cacert=${CERTDIR}/tls-ca.crt \ |
| 70 | + --auth.keyfile=${CERTDIR}/client-auth-ca.keyfile |
| 71 | +``` |
| 72 | + |
| 73 | +## Step 4: Check status of configuration |
| 74 | + |
| 75 | +```bash |
| 76 | +# Check status of cluster 1 |
| 77 | +arangosync get status \ |
| 78 | + --master.endpoint=https://${IP}:8542 \ |
| 79 | + --auth.keyfile=${CERTDIR}/client-auth-ca.keyfile \ |
| 80 | + --verbose |
| 81 | + |
| 82 | +# Check status of cluster 2 |
| 83 | +arangosync get status \ |
| 84 | + --master.endpoint=https://${IP}:9542 \ |
| 85 | + --auth.keyfile=${CERTDIR}/client-auth-ca.keyfile \ |
| 86 | + --verbose |
| 87 | +``` |
0 commit comments