我在测试 riak 时遇到了curl错误

发布于 2024-12-15 10:18:34 字数 862 浏览 1 评论 0原文

我是 Riak 和网络服务的新手

,我遵循 riak 快速通道 ,在服务器端输入

riak start

并在客户端运行 curl -H "Accept: text/plain" http://markson.hk:8093/stats

我收到一个错误:

curl: (7) 无法连接到主机

更新

在服务器端

curl -v http://127.0.0.1:8098/ping

response: OK

它实际上有效:但是在我的客户端计算机上

curl -v http://116.255.139.151:8098/ping

它不起作用并返回:

bogon:~ yozloy$ curl -v http://116.255.139.151:8098/ping
* About to connect() to 116.255.139.151 port 8098 (#0)
*   Trying 116.255.139.151... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host

Nginx 欢迎页面起作用!

I'm newbie to Riak and web service

I follow the riak fast track,In server side I type

riak start

and in a client side, I run curl -H "Accept: text/plain" http://markson.hk:8093/stats

I got an error:

curl: (7) couldn't connect to host

update

on the server side it actually works:

curl -v http://127.0.0.1:8098/ping

response: OK

But on my client machine

curl -v http://116.255.139.151:8098/ping

it doesn't work and returns:

bogon:~ yozloy$ curl -v http://116.255.139.151:8098/ping
* About to connect() to 116.255.139.151 port 8098 (#0)
*   Trying 116.255.139.151... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host

And Nginx welcome pages works!

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

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

发布评论

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

评论(3

以酷 2024-12-22 10:18:35

我在虚拟机中设置 riak 1.4.2 然后尝试通过端口转发从主机访问 API 时遇到了类似的问题。

解决方案是编辑 riak app.config 文件并更改 http 设置。
默认/初始设置是:

{http, [ {"127.0.0.1", 8098} ]}

...仅绑定到环回接口。如果您希望 riak 在其他接口上响应,您必须将它们添加到设置中,例如:

{http, [ {"X.X.X.X", 8098}, {"127.0.0.1", 8098} ]}

其中 XXXX 是绑定到您要使用的其他接口的地址。
对于我的虚拟机来说,这是一个 10.0.XX 地址。

Protocol buffers API 还有一个类似格式的 pb 设置,如果您想从客户端计算机使用 protocol buffers API 访问服务器,您可能也需要更新该设置。

I encountered a similar problem setting up riak 1.4.2 in a virtual machine and then trying to access the API from the host machine via port forwarding.

The solution was to edit the riak app.config file and change the http setting.
The default/initial setting was:

{http, [ {"127.0.0.1", 8098} ]}

...which only binds to the loopback interface. If you want riak to respond on other interfaces you have to add them to the setting like:

{http, [ {"X.X.X.X", 8098}, {"127.0.0.1", 8098} ]}

where X.X.X.X is the address bound to the other interface you would like to use.
In the case of my VM this was a 10.0.X.X address.

There is also a similarly formatted pb setting for the protocol buffers API which you may want to update as well if you want to access the server using the protocol buffers API from a client machine.

巡山小妖精 2024-12-22 10:18:35

2016 年 Riask 2.1.4 的答案(早期版本有所不同)

打开配置文件:

sudo vi /etc/riak/riak.conf +/http.internal

将此行从:更改

listener.http.internal = 127.0.0.1:8098

为:

listener.http.internal = 0.0.0.0:8098

然后重新启动:(

sudo riak restart

来源:https://gist.github.com/wavell/7979851

Riak 中对此的记录确实很少2.1.4,我的评价瞬间扣分。

2016 answer for Riask 2.1.4 (earlier versions are different)

Open the config file:

sudo vi /etc/riak/riak.conf +/http.internal

Change this line from:

listener.http.internal = 127.0.0.1:8098

to:

listener.http.internal = 0.0.0.0:8098

Then restart:

sudo riak restart

(Credits: https://gist.github.com/wavell/7979851)

This is really poorly documented in Riak 2.1.4, an instant point deduction in my evaluation.

意中人 2024-12-22 10:18:35

我想这是一个网络问题,您可以尝试代理或远程 VPS 服务器

ping 116.255.139.151
PING 116.255.139.151 (116.255.139.151) 56(84) bytes of data.
64 bytes from 116.255.139.151: icmp_seq=1 ttl=46 time=222 ms
64 bytes from 116.255.139.151: icmp_seq=2 ttl=46 time=223 ms

,我在服务器上运行您正在使用的相同命令,我得到了正确的结果。

 curl -v http://116.255.139.151:8098/ping
* About to connect() to 116.255.139.151 port 8098 (#0)
*   Trying 116.255.139.151... connected
* Connected to 116.255.139.151 (116.255.139.151) port 8098 (#0)
> GET /ping HTTP/1.1
> User-Agent: curl/7.19.5 (i486-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15
> Host: 116.255.139.151:8098
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
< Date: Tue, 22 Nov 2011 07:00:46 GMT
< Content-Type: text/html
< Content-Length: 2
< 
* Connection #0 to host 116.255.139.151 left intact
* Closing connection #0

希望这对您的故障排除有用。

I guess this is a network issue, you can try a proxy or a remote VPS server

ping 116.255.139.151
PING 116.255.139.151 (116.255.139.151) 56(84) bytes of data.
64 bytes from 116.255.139.151: icmp_seq=1 ttl=46 time=222 ms
64 bytes from 116.255.139.151: icmp_seq=2 ttl=46 time=223 ms

And I run that on the server same command you are using, I got correct result.

 curl -v http://116.255.139.151:8098/ping
* About to connect() to 116.255.139.151 port 8098 (#0)
*   Trying 116.255.139.151... connected
* Connected to 116.255.139.151 (116.255.139.151) port 8098 (#0)
> GET /ping HTTP/1.1
> User-Agent: curl/7.19.5 (i486-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15
> Host: 116.255.139.151:8098
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
< Date: Tue, 22 Nov 2011 07:00:46 GMT
< Content-Type: text/html
< Content-Length: 2
< 
* Connection #0 to host 116.255.139.151 left intact
* Closing connection #0

Hope that is useful for your troubleshooting.

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