一、Cassandra 3.11.10 依赖环境安装
-
JDK
1)Cassandra 3.11.10基于jdk8!单需安装低版本的jdk8,推荐Jdk8_251_x64;
2)设置JAVA_HOME环境变量
3)验证jdk的是否正确安装
命令:java -version
4)常见错误:
1.最新版jdk8,运行cassandra会出现Failed to write core dump. Minidumps are not enabled by…;
2.jdk8 x86会出现Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap;
-
Python
Cassandra的命令式客户端:cqlsh基于python开发,需安装python运行环境。官网下载地址Python Releases for Windows
1)python环境变量设置(==注:windows的msi安装,会自设置环境变量==)
2)验证
命令:python
二、Cassandra 3.11.10 安装
-
下载Cassandra 3.11.10
-
环境变量设置
-
验证:默认配置时
命令:cassandra
-
Cassandra正常启动后,使用cqlsh客户端连接
命令:cqlsh
参考:How To Install Cassandra On Windows 10
三、Cassandra 集群搭建
这里使用三台电脑进行集群搭建,IP依次为192.168.2.207、192.168.2.203、192.168.79.128。
-
cassandra.yaml配置文件
1)设置集群名称
所有Node的cassandra.yaml中的集群名需保持一致。
cluster_name: 'Test Cluster' #集群中所有Node的集群名需保持一致 #默认第10行
复制代码
2)设置集群节点
该配置为Node IP为192.168.2.207上的配置。
master ==192.168.2.207==;slave-1 ==192.168.2.203==;slave-2 ==192.168.79.128==;
seed_provider:
# Addresses of hosts that are deemed contact points.
# Cassandra nodes use this list of hosts to find each other and learn
# the topology of the ring. You must change this if you are running
# multiple nodes!
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
# seeds is actually a comma-delimited list of addresses.
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "192.168.2.207,192.168.2.203,192.168.79.178"
#默认第416-425行
复制代码
3)设置监听地址(==每个Node对应填写自己的IP地址==)
该配置为Node IP为192.168.2.207上的配置。
# Address or interface to bind to and tell other Cassandra nodes to connect to.
# You _must_ change this if you want multiple nodes to be able to communicate!
#
# Set listen_address OR listen_interface, not both.
#
# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
# will always do the Right Thing _if_ the node is properly configured
# (hostname, name resolution, etc), and the Right Thing is to use the
# address associated with the hostname (it might not be).
#
# Setting listen_address to 0.0.0.0 is always wrong.
#
listen_address: 192.168.2.207 #默认第612行
复制代码
4)设置rpc(开启服务,并为每个Node填写自己的IP)
该配置为Node IP为192.168.2.207上的配置。
# Whether to start the thrift rpc server.
start_rpc: true #默认第675行 #true:开启 #false:关闭
# The address or interface to bind the Thrift RPC service and native transport
# server to.
#
# Set rpc_address OR rpc_interface, not both.
#
# Leaving rpc_address blank has the same effect as on listen_address
# (i.e. it will be based on the configured hostname of the node).
#
# Note that unlike listen_address, you can specify 0.0.0.0, but you must also
# set broadcast_rpc_address to a value other than 0.0.0.0.
#
# For security reasons, you should not expose this port to the internet. Firewall it if needed.
rpc_address: 192.168.2.207 #默认第689行
复制代码
5)另外两个Node(192.168.2.203、192.168.79.128)的配置
这两个Node为分发,配置同Node(192.168.2.207)。
Node:192.168.2.203
listen_address: 192.168.2.203 #默认第612行
rpc_address: 192.168.2.203 #默认第689行
- seeds: "192.168.2.203,192.168.2.207,192.168.79.178"
复制代码
Node:192.168.79.128
listen_address: 192.168.79.128 #默认第612行
rpc_address: 192.168.79.128 #默认第689行
- seeds: "192.168.79.128,192.168.2.203,192.168.2.207"
复制代码
6)启动Cassandra(每个Node都执行)
cassandra -R #root用户需要-R参数
nodetool status #查看节点状态
7)启动cqlsh
cqsh [主机名]
示例:cqsh 192.168.2.207
参考:cassandra3.11.4集群搭建 – osc_qpjywoo6的个人空间 – OSCHINA – 中文开源技术交流社区