Error reading influxdb status code 401

Just installed and it doesn't work. mini31 # apt-get install influxdb2 influxdb-client Reading package lists... Done Building dependency tree Reading state information... Done influxdb-client i...

Just installed and it doesn’t work.

mini31 # apt-get install influxdb2 influxdb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
influxdb-client is already the newest version (1.6.4-1+deb10u1).
The following NEW packages will be installed:
  influxdb2 influxdb2-cli
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/114 MB of archives.
After this operation, 195 MB of additional disk space will be used.
Selecting previously unselected package influxdb2.
(Reading database ... 117705 files and directories currently installed.)
Preparing to unpack .../influxdb2_2.1.1_amd64.deb ...
Unpacking influxdb2 (2.1.1) ...
Preparing to unpack .../influxdb2-cli_2.2.1_amd64.deb ...
Unpacking influxdb2-cli (2.2.1) ...
dpkg: error processing archive /var/cache/apt/archives/influxdb2-cli_2.2.1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/influx', which is also in package influxdb-client 1.6.4-1+deb10u1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/influxdb2-cli_2.2.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
mini31 # apt-get install influxdb2 influxdb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
influxdb-client is already the newest version (1.6.4-1+deb10u1).
influxdb2 is already the newest version (2.1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up influxdb2 (2.1.1) ...
Created symlink /etc/systemd/system/influxd.service → /lib/systemd/system/influxdb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/influxdb.service → /lib/systemd/system/influxdb.service.
mini31 # apt-get install influxdb2 influxdb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
influxdb-client is already the newest version (1.6.4-1+deb10u1).
influxdb2 is already the newest version (2.1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
mini31 # systemctl status influxdb
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-02-21 09:29:08 GMT; 6min ago
     Docs: https://docs.influxdata.com/influxdb/
 Main PID: 19911 (influxd)
    Tasks: 8 (limit: 4367)
   Memory: 65.4M
   CGroup: /system.slice/influxdb.service
           └─19911 /usr/bin/influxd

Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691497Z lvl=info msg="Open store (end)" l
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691529Z lvl=info msg="Starting retention
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691554Z lvl=info msg="Starting precreatio
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691621Z lvl=info msg="Starting query cont
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.694681Z lvl=info msg="Configuring InfluxQ
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: InfluxDB API at http://localhost:8086/ready unavailable after 1
Feb 21 09:29:08 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:08.009652Z lvl=info msg=Starting log_id=0Znu
Feb 21 09:29:08 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:08.010925Z lvl=info msg=Listening log_id=0Zn
Feb 21 09:29:08 mini31 influxd-systemd-start.sh[19910]: InfluxDB started
Feb 21 09:29:08 mini31 systemd[1]: Started InfluxDB is an open-source, distributed, time series database.
mini31 # influx
Connected to http://localhost:8086 version 2.1.1
InfluxDB shell version: 1.6.4
> SHOW DATABASES
ERR: received status code 401 from server

Summary

A solution to the Influx DB CLI error “Failed to check token: received status code 401 from server” including instructions to install the InfluxDB V2 CLI.

Story

As I worked my way through using the Influx Database I tried using the InfluxDB CLI.  However, no matter what I seemed to do I got this error, which was super annoying.

linux$ 
linux$ influx
Failed to check token: received status code 401 from server
linux$ influx create
Failed to check token: received status code 401 from server
linux$ influx adsf
Failed to check token: received status code 401 from server
linux$ influx setup
Failed to check token: received status code 401 from server

I tried googling around to try to figure out what was happening but really didn’t see anything that would explain that behavior.  However, I did find one comment that if you were using Docker you could run the CLI by running in the shell.  So I tried that:

linux$ docker exec -it 89ffd4bb9ec5  /bin/bash
root@89ffd4bb9ec5:/# influx version
Influx CLI 2.0.4 (git: 4e7a59bb9a) build_date: 2021-02-08T17:47:02Z

When I originally installed the client (on Ubuntu) I did this:

linux$ sudo apt install influxdb-client
[sudo] password for arh: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-hwe-5.4-headers-5.4.0-71
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  influxdb-client
0 upgraded, 1 newly installed, 0 to remove and 97 not upgraded.
Need to get 1,146 kB of archives.
After this operation, 3,969 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 influxdb-client amd64 1.1.1+dfsg1-4 [1,146 kB]
Fetched 1,146 kB in 1s (1,883 kB/s)       
Selecting previously unselected package influxdb-client.
(Reading database ... 275845 files and directories currently installed.)
Preparing to unpack .../influxdb-client_1.1.1+dfsg1-4_amd64.deb ...
Unpacking influxdb-client (1.1.1+dfsg1-4) ...
Setting up influxdb-client (1.1.1+dfsg1-4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

When I ran the version look what I got:

linux$ /usr/bin/influx -version
InfluxDB shell version: 1.1.1

Now we know the problem.  I have the wrong version of the CLI.  This was caused by two things

  1. I installed the docker version of InfluxDB.  So I never had the command line version on my linux box.
  2. The influxdb-client that you get from whatever the debian source on Ubuntu is the 1.xx version.  It is too bad that you can’t “sudo apt install influxdbv2-client”  Oh well.

To fix this start by nuking the old version.

linux$ sudo apt-get remove influxdb-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-hwe-5.4-headers-5.4.0-71
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  influxdb-client
0 upgraded, 0 newly installed, 1 to remove and 97 not upgraded.
After this operation, 3,969 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 275851 files and directories currently installed.)
Removing influxdb-client (1.1.1+dfsg1-4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Then download the “InfluxDB Cloud CLI” (which is just a standalone version of the CLI.  You can get it from the influxdata.com website here.

Scroll down to the InfluxDB Cloud CLI

Then follow the instructions (Notice that I moved it to /usr/local/bin)

linux$ wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.0.6-linux-amd64.tar.gz
--2021-05-21 11:08:48--  https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.0.6-linux-amd64.tar.gz
Resolving dl.influxdata.com (dl.influxdata.com)... 13.33.74.100, 13.33.74.21, 13.33.74.27, ...
Connecting to dl.influxdata.com (dl.influxdata.com)|13.33.74.100|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11758006 (11M) [application/x-gzip]
Saving to: ‘influxdb2-client-2.0.6-linux-amd64.tar.gz’

influxdb2-client-2.0.6-linux-amd64.tar.gz              100%[===========================================================================================================================>]  11.21M  10.8MB/s    in 1.0s    

2021-05-21 11:08:50 (10.8 MB/s) - ‘influxdb2-client-2.0.6-linux-amd64.tar.gz’ saved [11758006/11758006]

linux$ tar xvf influxdb2-client-2.0.6-linux-amd64.tar.gz 
influxdb2-client-2.0.6-linux-amd64/LICENSE
influxdb2-client-2.0.6-linux-amd64/README.md
influxdb2-client-2.0.6-linux-amd64/influx
linux$ sudo mv influxdb2-client-2.0.6-linux-amd64/influx /usr/local/bin

Now when you check the version, you are in the money

linux$ influx version
Influx CLI 2.0.6 (git: 4db98b4c9a) build_date: 2021-04-29T16:48:12Z

I am an engineer and tinkerer at heart. I live in the most beautiful place on earth — Central Kentucky. This blog is about hooking stuff up to the internet. Click here for the long version.

Just installed and it doesn’t work.

mini31 # apt-get install influxdb2 influxdb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
influxdb-client is already the newest version (1.6.4-1+deb10u1).
The following NEW packages will be installed:
  influxdb2 influxdb2-cli
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/114 MB of archives.
After this operation, 195 MB of additional disk space will be used.
Selecting previously unselected package influxdb2.
(Reading database ... 117705 files and directories currently installed.)
Preparing to unpack .../influxdb2_2.1.1_amd64.deb ...
Unpacking influxdb2 (2.1.1) ...
Preparing to unpack .../influxdb2-cli_2.2.1_amd64.deb ...
Unpacking influxdb2-cli (2.2.1) ...
dpkg: error processing archive /var/cache/apt/archives/influxdb2-cli_2.2.1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/influx', which is also in package influxdb-client 1.6.4-1+deb10u1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/influxdb2-cli_2.2.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
mini31 # apt-get install influxdb2 influxdb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
influxdb-client is already the newest version (1.6.4-1+deb10u1).
influxdb2 is already the newest version (2.1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up influxdb2 (2.1.1) ...
Created symlink /etc/systemd/system/influxd.service → /lib/systemd/system/influxdb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/influxdb.service → /lib/systemd/system/influxdb.service.
mini31 # apt-get install influxdb2 influxdb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
influxdb-client is already the newest version (1.6.4-1+deb10u1).
influxdb2 is already the newest version (2.1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
mini31 # systemctl status influxdb
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-02-21 09:29:08 GMT; 6min ago
     Docs: https://docs.influxdata.com/influxdb/
 Main PID: 19911 (influxd)
    Tasks: 8 (limit: 4367)
   Memory: 65.4M
   CGroup: /system.slice/influxdb.service
           └─19911 /usr/bin/influxd

Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691497Z lvl=info msg="Open store (end)" l
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691529Z lvl=info msg="Starting retention
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691554Z lvl=info msg="Starting precreatio
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.691621Z lvl=info msg="Starting query cont
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:07.694681Z lvl=info msg="Configuring InfluxQ
Feb 21 09:29:07 mini31 influxd-systemd-start.sh[19910]: InfluxDB API at http://localhost:8086/ready unavailable after 1
Feb 21 09:29:08 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:08.009652Z lvl=info msg=Starting log_id=0Znu
Feb 21 09:29:08 mini31 influxd-systemd-start.sh[19910]: ts=2022-02-21T09:29:08.010925Z lvl=info msg=Listening log_id=0Zn
Feb 21 09:29:08 mini31 influxd-systemd-start.sh[19910]: InfluxDB started
Feb 21 09:29:08 mini31 systemd[1]: Started InfluxDB is an open-source, distributed, time series database.
mini31 # influx
Connected to http://localhost:8086 version 2.1.1
InfluxDB shell version: 1.6.4
> SHOW DATABASES
ERR: received status code 401 from server

Понравилась статья? Поделить с друзьями:
  • Error reading from source device
  • Error program review
  • Error program mingw32 make exe not found in path
  • Error prog renault
  • Error reading from rom ошибка atiwinflash что делать