第五部分 安裝Cassandra1.0.x的單實例模式

今天我們要進入一個重要的課題,下文翻譯的內容就是Cassandra的單點安裝過程,安裝版本選擇DataStax Community Edition的Cassandra嗎,其實與哪個版本沒什麼本質的區別,就是操作步驟略有不同,但是結果是一樣的。

 

Installing a Single-Node Instance of Cassandra

安裝Cassandra的單實例模式

 

原文

The fastest way to get up and runningquickly with Cassandra is to install Cassandra using the DataStax Communitytarball distributions and start a single-node instance. Cassandra is intendedto be run on multiple nodes, however starting out with a single-node cluster isa great way to get started.

 

譯文

最快的速度獲得並運行Cassandra的方法就是安裝Datastax 社區版本的Cassandra,並且實現單節點下運行。雖然Cassandra的目的是爲多節點運行而設計的,但是從一個單節點的羣集開始Cassandra旅程是最好的開始。

 

原文

Getting up and running takes just threesimple steps:

1.Make sure youhave Java installed

2.Install theDataStax Community Edition of Apache Cassandra 1.0

3.Set a coupleof configuration properties and start the Cassandra server

 

譯文

開始和運行Cassandra只需要實現以下3個步驟。

1.確認JDK安裝環境

2.安裝DataStax社區版本的Cassandra

3.爲Cassandra服務器設置幾個屬性,並啓動Cassandra

 

原文

Checking for a Java Installation

Cassandra is a Java program and requires aJava Virtual Machine (JVM) to be installed before you can start the server. Forproduction deployments, you will need the Sun Java Runtime Environment 1.6.0_19or later, but if you are just kicking the tires, any JVM should do.

To check for Java, run the followingcommand:

# java -version

If you do not have Java installed, see InstallingSun JRE on RedHat Systems or InstallingSun JRE on Ubuntu Systems for instructions.

 

譯文

確認Java的安裝

Cassandra使用Java語言縮寫的應用程序,所以在運行Cassandra之前必須爲它準備一個Java虛擬機的運行環境。在發佈產品時,你可以選擇Sun的JRE1.6.0_19及更高版本的虛擬機運行環境,如果你只是初步測試和學習Cassandra,那麼任何滿足Cassandra運行的虛擬機環境都可以。

確認你得系統是否安裝了jdk或是jre,以及確認安裝的版本是否滿足Cassandra運行的需要,你可以在windows 命令行或是linux的終端(譯者注:本文采用CentOS6作爲測試平臺)打入:

# java –version

加入你已經安裝了Java虛擬機,那麼系統會返回java的版本信息

加入你還沒有安裝java,那麼請閱讀在RedHat系統上安裝SunJRE(和在Ubuntu系統上安裝SunJRE。

 

InstallingSun JRE on RedHat Systems

在RedHat系統上安裝SunJRE

原文

DataStax recommends installing the mostrecently released version of the Oracle Sun Java Runtime Environment (JRE),also referred to as the Java Virtual Machine (JVM). Versions earlier than1.6.0_19 should not be used.

 

譯文

DataStax推薦安裝最新版本的Oracle Sun JRE,或是稱作Java虛擬機,1.6.0_19以前的版本不能使用,必須是1.6.0_19及之後的JRE版本才能正常運行Cassandra1.0.x。

 

原文

The rpm packages install the OpenJDK JavaRuntime Environment (JRE) instead of the Oracle Sun JRE. After installing usingthe rpm packaged releases, configure your operating system to use the OracleSun JRE instead of OpenJDK.

 

譯文

操作系統初始安裝時默認安裝OpenJDK,所以我們必須安裝Oracle Sun 的JDK,並取代原來的OpenJDK。

 

原文

Check which version of the java runtimeenvironment your system is using. If your system is using the OpenJDK RuntimeEnvironment, you will need to change it to use the Oracle Sun JRE.

$ java -version

 

譯文

確認你得系統運行的jre版本是哪個版本,假如你的系統使用的OpenJDK運行時,那麼必須重新安裝Oracle Sun 的JDK取代它。

$java –version

(譯者注:看看版本是否符合,如果已經符合就跳過安裝jre步驟)

 

原文

Go to the Oracle JavaRuntime Environment Download Page, accept the license agreement, anddownload the Linux x64-RPM Installer or Linuxx86-RPM Installer (depending onyour platform).

 

譯文

到Oracle Java運行環境下載頁面

http://www.oracle.com/technetwork/java/javase/downloads/jre-6u25-download-346243.html

下載Sun Jdk,選擇和是的版本,注意下載合適的rpm包,根據你得極其的芯片和硬件,比如是32的系統,那麼你下載的64爲時安裝不了的)

 

