当前位置:  开发笔记 > 编程语言 > 正文

如何在Windows 7 64位上创建本地多节点Cassandra集群?

如何解决《如何在Windows764位上创建本地多节点Cassandra集群?》经验,为你挑选了1个好方法。

我正在寻找一组指令来在Window 7 64位PC上创建本地多节点Cassandra 2.x集群.

它最好使用CCM"Cassandra Cluster Manager"并允许使用DataStax OpsCenter进行管理

我按照" 轻松实现Windows上的Apache Cassandra入门 "中的说明进行操作,但它们适用于单节点群集.

编辑:我坚持使用CCM在每个节点上部署OpsCenter代理,任何想法?



1> Adrian..:

本教程使用的文章:

CCM 2.0和Windows

Cassandra Wiki - Windows开发

在单台Windows计算机上设置多节点Cassandra集群

也可以看看:

简单的方法在Windows上使用Apache Cassandra入门

Cassandra DevCenter(需要免费注册)

先决条件:

假设已经安装了以下工具:

JDK 7或更早版本

ANT构建工具

第1步:安装Python

从这里下载并安装最新版本的Python 2.x, 例如https://www.python.org/ftp/python/2.7.11/python-2.7.11.amd64.msi

注意:这也将安装" pip "工具

需要将以下目录添加到PATH中

\Python
\Python\Scripts
\bin

第2步:安装CCM"Cassandra Cluster Manager"

在新的命令提示符/ Powershell窗口中(以您自己的身份登录)

键入"pip install ccm" - 将自动下载并安装ccm

> pip install ccm
Collecting ccm
  Downloading ccm-2.0.6.tar.gz (56kB)
    100% |################################| 57kB 1.8MB/s
Collecting pyYaml (from ccm)
  Downloading PyYAML-3.11.tar.gz (248kB)
    100% |################################| 249kB 1.7MB/s
Collecting six>=1.4.1 (from ccm)
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: pyYaml, six, ccm
  Running setup.py install for pyYaml
  Running setup.py install for ccm
Successfully installed ccm-2.0.6 pyYaml-3.11 six-1.10.0

第3步:安装"psutil(python系统和进程实用程序)"

在与步骤2相同的窗口中:

键入"pip install psutil" - - 将自动下载并安装psutil

> pip install psutil
Collecting psutil
  Downloading psutil-3.3.0-cp27-none-win_amd64.whl (92kB)
    100% |################################| 94kB 1.4MB/s
Installing collected packages: psutil
Successfully installed psutil-3.3.0

注意:此窗口现在可以关闭

步骤4:Set-ExecutionPolicy Unrestricted 在新的Powershell窗口(以本地管理员身份登录)中,键入"Set-ExecutionPolicy Unrestricted"

*注意:您必须设置Windows Powershell的执行策略以允许CCM启动Cassandra的实例.不受限制的执行策略还允许CCM在常规命令提示符(cmd)以及Windows Powershell上运行

PS C:\Windows\system32> Set-ExecutionPolicy Unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y

第5步:注册PY扩展

注意:将.PY扩展名添加到环境变量$ PATHEXT,以允许从任何位置执行ccm(以管理员身份在PowerShell上运行):

在与步骤4类型相同的窗口中

[Environment]::SetEnvironmentVariable("PATHEXT", "$env:PATHEXT;.PY", "MACHINE")

注意:此窗口现在可以关闭

步骤6:检查CCM是否已启动并正在运行

在新的命令提示符窗口(以您自己登录)中键入:

>ccm status
No currently active cluster (use ccm cluster switch)

第7步:更新主机文件

以管理员身份打开记事本,并将以下行打开到C:\ Windows\System32\drivers\etc\hosts文件:

#cassandra nodes
127.0.0.1               127.0.0.2
127.0.0.1               127.0.0.3
127.0.0.1               127.0.0.4
127.0.0.1               127.0.0.5
127.0.0.1               127.0.0.6

步骤8:使用Cassandra v2.1.2创建并填充3节点集群

注意:这将下载Cassandra的2.1.2版本,构建它然后用它来创建一个名为"mytestcluster"的新CCM集群.

Cassandra安装路径%USERPROFILE%.ccm\repository\2.1.2

"test"集群路径%USERPROFILE%.ccm\test


C:\Users\myusername>ccm create mytestcluster -v 2.1.2
Downloading http://archive.apache.org/dist/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz to c:\users\myusername\appdata\local\temp\ccm-qwauvs.tar.gz (21.735MB)
  22790390  [100.00%]
Extracting c:\users\myusername\appdata\local\temp\ccm-qwauvs.tar.gz as version 2.1.2 ...

Current cluster is now: mytestcluster

C:\Users\myusername>ccm status
Cluster: 'mytestcluster'
------------------------
No node in this cluster yet

C:\Users\myusername>ccm populate -n 3

C:\Users\myusername>ccm status
Cluster: 'mytestcluster'
------------------------
node1: DOWN (Not initialized)
node3: DOWN (Not initialized)
node2: DOWN (Not initialized)   

C:\Users\myusername>ccm start
Started: node1 with pid: 17432
Started: node3 with pid: 6308
Started: node2 with pid: 22484

C:\Users\myusername>ccm status
Cluster: 'mytestcluster'
------------------------
node1: UP
node3: UP
node2: UP

C:\Users\myusername>ccm jconsole

Cassandra Cluster jconsole截图

C:\Users\myusername>ccm node1 show
node1: UP
       cluster=mytestcluster
       auto_bootstrap=False
       thrift=('127.0.0.1', 9160)
       binary=('127.0.0.1', 9042)
       storage=('127.0.0.1', 7000)
       jmx_port=7100
       remote_debug_port=0
       initial_token=-9223372036854775808
       pid=17432

C:\Users\myusername>ccm node2 show
node2: UP
       cluster=mytestcluster
       auto_bootstrap=False
       thrift=('127.0.0.2', 9160)
       binary=('127.0.0.2', 9042)
       storage=('127.0.0.2', 7000)
       jmx_port=7200
       remote_debug_port=0
       initial_token=-3074457345618258603
       pid=22484

C:\Users\myusername>ccm node3 show
node3: UP
       cluster=mytestcluster
       auto_bootstrap=False
       thrift=('127.0.0.3', 9160)
       binary=('127.0.0.3', 9042)
       storage=('127.0.0.3', 7000)
       jmx_port=7300
       remote_debug_port=0
       initial_token=3074457345618258602
       pid=6308

推荐阅读
yzh148448
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有