docker中运行的InfluxDB v2.0 - err:从服务器接收的状态代码401

发布于 2025-02-10 23:35:23 字数 2520 浏览 2 评论 0原文

我正在尝试在本地计算机中使用InfluxDB进行一些实验,但由于某种原因,auth无法正常工作(或者我无法使其正常工作)。

我创建一个运行的Docker网络:

docker network create --driver bridge influxdb-telegraf-net

稍后,我只需将容器的8086绑定到Local -Host的,将数据文件附加一个卷,这几乎是全部:

docker run -d --name=influxdb -p 8086:8086 -v /tmp/influx:/root/.influxdb2 --net=influxdb-telegraf-net influxdb:2.0

然后,我将以下命令运行到在容器内部设置ImpruxDB:

docker exec -it influxdb influx setup

我填写用户名,密码,组织...等等。

但是,当我使用设置“完成”时,我使用本地Influx客户端创建一个新数据库,但是我运行的每个命令都会返回:err:从服务器中接收的状态代码401。

例如:

myuser@mymachine:~$ influx
Connected to http://localhost:8086 version 2.0.9
InfluxDB shell version: 1.6.7~rc0
> show databases
ERR: received status code 401 from server

我不确定问题的来源。我尝试运行auth,但是填充用户名和密码后,它仍然返回相同的错误。

我敢肯定,它必须是一些小的(但简单)的细节,因为我没有做任何喜欢的事情。

蒂亚!

在运行Docker运行时编辑

Influxdb-telegraf-net :

myuser@mymachine:~$ docker inspect influxdb-telegraf-net 
[
    {
        "Name": "influxdb-telegraf-net",
        "Id": "33afd698984c851c86e36e083522acfac5310a87313691c047826adb073a6065",
        "Created": "2022-06-25T10:15:06.630948524+01:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.20.0.0/16",
                    "Gateway": "172.20.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "e1ddbd36321b798a9343b3061d73ab438d012859134f73b7d072027729694917": {
                "Name": "influxdb",
                "EndpointID": "08e5698c04ea2532de6880946ed90c7c80e274b8920f4ce560b7c63f4a4f0f7a",
                "MacAddress": "00:00:aa:00:00:00",
                "IPv4Address": "172.20.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

Note 我将macaddress更改为虚拟添加的添加时。

I'm trying to run some experiments with InfluxDB in my local machine but for some reason, auth is not working (or I'm not being able to make it work).

I create a docker network running:

docker network create --driver bridge influxdb-telegraf-net

Later, I simply bind the 8086 of the container to the localhost's, attach a volume for the data files, and that's pretty much all:

docker run -d --name=influxdb -p 8086:8086 -v /tmp/influx:/root/.influxdb2 --net=influxdb-telegraf-net influxdb:2.0

Then, I run the following command to set up InfluxDB inside of the container:

docker exec -it influxdb influx setup

And I fill the username, password, organization... and so on.

However, when I'm "done" with the set up, I use my local influx client to create a new database, but every command I run returns: ERR: received status code 401 from server.

For instance:

myuser@mymachine:~$ influx
Connected to http://localhost:8086 version 2.0.9
InfluxDB shell version: 1.6.7~rc0
> show databases
ERR: received status code 401 from server

I'm not sure where the issue comes from. I tried running auth but after filling the username and password, it still returns the same error.

I'm sure it has to be some small - yet simple - detail, because I'm not doing anything fancy.

TIA!

EDIT

When running docker inspect influxdb-telegraf-net:

myuser@mymachine:~$ docker inspect influxdb-telegraf-net 
[
    {
        "Name": "influxdb-telegraf-net",
        "Id": "33afd698984c851c86e36e083522acfac5310a87313691c047826adb073a6065",
        "Created": "2022-06-25T10:15:06.630948524+01:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.20.0.0/16",
                    "Gateway": "172.20.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "e1ddbd36321b798a9343b3061d73ab438d012859134f73b7d072027729694917": {
                "Name": "influxdb",
                "EndpointID": "08e5698c04ea2532de6880946ed90c7c80e274b8920f4ce560b7c63f4a4f0f7a",
                "MacAddress": "00:00:aa:00:00:00",
                "IPv4Address": "172.20.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

Note that I changed my MacAddress to a dummy add just in case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2025-02-17 23:35:23

好吧,在检查了版本后(我应该做的第一件事!)我发现了:

myuser@mymachine:~$ /usr/bin/influx --version
InfluxDB shell version: 1.6.7~rc0

myuser@mymachine:~$ docker exec -it influxdb /bin/bash
root@e1ddbd36321b:/# influx version
Influx CLI 2.0.9 (git: d1233b7951) build_date: 2021-10-01T21:09:53Z

的,这基本上就是问题所在。客户和数据库的版本必须匹配。

请记住,InfluxDB 2.0或更高版本没有可让您进入DB CLI的开箱即用的CLI。您需要按照 19986年

Alright, after checking the versions (first thing I should have done!) I found out:

myuser@mymachine:~$ /usr/bin/influx --version
InfluxDB shell version: 1.6.7~rc0

and

myuser@mymachine:~$ docker exec -it influxdb /bin/bash
root@e1ddbd36321b:/# influx version
Influx CLI 2.0.9 (git: d1233b7951) build_date: 2021-10-01T21:09:53Z

So yeah, that's basically the issue. The versions of the client and the DB must match.

Keep in mind that InfluxDB 2.0 or greater does not have the out-of-the-box CLI that lets you enter the DB cli. You need to compile it by yourself as per issue #19986.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文