原文

Go to the directory where you downloadedthe JRE package, and change the permissions so the file is executable. Forexample:

$ cd /tmp

$ chmod a+x jre-6u25-linux-x64-rpm.bin

 

譯文

到你所下載的jre目錄,改變目錄的權限,以便授權給其他用戶使用。

$ cd /tmp

$ chmod a+x jre-6u25-linux-x64-rpm.bin

 

原文

Extract and run the rpm file. For example:

$ sudo ./jre-6u25-linux-x64-rpm.bin

The rpm installs the JRE into /usr/java/.

 

譯文

解壓並運行rpm,比如:

$ sudo ./jre-6u25-linux-x64-rpm.bin

Rpm包將java運行環境安裝到了系統的/usr/java/目錄

 

原文

Configure your system so that it is usingthe Oracle Sun JRE instead of the OpenJDK JRE. Use the alternatives command toadd a symbolic link to the Oracle Sun JRE installation. For example:

$ sudo alternatives --install /usr/bin/javajava /usr/java/jre1.6.0_25/bin/java 20000

 

譯文

配置系統默認的JRE,用OraclrSunJRE代替OpenJDK,使用alternatives命令配置系統的jdk運行環境轉移帶OracleSun jre,例如:

$ sudo alternatives --install /usr/bin/javajava /usr/java/jre1.6.0_25/bin/java 20000

 

原文

Make sure your system is now using thecorrect JRE. For example:

$ java -version

 

譯文

再次確認你得jre版本

$ java –version

 

原文

If the OpenJDK JRE is still being used, usethe alternatives command to switch it. For example:

$ sudo alternatives --config java

There are 2 programs which provide 'java'.

 

   Selection    Command

-----------------------------------------------

  1          /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

*+ 2           /usr/java/jre1.6.0_25/bin/java

 

Enter to keep the current selection[+], or typeselection number: 2

 

譯文

加入OpenJDK仍然在使用中,那麼可以通過alternatives命令進行切換,比如:

$ sudo alternatives --config java

There are 2 programs which provide 'java'.

 

   Selection    Command

-----------------------------------------------

  1          /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

*+ 2           /usr/java/jre1.6.0_25/bin/java

 

Enter to keep the current selection[+], or typeselection number: 2

譯者注:這時候應該是切人切換過來使用Oracle sun 的JRE了。

 

原文

Installingthe DataStax Community Binaries

The quickest way to get going on a singlenode with Cassandra is to install the DataStax Community Edition binary tarballpackages. This allows you to install everything in a single location (such asyour home directory), and does not require root permissions.

 

譯文

開始使用Cassandra單節點最快的辦法就是安裝DataStax社區版本二進制包得的Cassandra。它允許你把Cassandra安裝在任意一個位置(比如home的目錄),並不需要管理員的權限。

 

原文

DataStax Community is comprised of fourcomponents - The Apache Cassandra 1.0 server, the DataStax portfolio demoapplication, DataStax OpsCenter (a web-based monitoring application forCassandra), and cqlsh (a SQL-like command-line clientinterface). Note that DataStax OpsCenter is not currently supported on MacOS.

 

譯文

DataStax社區版本的Cassandra包含4個組成部分。-第一部分:阿帕奇的Cassandra1.0.x服務器;第二部分:DataStax組合演示應用程序;第三部分:DataStax的OpsCenter(一個基於Web的Cassandra監控程序);第四部分:一個CSQL(一個類似SQL命令行的客戶)。注意當前的OpsCenter並不支持MacOS。

 

原文

Note

The instructions in this section are not intended for production installations, just for a quick start tutorial. SeePlanning a Cassandra Cluster Deployment,Installing and Initializing a Cassandra Cluster, andConfiguring and Starting a Cassandra Cluster for production cluster setup best practices.

 

譯文

備註

