Influxdb python:找不到404页面

III*_*III 6 python influxdb

我正在尝试使用我在这里找到的Influxdb-python lib .但我甚至无法让教程程序工作.

当我运行以下示例代码时:

$ python

>>> from influxdb import InfluxDBClient

>>> json_body = [
    {
        "measurement": "cpu_load_short",
        "tags": {
            "host": "server01",
            "region": "us-west"
        },
        "time": "2009-11-10T23:00:00Z",
        "fields": {
            "value": 0.64
        }
    }
]

>>> client = InfluxDBClient('localhost', 8086, 'root', 'root', 'example')

>>> client.create_database('example')
Run Code Online (Sandbox Code Playgroud)

我在最后一行收到此错误消息:

>>> client.create_database('example')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 318, in create_database
    status_code=201
  File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 124, in request
    raise InfluxDBClientError(response.content, response.status_code)
influxdb.client.InfluxDBClientError: 404: 404 page not found
Run Code Online (Sandbox Code Playgroud)

我的安装版本:

pi@raspberrypi:~ $ influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 0.9.6.1
InfluxDB shell 0.9.6.1
Run Code Online (Sandbox Code Playgroud)

如果有人能指出我的问题,那将是非常好的.

UPDATE

也许这很有帮助.我和Jessie一起使用Raspberry Pi 3并使用这个tuturial 链接安装了Influxdb

更新2

如果我跑,curl http://localhost:8086我也找不到404页面.在端口8083上我收到回复.

fsp*_*fsp 1

我在 Raspberry Pi2 上运行 Influxdb。

InfluxDB shell 0.12.1是我拥有的版本。您正在运行 0.9.6.1,它可能已经过时,但仍然是您使用的存储库中可用的最新版本。

您的端口似乎是正确的,快速 netstat 显示:

tcp6       0      0 :::8083                 :::*                    LISTEN      17740/influxd   
tcp6       0      0 :::8086                 :::*                    LISTEN      17740/influxd   
tcp6       0      0 :::8088                 :::*                    LISTEN      17740/influxd   
Run Code Online (Sandbox Code Playgroud)

为了测试它,我使用了与您相同的示例脚本,但略有不同:

#!/usr/bin/python

import random
from datetime import datetime

from influxdb import InfluxDBClient


query = 'select value from wetter;'
client = InfluxDBClient(host='127.0.0.1', database='wetter')
print(client)

current_time = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
json_body = [
    {
        "measurement": "temperature",
        "tags": {
            "host": "192.168.0.82",
            "location": "room"
        },
        "time": current_time,
        "fields": {
            "value": random.random()
        }
    }
]
print(json_body)

client.write_points(json_body)
Run Code Online (Sandbox Code Playgroud)

然后我启动脚本,while true; do ./influxdb-test.py; sleep 2; done每 2 秒插入一个新条目。

> select * from temperature

1462865736000000000 192.168.0.82    room    0.116745414817
1462866059000000000 192.168.0.82    room    0.576278097718
1462866062000000000 192.168.0.82    room    0.731955354635
1462866065000000000 192.168.0.82    room    0.536106447983
1462866068000000000 192.168.0.82    room    0.965246396917
1462866070000000000 192.168.0.82    room    0.785592521739
Run Code Online (Sandbox Code Playgroud)