如何配置cassandra进行远程连接
How to configure cassandra for remote connection
我正在尝试为 windows、
上的远程连接配置 Cassandra Datastax Community Edition
Cassandra Server 安装在 Windows 7 PC 上,使用本地 CQLSH 可以完美连接到本地服务器。
但是当我尝试从同一网络中的另一台 PC 连接 与 CQLSH 时,我收到此错误消息:
Connection error: ('Unable to connect to any servers', {'MYHOST':
error(10061, "Tried connecting to [('HOST_IP', 9042)]. Last error: No
connection could be made because the target machine actively refused
it")})
所以我想知道如何正确配置(我应该对 cassandra.yaml 配置文件进行哪些更改)Cassandra 服务器以允许远程连接。
提前致谢!
Cassandra 的远程访问是通过它的 Cassandra 2.0 thrift 端口。在 Cassandra 2.0.x 中,默认的 cqlsh 监听端口是 9160,这是在 cassandra.yaml 中由 rpc_port 参数定义的。默认情况下,Cassandra 2.0.x 和更早版本通过在 cassandra.yaml 文件中将 start_rpc 配置为 true 来启用 Thrift。
在 Cassandra 2.1 中,cqlsh 实用程序使用本机协议。在使用 Datastax python 驱动程序的 Cassandra 2.1 中,默认的 cqlsh 监听端口是 9042.
cassandra 节点应该绑定到服务器网卡的 IP 地址 - 它不应该是 127.0.0.1 或 localhost,这是环回接口的 IP,绑定到此将阻止直接远程访问。要配置绑定地址,请使用 cassandra.yaml 中的 rpc_address 参数。将此设置为 0.0.0.0 将侦听所有网络接口。
您检查过远程机器是否可以连接到Cassandra节点?机器之间有防火墙吗?您可以尝试以下步骤来对此进行测试:
1) 确保您可以从您所在的服务器连接到该 IP:
$ ssh 用户@xxx.xxx.xx.xx
2) 检查节点的状态并确认它显示相同的 IP:
$nodetool 状态
3)运行连接IP的命令(不使用默认端口只需要指定端口):
$ cqlsh xxx.xxx.xx.xx
Kat 的替代解决方案。与 Ubuntu 16.04
合作
- ssh 进入服务器
server_user@**.**.**.**
停止 cassandra 如果 运行:
- 检查是否 运行
ps aux | grep cassandra
如果运行,将输出一大块命令/标志,例如
ubuntu 14018 4.6 70.1 2335692 712080 pts/2 Sl+ 04:15 0:11 java -Xloggc:./../logs/gc.log ........
注意例子中的14018是进程id
- 停止
kill <process_id>
(在本例中为 14018)
编辑cassandra.yaml文件如下
rpc_address: 0.0.0.0
broadcast_rpc_address: **.**.**.**
<- 你服务器的IP(不能设置为0.0.0.0)
- 重新启动 cassandra
./bin/cassandra -f
(从 cassandra root 中)
- 在本地机器上打开另一个终端并通过
cqlsh **.**.**.**
(您服务器的 IP)连接进行测试。
./bin/nodetool status
地址报告了我的本地主机 IP (127.0.0.1),但 cqlsh 远程仍然有效。
这个怎么样:
在 cassandra.yaml 配置文件中进行以下更改:
start_rpc: true
rpc_address: 0.0.0.0
broadcast_rpc_address: [node-ip]
listen_address: [node-ip]
seed_provider:
- class_name: ...
- seeds: "[node-ip]"
参考:https://gist.github.com/andykuszyk/7644f334586e8ce29eaf8b93ec6418c4
我正在尝试为 windows、
上的远程连接配置 Cassandra Datastax Community EditionCassandra Server 安装在 Windows 7 PC 上,使用本地 CQLSH 可以完美连接到本地服务器。
但是当我尝试从同一网络中的另一台 PC 连接 与 CQLSH 时,我收到此错误消息:
Connection error: ('Unable to connect to any servers', {'MYHOST': error(10061, "Tried connecting to [('HOST_IP', 9042)]. Last error: No connection could be made because the target machine actively refused it")})
所以我想知道如何正确配置(我应该对 cassandra.yaml 配置文件进行哪些更改)Cassandra 服务器以允许远程连接。
提前致谢!
Cassandra 的远程访问是通过它的 Cassandra 2.0 thrift 端口。在 Cassandra 2.0.x 中,默认的 cqlsh 监听端口是 9160,这是在 cassandra.yaml 中由 rpc_port 参数定义的。默认情况下,Cassandra 2.0.x 和更早版本通过在 cassandra.yaml 文件中将 start_rpc 配置为 true 来启用 Thrift。
在 Cassandra 2.1 中,cqlsh 实用程序使用本机协议。在使用 Datastax python 驱动程序的 Cassandra 2.1 中,默认的 cqlsh 监听端口是 9042.
cassandra 节点应该绑定到服务器网卡的 IP 地址 - 它不应该是 127.0.0.1 或 localhost,这是环回接口的 IP,绑定到此将阻止直接远程访问。要配置绑定地址,请使用 cassandra.yaml 中的 rpc_address 参数。将此设置为 0.0.0.0 将侦听所有网络接口。
您检查过远程机器是否可以连接到Cassandra节点?机器之间有防火墙吗?您可以尝试以下步骤来对此进行测试:
1) 确保您可以从您所在的服务器连接到该 IP:
$ ssh 用户@xxx.xxx.xx.xx
2) 检查节点的状态并确认它显示相同的 IP:
$nodetool 状态
3)运行连接IP的命令(不使用默认端口只需要指定端口):
$ cqlsh xxx.xxx.xx.xx
Kat 的替代解决方案。与 Ubuntu 16.04
合作- ssh 进入服务器
server_user@**.**.**.**
停止 cassandra 如果 运行:
- 检查是否 运行
ps aux | grep cassandra
如果运行,将输出一大块命令/标志,例如
ubuntu 14018 4.6 70.1 2335692 712080 pts/2 Sl+ 04:15 0:11 java -Xloggc:./../logs/gc.log ........
注意例子中的14018是进程id
- 停止
kill <process_id>
(在本例中为 14018)
- 检查是否 运行
编辑cassandra.yaml文件如下
rpc_address: 0.0.0.0
broadcast_rpc_address: **.**.**.**
<- 你服务器的IP(不能设置为0.0.0.0)
- 重新启动 cassandra
./bin/cassandra -f
(从 cassandra root 中) - 在本地机器上打开另一个终端并通过
cqlsh **.**.**.**
(您服务器的 IP)连接进行测试。
./bin/nodetool status
地址报告了我的本地主机 IP (127.0.0.1),但 cqlsh 远程仍然有效。
这个怎么样:
在 cassandra.yaml 配置文件中进行以下更改:
start_rpc: true
rpc_address: 0.0.0.0
broadcast_rpc_address: [node-ip]
listen_address: [node-ip]
seed_provider:
- class_name: ...
- seeds: "[node-ip]"
参考:https://gist.github.com/andykuszyk/7644f334586e8ce29eaf8b93ec6418c4