当前位置:   article > 正文

第五部分 安装Cassandra1.0.x的单实例模式_cassandra 单实例

cassandra 单实例

今天我们要进入一个重要的课题,下文翻译的内容就是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的数据模型。


声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号