1. 程式人生 > >NoSQL之Apache Cassandra的下載和安裝(Window版)

NoSQL之Apache Cassandra的下載和安裝(Window版)

準備工作

  1. 因Cassandra是Java編寫,需要安裝JDK1.7及以上版本。(java -version)
  2. 為了使用cqlsh, 下載安裝最新的Python版本。(python –version)

Cassandra下載

從Apache Cassandra的官網下載最新或者較新的cassandra版本。例如:apache-cassandra-3.9-bin.tar.gz

Cassandra目錄結構

Cassandra解壓後的目錄結構

解壓並Cassandra配置環境變數

將下載的檔案解壓,如:apache-cassandra-3.9。
配置環境變數(可選):
① CASSANDRA_HOME=D:\apache-cassandra-3.9;
② path=%CASSANDRA_HOME%\bin.

啟動Cassandra服務和客戶端

啟動cmd(或者Power Shell),進入到cassandra的bin目錄中執行cassandra.bat即可啟動cassandra服務。

啟動cassandra服務

啟動Cassandra客戶端,在cassandra的bin目錄下執行cassandra-cli啟動客戶端。

啟動客戶端

Cassandra啟動過程遇到的錯誤

Windows PowerShell 內部錯誤。載入託管的 Windows PowerShell 失敗,返回錯誤 80070002。  
WARNING! Powershell script execution unavailable.  
   Please use 'powershell Set-ExecutionPolicy Unrestricted'  
   on
this user-account to run cassandra with fully featured functionality on this platform. Starting with legacy startup options Starting Cassandra Server Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap

解決方法:
1. 安裝補丁Windows Management Framework 4.0 (KB2819745)可解決.
地址:

http://www.microsoft.com/en-us/download/details.aspx?id=40855
2. 解決辦法:
Could not reserve enough space for 2097152KB object heap
修改 cassandra.bat 中的JVM引數
set JAVA_OPTS=-ea^
-javaagent:”%CASSANDRA_HOME%\lib\jamm-0.2.8.jar”^
-Xms512m^
-Xmx512m^

Cassandra客戶端初體驗

1. help;

使用help命令檢視Cassandra客戶端的基本操作命令。

這裡寫圖片描述

2. 建立keyspace

keyspace 對應關係資料庫中的資料庫。
命令: create keyspace geeker;

這裡寫圖片描述

3. 使用建立的keyspace

use geeker;
如圖可以看到,進入了geeker這個keyspace裡面了。

這裡寫圖片描述

建立列族 column family

列族 column family 就對應關係資料庫中的表。

這裡寫圖片描述

插入資料

set java[ascii(‘zhangsan’)][ascii(‘name’)]=ascii(‘zhangsan’);

這裡寫圖片描述

查詢資料

get java[ascii(‘zhangsan’)];

這裡寫圖片描述

提供所需資源的下載

上傳速度太慢了下週再發地址…
這裡寫圖片描述