gravitl / netmaker

Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.
https://netmaker.io
Other
9.5k stars 552 forks source link

Non-Docker install - how to interpret the errors output by: journalctl -u netmaker #124

Closed bmullan closed 3 years ago

bmullan commented 3 years ago

Still following the Non-Docker installation.

Any idea what "might" be causing the error provided by - journalctl -u netmaker

I know the userID and password are correctly entered.

thanks

$ sudo journalctl -u netmaker
shows... (snippet)

-- Logs begin at Sat 2021-04-17 10:44:40 EDT, end at Thu 2021-04-22 09:54:30 EDT. -- Apr 21 12:06:35 w540 systemd[1]: Started Netmaker Server. Apr 21 12:06:35 w540 netmaker[7106]: 2021/04/21 12:06:35 Server starting... Apr 21 12:06:35 w540 netmaker[7106]: 2021/04/21 12:06:35 Database connecting... Apr 21 12:06:40 w540 systemd[1]: Stopping Netmaker Server... Apr 21 12:06:40 w540 systemd[1]: netmaker.service: Succeeded. Apr 21 12:06:40 w540 systemd[1]: Stopped Netmaker Server. Apr 21 12:06:40 w540 systemd[1]: Started Netmaker Server. Apr 21 12:06:40 w540 netmaker[7120]: 2021/04/21 12:06:40 Server starting... Apr 21 12:06:40 w540 netmaker[7120]: 2021/04/21 12:06:40 Database connecting... Apr 21 12:07:10 w540 netmaker[7120]: 2021/04/21 12:07:10 server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: localhost:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : dial tcp 127.0..0.1:27017: connect: connection refused }, ] } Apr 21 12:07:10 w540 systemd[1]: netmaker.service: Main process exited, code=exited, status=1/FAILURE Apr 21 12:07:10 w540 systemd[1]: netmaker.service: Failed with result 'exit-code'. Apr 21 12:07:11 w540 systemd[1]: netmaker.service: Scheduled restart job, restart counter is at 1. Apr 21 12:07:11 w540 systemd[1]: Stopped Netmaker Server.

MongoDB is listening on port 27017

$ sudo lsof -i -P -n | grep LISTEN
systemd-r  881 systemd-resolve   13u  IPv4  34855      0t0  TCP 127.0.0.53:53 (LISTEN) cupsd      934            root    6u  IPv6  37929      0t0  TCP [::1]:631 (LISTEN) cupsd      934            root    7u  IPv4  37930      0t0  TCP 127.0.0.1:631 (LISTEN) mongod    1013         mongodb   11u  IPv4  36746      0t0  TCP 127.0.0.1:27017 (LISTEN) sshd      1051            root    3u  IPv4  35210      0t0  TCP :22 (LISTEN) sshd      1051            root    4u  IPv6  35212      0t0  TCP :22 (LISTEN)

bmullan commented 3 years ago

@afeiszli

I think I found *part of the problem why I have a dev.yaml and no ENV.yaml. But in addition it seems like the user: and pass: below overwrite what I passed as my "user" and "pass" when I installed?

In the Netmaker repo:

https://raw.githubusercontent.com/gravitl/netmaker/v0.2/netmaker-server.sh

#!/bin/sh set -e

mkdir -p /etc/netmaker/config/environments wget -O /etc/netmaker/netmaker https://github.com/gravitl/netmaker/releases/download/latest/netmaker chmod +x /etc/netmaker/netmaker

cat >/etc/netmaker/config/environments/dev.yaml<<EOL server: host: apiport: "8081" grpcport: "50051" masterkey: "secretkey" allowedorigin: "*" restbackend: true
agentbackend: true defaultnetname: "default" defaultnetrange: "10.10.10.0/24" createdefault: true mongoconn: user: "mongoadmin" pass: "mongopass" host: "localhost" port: "27017" opts: '/?authSource=admin' EOL

cat >/etc/systemd/system/netmaker.service<<EOL [Unit] Description=Netmaker Server After=network.target

[Service] Type=simple Restart=on-failure

WorkingDirectory=/etc/netmaker ExecStart=/etc/netmaker/netmaker

[Install] WantedBy=multi-user.target EOL systemctl daemon-reload systemctl start netmaker.service

afeiszli commented 3 years ago

Hi Brian, yes this is another mis-clarification in docs. It specifies "ENV.yaml" as a placeholder for whatever you're calling your env file. It could be dev.yaml or prod.yaml or something else. On startup, netmaker will look for an environment variable $APP_ENV.

If that value is not found, it will use "dev" by default and choose the dev.yaml file.

Based on your output, this does appear to be an authentication issue with mongo so the problem is likely the mongo user:pass.

bmullan commented 3 years ago

@afeiszli re your comment

Based on your output, this does appear to be an authentication issue with mongo so the problem is likely the mongo user:pass.

You may have missed this in my previous post:

But in addition it seems like the user: and pass: below overwrite what
I passed as my "user" and "pass" when I installed?

In my command I was specifying both "user=admin" and "pass=admin"

but I found those were ignored/overwritten by the above script and was setting user=mongoadmin and pass=mongopass

I'm not sure why my user: and pass: were overwritten

afeiszli commented 3 years ago

Were user/pass overwritten on the server (config for connecting with mongo), or on mongo itself There's nothing written in Netmaker that can write a user/pass to mongodb.