Skip to content

Commit

Permalink
Add mongodb credential
Browse files Browse the repository at this point in the history
  • Loading branch information
hiepmai-babylonchain committed Jul 17, 2024
1 parent 52e7087 commit db36e88
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ cat $OUTPUT | jq . > $FINAL
This script clones the Babylon networks repository,
navigates to the specified directory,
iterate over JSON files and
append them to the output filecontaining Finality provider information.
append them to the output file containing all Finality provider information.

This script only uses the registry information maintained by Babylon.
Other such registries might exist,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ replication:
replSetName: "rs0"
```

This process instructs MongoDB to start up
as part of the specified replica set (`rs0` in this case).

### 2.3 Restart MongoDB to apply changes

```bash
Expand All @@ -44,8 +47,14 @@ sudo systemctl restart mongod

### 2.4 Initialize the replica set

Start the MongoDB shell and connect to the installed MongoDB instance
running on `localhost` at port `27017`

If your MongoDB server is running on a different host or port,
you can specify them using the --host and --port options respectively.

```bash
mongosh
mongosh --host localhost --port 27017
```

Inside the MongoDB shell, run:
Expand All @@ -60,7 +69,76 @@ rs.initiate()
rs.status()
```

## 3. Monitoring
The output of `rs.status()` will include information like:

- `Set Name` (set): The name of the replica set.
- `Members` (members): List of replica set members (members array)
with details such as `hostname`, `state` (stateStr), `health` (health),
`uptime` (uptime), and `last heartbeat message` (lastHeartbeatMessage).

Here’s a simplified example of how the output look like:


```json
set: 'rs0',
members: [
{
_id: 0,
name: '127.0.0.1:27017',
health: 1,
state: 1,
stateStr: 'PRIMARY',
uptime: 1202009,
optime: { ts: Timestamp({ t: 1721191458, i: 1 }), t: Long('1') },
optimeDate: ISODate('2024-07-17T04:44:18.000Z'),
lastAppliedWallTime: ISODate('2024-07-17T04:44:18.441Z'),
lastDurableWallTime: ISODate('2024-07-17T04:44:18.441Z'),
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
electionTime: Timestamp({ t: 1719989484, i: 2 }),
electionDate: ISODate('2024-07-03T06:51:24.000Z'),
configVersion: 1,
configTerm: 1,
self: true,
lastHeartbeatMessage: ''
}
]
```

## 3. Create MongoDB credentials

:::info Note

The exact credentials will later be used by the services to connect to the queues.

:::

Start the MongoDB shell and connect to the installed MongoDB instance
running on `localhost` at port `27017`

If your MongoDB server is running on a different host or port,
you can specify them using the --host and --port options respectively.

```bash
mongosh --host localhost --port 27017
```

Inside the MongoDB shell, run the following commands to create a new user::

```text
use admin
db.createUser({
user: "<username>",
pwd: "<password>",
roles: [ { role: "readWrite", db: "<database>" } ]
})
```

Replace `"<username>"`, `"<password>"`, and `"<database>"`
with your desired username, password, and database name respectively.

## 4. Monitoring

The MongoDB server availability can be polled through
[Prometheus Blackbox Exporter](https://github.com/prometheus/blackbox_exporter).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ Replace `<admin>` with your desired username and `<password>` with your desired

### 2.3 Access the RabbitMQ Management Dashboard

Open your web browser and navigate to: `http://localhost:15672/`
Open your web browser and navigate to
the `default` RabbitMQ Management Dashboard
: `http://localhost:15672/`

Log in with the username `<admin>` and the password `<password>`
that is set from the above step.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ cp ~/staking-api-service/config/config-local.yml ~/.staking-api-service/config.y
- MongoDB cluster to connect to

Set the MongoDB connection address (`address`)
and credentials (`username` and `password`) to match
and credentials (`username`, `password`, and `db-name`) to match
the information from the
[installed MongoDB cluster](../infra/mongodb.md).

```yml
db:
address: "mongodb://localhost:27017/?directConnection=true"
username: "<admin>"
username: "<username>"
password: "<password>"
db-name: "<db-name>"
```
- RabbitMQ cluster to connect to
Expand All @@ -68,6 +69,16 @@ queue:
url: "localhost:5672"
```

- Prometheus metrics configuration:

Set the `host` and `port` to customize how the metrics are exposed

```yml
metrics:
host: 0.0.0.0
port: 2112
```

## 3. Download global params

To run the Staking API, a `global-params.json` file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cp ~/staking-expiry-checker/config/config-local.yml ~/.staking-expiry-checker/co
- MongoDB cluster to connect to

Set the MongoDB connection address (`address`)
and credentials (`username` and `password`) to match
and credentials (`username`, `password`, and `db-name`) to match
the information from the
[installed MongoDB cluster](../infra/mongodb.md).

Expand All @@ -47,6 +47,7 @@ db:
username: "<admin>"
password: "<password>"
address: "mongodb://localhost:27017/?directConnection=true"
db-name: "<db-name>"
```
- Bitcoin node to connect to
Expand Down Expand Up @@ -79,6 +80,16 @@ queue:
url: "localhost:5672"
```

- Prometheus metrics configuration:

Set the `host` and `port` to customize how the metrics are exposed

```yml
metrics:
host: 0.0.0.0
port: 2112
```

## 3. Start Staking Expiry Checker

You can start the staking-expiry-checker by running:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ Password = password
Url = localhost:5672
```

- Prometheus metrics configuration:

Set the `Host` and `Port` to customize how the metrics are exposed

```text
[metricsconfig]
; IP of the Prometheus server
Host = 127.0.0.1
; Port of the Prometheus server
Port = 2112
```

## 3. Download global params

To download the global parameters,
Expand Down

0 comments on commit db36e88

Please sign in to comment.