How can I create a local multi-node Cassandra cluster on Windows 7 64 bit?

旧时模样 提交于 2019-11-27 15:25:38

Articles used for this tutorial:

See also:

Prerequisites:

The following tools are assumed to be already installed:

  • JDK 7 or older
  • ANT build tool

Step 1: Install Python

Download and install latest version of Python 2.x from here e.g. https://www.python.org/ftp/python/2.7.11/python-2.7.11.amd64.msi

Note: This will also install “pip” tool

The following directories need to be added to the PATH

<PYTHON_INSTALL_DIR>\Python
<PYTHON_INSTALL_DIR>\Python\Scripts
<ANT_INSTALL_DIR>\bin

Step 2: Install CCM “Cassandra Cluster Manager”

In a new Command Prompt/Powershell window (login as yourself)

type “pip install ccm” – which will automatically download and install 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

Step 3: Install “psutil (python system and process utilities)”

In the same window as for Step 2:

type “pip install psutil” – – which will automatically download and install 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

Note: This window can now be closed

Step 4: Set-ExecutionPolicy Unrestricted In a new Powershell window (login as local admin), type “Set-ExecutionPolicy Unrestricted”

*Note: You must set the execution policy of Windows Powershell to allow CCM to launch instances of Cassandra. An unrestricted execution policy will also allow CCM to run on the regular command prompt (cmd) as well as 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

Step 5: Register PY extension

Note: Add .PY extension to environment variable $PATHEXT, to allow ccm to be executed from any location (run on PowerShell as administrator):

In the same window as for Step 4 type

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

Note: This window can now be closed

Step 6: Check if CCM is up and running

In a new Command Prompt window (login as yourself) type:

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

Step 7: Update hosts file

Open Notepad as Administrator and the following lines to the C:\Windows\System32\drivers\etc\hosts file:

#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

Step 8: Create and populate a 3 node cluster using Cassandra v2.1.2

Note: This will download version 2.1.2 of Cassandra, build it and then use it to create a new CCM cluster called “mytestcluster”.

  • Cassandra installation path %USERPROFILE%.ccm\repository\2.1.2
  • “test” cluster path %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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!