13th August 2024

How to setup mongo in repl set mode for prisma on arch linux?

Install bin version, mongo from source will compile even few hours


```

yay -S mongodb-bin

```


start / enable `mongodb.service`


```

sudo systemctl enable mongodb.service

sudo systemctl start mongodb.service

```

optionally check status

```

sudo systemctl status mongodb.service

```

connect to mongo

```
mongosh
```


By default replicaset is disabled. You can confirm it in `mongosh`

```

rs.status()

MongoServerError[NoReplicationEnabled]: not running with --replSet
```

Now time to change settings:

```

sudo nvim /etc/mongodb.conf

```


replace

```
#replcation:
```

by

```

replication:

  replSetName: "rs0"


```


restart mongo service


```

sudo systemctl restart mongodb.service

```


now you can see different error


```

rs.status()

MongoServerError[NotYetInitialized]: no replset config has been received

```


so lets init replicaset


```

rs.initiate()

{

  info2: 'no configuration specified. Using a default configuration for the set',

  me: '127.0.0.1:27017',

  ok: 1

}

```


Finally rs.status() works correctly.