1, Cassandra Introduction
Apache Cassandra is a set of open source distributed key-value storage systems. It was originally developed by Facebook to store particularly large data. Cassandra is not a database, it is a mixed non-relational database, similar to Google's BigTable. This article mainly from the following five aspects to introduce CASSANDRA:CASSANDRA data model, installation and preparation Cassandra, common programming language use Cassandra to store data, Cassandra cluster building.
2. Configure the Environment
Ubuntu 14.04
apache-cassandra-2.0.15
Cassandra the Java environment must be configured to function properly (preferably greater than 1.7)
" 1.8.0_40 " 1.8. 0_40-25.40-b25, Mixed mode)
3. Download Cassandra Package
wget http://mirrors.cnnic.cn/apache/cassandra/2.0.15/apache-cassandra-2.0.15-bin.tar.gz
TAR-ZXVF apache-cassandra-2.0.15-bin.tar.gz-c./
MV apache-cassandra-2.0.15 Cassandra
4, Configuration Cassandra
Set the Cassandra Data directory
-
- Data_file_directories: Directory for data files
- Commitlog_directory: Directory for log files
- Saved_caches_directory: directory for cache files
Open the Cassandra configuration file with VI Cassandra.yaml
Vim ~/cassandra/conf/cassandra.yaml
data_file_directories: -/var/lib/cassandra//var/lib/cassandra//var/lib/cassandra/saved_caches
Create a new directory
# New Directory sudo mkdir -p/var/lib/cassandra/datasudomkdir -p/var/lib/cassandra/saved_ Cachessudomkdir -p/var/lib/cassandra/commitlogsudomkdir -p/var/log/cassandra
Set permissions
# Change Directory attribution to operational user sudo chown -R ubuntu:ubuntu/var/lib/Cassandrasudochown -R ubuntu:ubuntu/var/log/ cassandra/
5. Setting Environment variables
sudo vi /etc/environmentcassandra_home=/home/ubuntu/cassandra1215# Let the environment variable take effect ~. /etc/environment# View environment Variables echo $CASSANDRA _home/home/ubuntu/cassandra
6. Start Cassandra Server
#注:-f参数是绑定到console,不加-f则是后台启动
~/cassandra/bin$./Cassandra INFO -: -: at,670Logging initialized INFO -: -: at,923Loading settings fromfile:/home/talkweb/cassandra/conf/Cassandra.yaml INFO -: -: -,642Data Files Directories: [/var/lib/cassandra/Data] INFO -: -: -,648Commit Log directory:/var/lib/cassandra/Commitlog INFO -: -: -,651Diskaccessmode'Auto'determined to being standard, Indexaccessmode are standard INFO -: -: -,652Disk_failure_policy is stop INFO -: -: -,654Commit_failure_policy is stop INFO -: -: -,669Global memtable threshold is enabled at 123MB INFO -: -: -,049Not using multi-Threaded compaction INFO -: -: -,684Loading settings fromfile:/home/talkweb/cassandra/conf/Cassandra.yaml INFO -: -: -,707Loading settings fromfile:/home/talkweb/cassandra/conf/Cassandra.yaml INFO -: -: -,82232bit JVM detected. It's recommended to run Cassandra on a 64bit JVM forbetter performance. INFO -: -: -,824JVM Vendor/version:java HotSpot (TM) Client vm/1.8.0_40
......
7. View Cassandra Service process
view Cassandra System processes~PS-axu|grepCassandraubuntu2818 6.9 17.1 718732 176080pts/1Sl -: - 0: -/usr/local/java/jdk1.8.0_40/bin/java-ea-javaagent:/home/ubuntu/cassandra/lib/jamm-0.2.5. jar-xx:+cmsclassunloadingenabled-xx:+usethreadpriorities-xx:threadprioritypolicy= the-xms501m-xmx501m-xmn100m-xx:+heapdumponoutofmemoryerror-xss256k-xx:stringtablesize=1000003-xx:+useparnewgc-xx:+useconcmarksweepgc-xx:+cmsparallelremarkenabled-xx:survivorratio=8-xx:maxtenuringthreshold=1-xx:cmsinitiatingoccupancyfraction= the-xx:+usecmsinitiatingoccupancyonly-xx:+usetlab-xx:+cmsparallelinitialmarkenabled-xx:+cmsedenchunksrecordalways -djava.net.preferipv4stack=true-dcassandra.jmx.local.port=7199-xx
... ...
# View System Ports~ netstat-nlt|grep 9160TCP0 0 127.0.0.1:9160 0.0.0.0:* LISTEN
8. Cassandra Command Line interface
This connection is not recommended, and the Cassandra Command line interface will be removed in version Cassandra 3.0
~/cassandra/bin$./cassandra-cliconnected to:"Test Cluster"On127.0.0.1/9160Unable to open/home/ubuntu/.cassandra/cli.history forWritingwelcome to Cassandra CLI version2.0. theThe CLI is deprecated and would be removedinchCassandra3.0. Consider migrating to Cqlsh. CQL is fully backwards compatible with Thrift data; See http://Www.datastax.com/dev/blog/thrift-to-cql3Type'Help ;'Or'?' forHelp . Type'quit;'Or'exit;'To quit. [[email protected]]
9. Using Cassandra Interactive command line interface Cqlsh
~/cassandra/bin$./cqlshconnected to Test Cluster at localhost:91604.1. 1 2.0. the 3.1. 1 19.39. 0 for help.cqlsh
Reference article: http://www.ibm.com/developerworks/cn/opensource/os-cn-cassandra/
http://m.blog.csdn.net/blog/a19881029/40630529
Cassandra installation configuration under Ubuntu environment