Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gkorland committed Aug 18, 2024
1 parent 9da3696 commit 6c72ec2
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions persistence_replication.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ FalkorDB supports advanced configurations to enable data persistence and replica

Before you begin, ensure you have the following:

* Docker installed on your machine.
* A working FalkorDB Docker image. You can pull it from Docker Hub.
* Basic knowledge of Docker commands and configurations.
* Docker installed on your machine.
* A working FalkorDB Docker image. You can pull it from Docker Hub.
* Basic knowledge of Docker commands and configurations.

## Step 1: Setting Up Persistence

Expand All @@ -36,16 +36,13 @@ This volume will be used to store the database files.
You can now run FalkorDB with the volume attached:

```bash
docker run -d \
--name falkordb \
-v falkordb_data:/data \
falkordb/falkordb
docker run -d --name falkordb -v falkordb_data:/data -p 6379:6379 falkordb/falkordb
```

In this configuration:

The -v falkordb_data:/data flag mounts the volume to the /data directory inside the container.
FalkorDB will use this directory to store its data.
The -v falkordb_data:/data flag mounts the volume to the /data directory inside the container.
FalkorDB will use this directory to store its data.

## Step 2: Configuring Replication

Expand All @@ -61,13 +58,14 @@ docker run -d \
-v falkordb_data:/data \
-e REPLICATION_MODE=master \
-e REPLICATION_ID=master1 \
-p 6379:6379 \
falkordb/falkordb
```

Here:

The -e REPLICATION_MODE=master flag sets this instance as the master.
The -e REPLICATION_ID=master1 assigns a unique ID to the master.
The -e REPLICATION_MODE=master flag sets this instance as the master.
The -e REPLICATION_ID=master1 assigns a unique ID to the master.

### 2.2 Configuring the Replica Instances

Expand All @@ -79,40 +77,41 @@ docker run -d \
-e REPLICATION_MODE=replica \
-e REPLICATION_MASTER_HOST=falkordb-master \
-e REPLICATION_ID=replica1 \
-p 6379:6379 \
falkordb/falkordb
```

In this setup:

* The -e REPLICATION_MODE=replica flag sets the instance as a replica.
* The -e REPLICATION_MASTER_HOST=falkordb-master flag specifies the master instance's hostname or IP address.
* The -e REPLICATION_ID=replica1 assigns a unique ID to this replica.
* The -e REPLICATION_MODE=replica flag sets the instance as a replica.
* The -e REPLICATION_MASTER_HOST=falkordb-master flag specifies the master instance's hostname or IP address.
* The -e REPLICATION_ID=replica1 assigns a unique ID to this replica.

You can add additional replicas by repeating the command with different container names and REPLICATION_IDs.

## Step 3: Verifying the Setup

To verify that your setup is working correctly:

* Persistence Check: Stop the FalkorDB container and start it again. The data should persist across restarts.
* Persistence Check: Stop the FalkorDB container and start it again. The data should persist across restarts.

```bash
docker stop falkordb
docker start falkordb
docker stop falkordb
docker start falkordb
```

* Replication Check: Insert some data into the master instance and check if it is available in the replica.
* Replication Check: Insert some data into the master instance and check if it is available in the replica.

```bash
# Connect to the master
docker exec -it falkordb-master /bin/bash
falkordb-cli set key "Hello, FalkorDB!"
exit

# Connect to the replica
docker exec -it falkordb-replica1 /bin/bash
falkordb-cli get key
# Output should be "Hello, FalkorDB!"
# Connect to the master
docker exec -it falkordb-master /bin/bash
falkordb-cli set key "Hello, FalkorDB!"
exit

# Connect to the replica
docker exec -it falkordb-replica1 /bin/bash
falkordb-cli get key
# Output should be "Hello, FalkorDB!"
```

## Conclusion
Expand Down

0 comments on commit 6c72ec2

Please sign in to comment.