Sak*_*thi 10 postgresql grafana
从 grafana 连接到 postgresql-11.5.1 不起作用。我在我的本地安装了 postgres 并创建了一个 grafana 并尝试连接,但我得到了常见的错误: dial tcp 127.0.0.1:5432: connect: connection returned am NOT using postgresql on docker, it just on my local on windows 10.因为 stackoverflow 上提供的答案与 docker 相关。请帮忙..
就我而言,我使用 Docker 在本地部署了 Grafana,并尝试使用 Postgres 插件连接到本地安装的 Postgres。我不得不使用host.docker.internal主机,而不是localhost导致相同的错误:
请检查 Postgresql 的这些配置文件。
/etc/postgresql//main/postgresql.conf
/etc/postgresql//main/pb_hba.conf
通过更改 来维护客户端身份验证pb_hba.conf。确保它有此行用于本地身份验证。
[TYPE] [DATABASE] [USER] [ADDRESS] [METHOD]
host all all 127.0.0.1/32 md5
Run Code Online (Sandbox Code Playgroud)
Grafana 实例现在位于不同的网络中,Postgres 将与其建立远程连接。默认情况下,仅本地连接可用。要启用远程,
sudo vim /etc/postgresql//main/postgresql.conf
改成。#listen_addresses = 'localhost'#listen_addresses = '*'
通过键入在终端中获取 docker 桥接网络接口信息。
ip addr
........
docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group
default
link/ether 02:42:da:5e:5e:95 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:daff:fe5e:5e95/64 scope link
valid_lft forever preferred_lft forever
Run Code Online (Sandbox Code Playgroud)
这里inet 172.17.0.1/16指的是
172.17.0.0/16允许您的计算机上的此网络pb_hba.conf。
host all all 172.17.0.0/16 md5
Run Code Online (Sandbox Code Playgroud)
现在,使用从您的计算机获取的 IP 地址(172.17.0.1)ip addr代替 localhost 作为 Grafana 数据源地址。
参考
允许 docker 容器连接到本地/主机 postgres 数据库
https://blog.jsinh.in/how-to-enable-remote-access-to-postgresql-database-server/#.XXYs2HUvNuS
| 归档时间: |
|
| 查看次数: |
8083 次 |
| 最近记录: |