Arangodb - Hands-On Labs - Section a - Arangodb Fundamentals
Arangodb - Hands-On Labs - Section a - Arangodb Fundamentals
TRAINING
Hands On Labs
Version 0.7
1.1 CREDENTIALS.................................................................................................... 2
1.2 LICENSE KEY.................................................................................................... 2
1.3 LIST OF ENVIRONMENTS...................................................................................... 3
2.1 INSTALLATION.................................................................................................. 4
SECTION A
2.1.1 L A-1: I
AB Y B .....................................................................................4
NSTALL OUR INARIES
A
2.1.2 L A-2: E
RANGO
AB
2.1.3 L A-3: S
AB
DB
R
F A ..................................................................................5
UNDAMENTALS
NABLE EMOTE CCESS
...............................................................................6
ECURE YOUR DEPLOYMENT
Page 1 of 26
4 SECTION II: ARANGODB OPERATIONS...................................................................... 24
Page 2 of 26
ARANGODB TRAINING: HANDS-ON LABS
1.1 CREDENTIALS
Use the following credentials to log in to the lab environments.
1.2LICENSE KEY
NOTE: Instructor to paste the latest license key here. The validUntil
needs to be at least until the last day of the training
{
"license":
"eyJncmFudCI6ImV5Sm1aV0YwZFhKbGN5STZleUpFWVhSaFUyTnBaVz
VqWlZCaFkydGhaMlVpT25zaVptVmhkSFZ5WlhNaU9sc2lSM0poY0doT
lRDSmRmU3dpZG1semRXRnNhWHBsY2lJNmV5SjFjMlZ5Y3lJNk1UQjlM
Q0psZUhCcGNtVnpJam94TnpRMk1EZ3lOems1ZlN3aWJtOTBRbVZtYjN
KbElqb2lNakF5TlMwd05DMHdOMVF4Tnpvd01Ub3lObG9pTENKdWIzUk
Page 3 of 26
ARANGODB TRAINING: HANDS-ON LABS
JablJsY2lJNklqSXdNalV0TURVdE1ERlVNRFk2TlRrNk5UbGFJaXdpY
zNWaWFtVmpkQ0k2ZXlKbGJXRnBiQ0k2SWlCeVlXcDFRR0pzZFdWd1lX
d3VZMjl0SW4wc0ltbHpjM1ZsY2lJNmV5SmpiMjF3WVc1NUlqb2lRWEp
oYm1kdlJFSWdSMjFpU0NJc0ltNWhiV1VpT2lKVWFXeHNiV0Z1SUVScG
MzTmxiR3RoYlhBaUxDSmxiV0ZwYkNJNkluUnBiRzFoYmk1a2FYTnpaV
3hyWVcxd1FHRnlZVzVuYjJSaUxtTnZiU0o5TENKamRYTjBiMjFsY2lJ
NmV5SnVZVzFsSWpvaVFteDFaWEJoYkNJc0ltVnVkbWx5YjI1dFpXNTB
Jam9pVUdGeWRHNWxjaUJVY21GcGJtbHVaeUlzSW05bGJTSTZJaUo5TE
NKMlpYSnphVzl1SWpveGZRPT0iLCJzaWduYXR1cmUiOiJHcTJsV2pKa
ndrYVdYTlQ4Mk0wRmlyK2xFRkZXM0lyODNZWTBlallXQi9oKzk3bGVN
cnlSdjZUQkJFV1IzWWNsV3FjU1ZzRktJSWwrUVQ0bHFGSktVS21Idm0
1QTZUcGdUR1FDUGtmM3RPRkp1T2JuTUlmYXRuci9ydkZ6dWRJODFwUE
k3R3RaeXYyWVQwN0ZIbXRpRTF5YWRWNTZkYWU0bGJWcnp1UEprWXEyR
245N1dwTEFvampzaHl0WEhMVWdVL3JrYW1wb1Fuc1ZUWjhrbkVmbjRX
ZTJZdzRaZllnUnJlaVpqejJNVkNJQkQxektxbmFJRzI4azVNRHhqODE
1YS96cnVKZW11bkc5VHNidXBTSzNGUkdjVWdnVndpV25VUlg2OXF1Sk
VaMlJhUzd3TE45b1NBY0plVlgzQ3dWWkM5T1RNSkZUSE1JSzZVNDFSb
U9sbWc9PSJ9",
"validUntil": "2024-08-18T23:59:59Z",
"validUntilLocal": "8/18/2024",
"daysToExpiry": 24
}
1.3LIST OF ENVIRONMENTS
Please enter your name against one of the nodes in the google sheet
here
Page 4 of 26
ARANGODB TRAINING: HANDS-ON LABS
2 ARANGODB FUNDAMENTALS
2.1INSTALLATION
curl -L http://localhost:8529
6. Next try accessing the arangodb instance remotely by entering
the following url into your browser
http://<your hostname>:8529
7. The host access should fail
Page 5 of 26
ARANGODB TRAINING: HANDS-ON LABS
sudo vi /etc/arangodb3/arangod.conf
3. Edit the following line:
a. Original Line:
endpoint = tcp://127.0.0.1:8529
b. Edited Line:
endpoint = tcp://0.0.0.0:8529
4. Make sure you are editing the line which is not commented i.e.
does not start with #
http://<your hostname>:8529
Page 6 of 26
ARANGODB TRAINING: HANDS-ON LABS
sudo arango-secure-installation
4. Specify and confirm your ‘root’ password once requested
http://<your hostname>:8529
7. Login with the password you just specified for root
Page 7 of 26
ARANGODB TRAINING: HANDS-ON LABS
arangosh
3. Enter your root password when prompted
127.0.0.1:8529@_system> db._setLicense("<your
license key>")
5. Note: The license key is the value of the attribute “license” in
Section 1.2. Please DO NOT select the whole JSON.
http://<your hostname>:8529
Page 8 of 26
ARANGODB TRAINING: HANDS-ON LABS
3. Verify the username being used and the database you are
connected to.
Page 9 of 26
ARANGODB TRAINING: HANDS-ON LABS
8. Explore other sections of the interface (you will need them later)
1. Confirm you have docker running on your system and you have
the right permissions
docker ps
2. Run the following command to start the docker deployment
docker ps
4. Confirm you can access the WebUI via your browser. Note the
extra 1 in the port number.
http://<your hostname>:18529
Page 10 of 26
ARANGODB TRAINING: HANDS-ON LABS
5. Login with the credentials to make sure that you can log into the
instance
NOTE:
1. You need your own fully configured K8s environment for this
lab, along with the requisite permissions for K8s
2. Currently ArangoDB does not provide a lab environment for a
K8s deployment (coming in the future)
1. Confirm you have kubectl install and all the requisite permissions
to apply yaml to the k8s cluster
https://github.com/arangodb/kube-arangodb/tree/master/examples
Page 11 of 26
ARANGODB TRAINING: HANDS-ON LABS
1. Check with
docker ps
if the docker container is still running. Stop it if necessary.
Starter 1:
arangodb --starter.data-dir=data/db1 --
starter.mode=cluster
--auth.jwt-secret=secrets/arangodb.secret --
starter.port=18528 --starter.join=localhost:18528
[CTRL]+Z; bg 1
Page 12 of 26
ARANGODB TRAINING: HANDS-ON LABS
Starter 2:
arangodb --starter.data-dir=data/db2 --
starter.mode=cluster
--auth.jwt-secret=secrets/arangodb.secret --
starter.port=28528 --starter.join=localhost:18528
Starter 3:
arangodb --starter.data-dir=data/db3 --
starter.mode=cluster
--auth.jwt-secret=secrets/arangodb.secret --
starter.port=38528 --starter.join=localhost:18528
3. The Starter uses the next few ports above the Starter port for the
cluster nodes. If you use port 8528 for the Starter
Page 13 of 26
ARANGODB TRAINING: HANDS-ON LABS
--server.password "" \
--javascript.execute-string
'require("@arangodb/users").update("root",
"$umm3r$un");'
8. Next connect to the arangosh
ps -ef|grep arangodb
12. You should be able to see the following:
a. 3 Starter processes
b. 3 DB Server Subprocesses
c. 3 Coordinator Subprocesses
d. 3 Agency subprocesses
pstree <pid> -a
Page 14 of 26
ARANGODB TRAINING: HANDS-ON LABS
14. Note: To simulate the scenario, all processes and starters were
started on the same machine; this is great for development. In
production, however, you will end up deploying these processes
on different machines.
--cluster.my-role DBSERVER
--agency.activate true
4. Click Save
Page 15 of 26
ARANGODB TRAINING: HANDS-ON LABS
5. Click the _SYSTEM link on the top right to switch to the newly
created database
6. Choose test from the screen and click the green Select DB:test
button
Page 16 of 26
ARANGODB TRAINING: HANDS-ON LABS
7. Create a collection
Page 17 of 26
ARANGODB TRAINING: HANDS-ON LABS
10. Copy the _id field from the result and use it to access the
document and get only the last name
RETURN DOCUMENT("mycollection/33780").lname
11. BONUS:
a. Navigate to COLLECTIONS
b. Click mycollection
c. Click Content
1. You can either use the local arangosh installed on your training
server or choose to install the client tools locally on your machine.
The client tools can be found here:
https://arangodb.com/download/
Page 18 of 26
ARANGODB TRAINING: HANDS-ON LABS
2. Once you have installed the client you can use arangosh to
connect to a deployment
arangosh --help
7. Let's go through a few basic usage steps
8. To create a database
localhost:18529@_system> db._createDatabase("mydb");
9. To use the created database
localhost:18529@_system> db._useDatabase("mydb");
10. To get additional help:
localhost:18529@_system> db._help();
11. To run a for loop:
localhost:18529@_system> for (var i = 0; i < 10; i ++) {
...> require("@arangodb").print("Hello world " + i + "!\n");
Page 19 of 26
ARANGODB TRAINING: HANDS-ON LABS
...> }
12. BONUS: (See: JavaScript API)
e. Truncate mycollection
Page 20 of 26
ARANGODB TRAINING: HANDS-ON LABS
Page 21 of 26
ARANGODB TRAINING: HANDS-ON LABS
localhost:28529@_system> db._useDatabase("testdb")
localhost:28529@testdb> db._create("mycollection",
{ replicationFactor: 4 },
{ enforceReplicationFactor: false });
7. Does it work? Why? Whats happening in the back end?
Page 22 of 26
ARANGODB TRAINING: HANDS-ON LABS
RETURN DECODE_REV("_h_59XG6--A")
11. What does the output show? What timezone is the output?
NOTE: Revision Ids are meant for optimistic locking and debugging
only please do not build business logic on the decoded value, the
implementation may change in the future
Page 23 of 26
ARANGODB TRAINING: HANDS-ON LABS
3. Run the query again without changing the revision id, does the
query work? Why ?
Page 24 of 26
ARANGODB TRAINING: HANDS-ON LABS
15. Review the primary index – type primary, not sparse, 100%
selectivity, with _key as the indexed attribute and cannot be
deleted
Page 25 of 26