【问题标题】:How can I create a local multi-node Cassandra cluster on Windows 7 64 bit?如何在 Windows 7 64 位上创建本地多节点 Cassandra 集群?
【发布时间】:2015-12-10 10:29:29
【问题描述】:

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

最好使用CCM “Cassandra Cluster Manager”,并允许使用DataStax OpsCenter进行管理

我按照“Getting Started with Apache Cassandra on Windows the Easy Way”中的说明进行操作,但它们适用于单节点集群。

编辑:我一直在使用 CCM 在每个节点上部署 OpsCenter 代理,有什么想法吗?

【问题讨论】:

    标签: cassandra cluster-computing windows-7-x64 opscenter cassandra-2.2


    【解决方案1】:

    本教程使用的文章:

    另见:

    先决条件:

    假定已安装以下工具:

    • JDK 7 或更早版本
    • ANT 构建工具

    第 1 步:安装 Python

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

    注意:这也会安装“pip”工具

    以下目录需要添加到PATH中

    <PYTHON_INSTALL_DIR>\Python
    <PYTHON_INSTALL_DIR>\Python\Scripts
    <ANT_INSTALL_DIR>\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 不受限制 在新的 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
    • “测试”集群路径 %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
    

    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
    

    【讨论】:

      猜你喜欢
      • 2015-01-22
      • 2018-08-09
      • 2012-01-23
      • 2020-03-31
      • 2014-05-10
      • 2020-04-12
      • 2013-02-02
      • 1970-01-01
      • 2021-04-23
      相关资源
      最近更新 更多