# Pbm-agent keep failing on Primary node on a mongodb replicaset of 3 nodes

**URL:** <https://forums.percona.com/t/pbm-agent-keep-failing-on-primary-node-on-a-mongodb-replicaset-of-3-nodes/29038>\
**Category:** Percona Backup for MongoDB\
**Created:** [March 8, 2024, 2:39pm UTC](https://forums.percona.com/t/pbm-agent-keep-failing-on-primary-node-on-a-mongodb-replicaset-of-3-nodes/29038 "2024-03-08T14:39:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![felembe](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@felembe](https://forums.percona.com/u/felembe)\
**Post date:** [March 8, 2024, 2:39pm UTC](https://forums.percona.com/t/pbm-agent-keep-failing-on-primary-node-on-a-mongodb-replicaset-of-3-nodes/29038/1 "2024-03-08T14:39:10Z")

</div>

Hello,  
pbm-agent keep failing on the primary node with the following error in /var/log/message

Mar 8 14:18:23 uk11lmdb24as pbm-agent[2452361]: 2024/03/08 14:18:23 Exit: connect to PBM: create mongo connection: mongo ping: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: }

Below pbm version  
pbm version  
Version: 2.1.0  
Platform: linux/amd64  
GitCommit: 342b5b9c996e8bd17a678ea0cecbf2eaaf9704ab  
GitBranch: release-2.1.0  
BuildTime: 2023-04-14\_12:23\_UTC  
GoVersion: go1.19

MongoDB version is 5.0.18-15

The pbm-agent is running on the 2 secondary nodes with the same PBM\_MONGODB\_URI in /etc/default/pbm-agent  
And when I run the command backup --type=logical I get the following  
Starting backup ‘2024-03-08T12:45:32Z’…Error: no progress from leader, backup metadata not found

Looking at this eror one of your advise is to ensure that the agent is running on all nodes  
Can you please assist to have the agent running on the primary or is there any workaround?

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [March 8, 2024, 3:34pm UTC](https://forums.percona.com/t/pbm-agent-keep-failing-on-primary-node-on-a-mongodb-replicaset-of-3-nodes/29038/2 "2024-03-08T15:34:21Z")

</div>

Hi, first of all I’d advise you to upgrade to the latest version of PBM since it has some interesting new features as well as bug fixes. One aspect that can be confusing is that pbm agent and pbm client need actually different URIs. I believe this might be related to your issue.  
The pbm agent always points at the local node, for example:

```auto
tee /etc/default/pbm-agent <<EOF
PBM_MONGODB_URI="mongodb://pbmuser:secretpwd@localhost:27017"
EOF

```

Differently, the pbm client (the command line program you run to interact with the pbm service) should be pointed at the replica set URI, for example:

```auto
export PBM_MONGODB_URI="mongodb://pbmuser:secretpwd@server1:27017,server2:27017/?replicaSet=testRPL"

```

hope that helps

---

<div class="post-metadata">

**Author:** ![felembe](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@felembe](https://forums.percona.com/u/felembe)\
**Post date:** [March 8, 2024, 4:53pm UTC](https://forums.percona.com/t/pbm-agent-keep-failing-on-primary-node-on-a-mongodb-replicaset-of-3-nodes/29038/3 "2024-03-08T16:53:47Z")

</div>

Hi Ivan and thanks for your reply  
I would prefer to upgrade later after fixing this issue as for now the agent is able work on secondary

I have updated /etc/default/pbm-agent with  
PBM\_MONGODB\_URI=“mongodb://pbmuser:@localhost:27017”

instead of  
PBM\_MONGODB\_URI=“mongodb://pbmuser:paaasowrd@localhost:27017/?authSource=admin&replicaSet=RepName”  
as it is on the other 2 nodes currently secondary

The agent is running successfully on secondary nodes and still failing on primary

Below 2 lines I am able to see on the mongodb log of the primary related to the agent when I attempt to start the agent if this could help.

Could you please advise

{“t”:{“$date”:“2024-03-08T16:40:01.720+00:00”},“s”:“I”, “c”:“NETWORK”, “id”:51800, “ctx”:“conn3706”,“msg”:“client metadata”,“attr”:{“remote”:“127.0.0.1:58146”,“client”:“conn3706”,“doc”:{“driver”:{“name”:“mongo-go-driver”,“version”:“v1.11.2”},“os”:{“type”:“linux”,“architecture”:“amd64”},“platform”:“go1.19”,“application”:{“name”:“pbm-agent”}}}}  
{“t”:{“$date”:“2024-03-08T16:40:01.721+00:00”},“s”:“I”, “c”:“NETWORK”, “id”:51800, “ctx”:“conn3707”,“msg”:“client metadata”,“attr”:{“remote”:“127.0.0.1:58154”,“client”:“conn3707”,“doc”:{“driver”:{“name”:“mongo-go-driver”,“version”:“v1.11.2”},“os”:{“type”:“linux”,“architecture”:“amd64”},“platform”:“go1.19”,“application”:{“name”:“pbm-agent”}}}}

---

<div class="post-metadata">

**Author:** ![felembe](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@felembe](https://forums.percona.com/u/felembe)\
**Post date:** [March 12, 2024, 12:31pm UTC](https://forums.percona.com/t/pbm-agent-keep-failing-on-primary-node-on-a-mongodb-replicaset-of-3-nodes/29038/4 "2024-03-12T12:31:50Z")

</div>

I manage to get the agent started by updating the file /etc/sysconfig/pbm-agent instead with the PBM\_MONGODB\_URI value