本節中的說明不適合生產環境,只作爲一個快速入門教程。如果希望配置生產環境的服務器,請參閱規劃Cassandra集羣部署,安裝和初始化Cassandra集羣,配置和啓動生產環境的Cassandra集羣的最佳實踐。

 

原文

These instructions will walk you throughsetting up a self-contained, single-node instance of Cassandra in your homedirectory (does not require root permissions).

 

譯文

以下的指令將獨立完成一個單節點的Cassandra的配置,無需管理員的權限。

 

原文

Note

By downloading community software from DataStax you agree to the terms of the DataStax Community EULA (end user license agreement) posted on the DataStax web site.

 

譯文

備註

您在同意DataStax社區DataStax網站上公佈的EULA(最終用戶許可協議)的條款下才能下載DataStax社會軟件。

 

原文

1、In your home directory, create a directory called datastax. In thatdirectory download the Cassandra package (required), plus the DataStax Demo,CQL and OpsCenter packages (optional).

 

$ cd $HOME

 

$ mkdir datastax

 

$ cd datastax

 

$ wgethttp://downloads.datastax.com/community/apache-cassandra-1.0.0-bin.tar.gz

 

$ wgethttp://downloads.datastax.com/community/dsc-1.0-3-demo-bin.tar.gz

 

$ wgethttp://downloads.datastax.com/community/datastax-cqlsh.tar.gz

 

$ wgethttp://downloads.datastax.com/community/opscenter-1.3-free.tar.gz

 

譯文

1、在你的home目錄中,創建一個名爲datastax目錄。在該目錄中下載Cassandra(必需),DataStax演示,CQL和OpsCenter的包(可選)。

 

$ cd $HOME

 

$ mkdir datastax

 

$ cd datastax

 

$ wgethttp://downloads.datastax.com/community/apache-cassandra-1.0.0-bin.tar.gz

 

$ wgethttp://downloads.datastax.com/community/dsc-1.0-3-demo-bin.tar.gz

 

$ wgethttp://downloads.datastax.com/community/datastax-cqlsh.tar.gz

 

$ wgethttp://downloads.datastax.com/community/opscenter-1.3-free.tar.gz

 

2、Unpack the distributions:

 

$ tar -xzvfapache-cassandra-1.0.0-bin.tar.gz

 

$ tar -xzvf dsc-1.0-*-demo-bin.tar.gz

 

$ tar -xzvf datastax-cqlsh.tar.gz

 

$ tar -xzvf opscenter-1.3-free.tar.gz

 

$ rm *.tar.gz

 

2、解壓發佈包

$ tar -xzvfapache-cassandra-1.0.0-bin.tar.gz

 

$ tar -xzvf dsc-1.0-*-demo-bin.tar.gz

 

$ tar -xzvf datastax-cqlsh.tar.gz

 

$ tar -xzvf opscenter-1.3-free.tar.gz

 

$ rm *.tar.gz

 

原文

3、For convenience, set the following environment variables in youruser environment. For example, to configure your environment in your $HOME/.bashrcfile:

1)、Open your .bashrc file in a texteditor (such as vi):

vi $HOME/.bashrc

2)、Add the following lines to bottomof the file:

export CASSANDRA_HOME=$HOME/datastax/apache-cassandra-1.0.0

export DSCDEMO_HOME=$HOME/datastax/dsc-1.0-*/demos/portfolio_manager

export CQLSH_HOME=$HOME/datastax/datastax-cqlsh

export OPSC_HOME=$HOME/datastax/opscenter-1.3

export PATH="$PATH:$CASSANDRA_HOME/bin:$DSCDEMO_HOME/bin:$OPSC_HOME/bin"

3)、Save and close the file.

4)、Source the file.

source $HOME/.bashrc

 

譯文

3,爲了方便,在您的用戶環境中設置以下環境變量。例如,在$HOME/ .bashrc文件中配置您的環境:

       1)、在一個文本編輯器打開.bashrc文件(比如vi)

              vi$HOME/.bashrc

       2)、在文件的地步添加以下幾行:

export CASSANDRA_HOME=$HOME/datastax/apache-cassandra-1.0.0

export DSCDEMO_HOME=$HOME/datastax/dsc-1.0-*/demos/portfolio_manager

export CQLSH_HOME=$HOME/datastax/datastax-cqlsh

export OPSC_HOME=$HOME/datastax/opscenter-1.3

exportPATH="$PATH:$CASSANDRA_HOME/bin:$DSCDEMO_HOME/bin:$OPSC_HOME/bin"

       3)、保存並關閉文件

       4)、讓文件生效

              source$HOME/.bashrc

 

原文

4、Create the data and logging directory for Cassandra.

$ mkdir $HOME/datastax/cassandra-data

 

譯文

爲Cassandra的數據和日誌準備目錄。

$ mkdir $HOME/datastax/cassandra-data

 

原文

Configuringand Starting a Single-Node Cluster

1、Set the configuration properties needed to start your cluster in the

$CASSANDRA_HOME/conf/cassandra.yaml file.This will configure Cassandra to run a

single-node cluster on the localhost andstore all of its data files in your home directory.

 

$ sed -i -e "s,initial_token:,initial_token:0," \

      $CASSANDRA_HOME/conf/cassandra.yaml

 

$ sed -i -e "s,-/var/lib/cassandra/data,- $HOME/datastax/cassandra-data," \

      $CASSANDRA_HOME/conf/cassandra.yaml

 

$ sed -i -e "s,saved_caches_directory:

/var/lib/cassandra/saved_caches,saved_caches_directory:$HOME/datastax/cassandra-data/saved_caches," \

      $CASSANDRA_HOME/conf/cassandra.yaml

 

$ sed -i -e "s,commitlog_directory:/var/lib/cassandra/commitlog,commitlog_directory:$HOME/datastax/cassandra-data/commitlog," \

$CASSANDRA_HOME/conf/cassandra.yaml

 

2、Set the Cassandra server log location in the

$CASSANDRA_HOME/conf/log4j-server.properties

file to the logdirectory you created earlier:

 

$ sed -i -e "s,log4j.appender.R.File=/var/log/cassandra/system.log,log4j.appender.R.File

=$HOME/datastax/cassandra-data/system.log,"\

      $CASSANDRA_HOME/conf/log4j-server.properties

 

3、Start the Cassandra server in the background.

$ Cassandra

 

4、Check that your Cassandra ring is up and running:

$ nodetool ring-h localhost

 

5、For the next hand-on steps, run the PortfolioDemo example application.

譯文

配置和啓動單節點的羣集

1、 通過配置$CASSANDRA_HOME/conf/cassandra.yaml文件設置羣集啓動需要的參數。以下將配置一個單節點的Cassandra羣集,數據就存儲在你得主目錄下。

$ sed -i -e "s,initial_token:,initial_token:0," \

      $CASSANDRA_HOME/conf/cassandra.yaml

 

$ sed -i -e "s,-/var/lib/cassandra/data,- $HOME/datastax/cassandra-data," \

      $CASSANDRA_HOME/conf/cassandra.yaml

 

$ sed -i -e "s,saved_caches_directory:

/var/lib/cassandra/saved_caches,saved_caches_directory:$HOME/datastax/cassandra-data/saved_caches," \

      $CASSANDRA_HOME/conf/cassandra.yaml

 

$ sed -i -e "s,commitlog_directory:/var/lib/cassandra/commitlog,commitlog_directory:$HOME/datastax/cassandra-data/commitlog," \

$CASSANDRA_HOME/conf/cassandra.yaml

       (譯者注:我建議您通過vi或是gedit打開$CASSANDRA_HOME/conf/cassandra.yaml,直接修改:

initial_token

data_file_directories

saved_caches_directory

commitlog_directory

)如圖:

 

2、通過設置$CASSANDRA_HOME/conf/log4j-server.properties文件,把Cassandra的日誌輸出到你配置的目錄裏面;

# Edit the next line to point to your logsdirectory

log4j.appender.R.File=/DataStax/cassandra-data/system.log

 

3、在後臺啓動Cassandra

$ Cassandra

 

4、測試Cassandra的羣集環是否在運行

$ nodetool ring -h localhost

 

5、如果需要查看Demo,那麼可以查看PortfolioDemo的文檔。

 

譯者注:

到這裏,cassandra安裝和配置結束,

對於OpsCenter以及CQL還有CassandraDemo的安裝,這裏不做詳述,因爲這些都不是運行Cassandra必須的組件,更多的是需要了解Cassandra的數據模型。


發佈了57 篇原創文章 · 獲贊 9 · 訪問量 58萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章