当前位置: 首页 > OpenSource > 正文

cassandra cluster install and configuration

1) Install

http://labs.renren.com/apache-mirror/cassandra/0.7.6-2/apache-cassandra-0.7.6-2-bin.tar.gz(apache官网推荐人人的mirror,不过link有问题 ^_^)

  * tar -zxvf apache-cassandra-$VERSION.tar.gz
  * cd apache-cassandra-$VERSION
  * sudo mkdir -p /var/log/cassandra
  * sudo chown -R `whoami` /var/log/cassandra
  * sudo mkdir -p /var/lib/cassandra
  * sudo chown -R `whoami` /var/lib/cassandra

Note: The sample configuration files in conf/ determine the file-system
locations Cassandra uses for logging and data storage. You are free to
change these to suit your own environment and adjust the path names
used here accordingly.

Now that we’re ready, let’s start it up!
#start up front
  * bin/cassandra -f

2) two nodes configuration:
node1:192.168.46.155
node2:192.168.46.179

[2hei.net conf]$ cat cassandra.yaml
cluster_name: ‘Test Cluster’
initial_token:
auto_bootstrap: false
hinted_handoff_enabled: true
max_hint_window_in_ms: 3600000 # one hour
hinted_handoff_throttle_delay_in_ms: 50
authenticator: org.apache.cassandra.auth.AllowAllAuthenticator
authority: org.apache.cassandra.auth.AllowAllAuthority
partitioner: org.apache.cassandra.dht.RandomPartitioner
data_file_directories:
    – /var/lib/cassandra/data
commitlog_directory: /var/lib/cassandra/commitlog
saved_caches_directory: /var/lib/cassandra/saved_caches
commitlog_rotation_threshold_in_mb: 128
commitlog_sync: periodic
commitlog_sync_period_in_ms: 10000
flush_largest_memtables_at: 0.75
reduce_cache_sizes_at: 0.85
reduce_cache_capacity_to: 0.6
seeds:
    – node2
concurrent_reads: 32
concurrent_writes: 32
memtable_flush_queue_size: 4
sliced_buffer_size_in_kb: 64
storage_port: 7000
listen_address: 192.168.46.155
rpc_address: 0.0.0.0
rpc_port: 9160
rpc_keepalive: true
thrift_framed_transport_size_in_mb: 15
thrift_max_message_length_in_mb: 16
incremental_backups: false
snapshot_before_compaction: false
column_index_size_in_kb: 64
in_memory_compaction_limit_in_mb: 64
compaction_preheat_key_cache: true
rpc_timeout_in_ms: 10000
endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch
dynamic_snitch: true
dynamic_snitch_update_interval_in_ms: 100
dynamic_snitch_reset_interval_in_ms: 600000
dynamic_snitch_badness_threshold: 0.0
request_scheduler: org.apache.cassandra.scheduler.NoScheduler
index_interval: 128

the same as node2,just need change
seeds:
    – node1

cat /etc/hosts    
192.168.46.155  node1
192.168.46.179  node2

Logs
#node1:
 INFO 10:23:46,151 Listening for thrift clients…
 INFO 10:23:46,315 Compacted to /var/lib/cassandra/data/system/LocationInfo-tmp-f-33-Data.db.  942 to 536 (~56% of original) bytes for 4 keys.  Time: 178ms.
 INFO 10:23:52,089 Node /192.168.46.179 has restarted, now UP again
 INFO 10:23:52,095 Node /192.168.46.179 state jump to normal
 INFO 10:24:02,177 Deleted /var/lib/cassandra/data/system/LocationInfo-f-32
 INFO 10:24:02,179 Deleted /var/lib/cassandra/data/system/LocationInfo-f-31
 INFO 10:24:52,097 Started hinted handoff for endpoint /192.168.46.179
 INFO 10:24:52,100 Finished hinted handoff of 0 rows to endpoint /192.168.46.179  
#node2:
 INFO 10:23:51,930 Binding thrift service to /0.0.0.0:9160
 INFO 10:23:51,939 Using TFastFramedTransport with a max frame size of 15728640 bytes.
 INFO 10:23:51,988 Listening for thrift clients…
 INFO 10:23:52,133 Node /192.168.46.155 has restarted, now UP again
 INFO 10:23:52,137 Node /192.168.46.155 state jump to normal
 INFO 10:23:53,548 InetAddress /192.168.46.155 is now dead.
 INFO 10:23:53,646 InetAddress /192.168.46.155 is now UP
 INFO 10:24:33,362 Started hinted handoff for endpoint /192.168.46.155
 INFO 10:24:33,365 Finished hinted handoff of 0 rows to endpoint /192.168.46.155
 
3) use cassandra:
#check cluster:
[2hei.net apache-cassandra-0.7.6-2]$ bin/nodetool -host localhost ring
Address         Status State   Load            Owns    Token                                      
                                                       168969914150282478893277211064871807700    
192.168.46.155   Up     Normal  53.28 KB        42.38%  70927753273796620281025030712152398970     
192.168.46.179   Up     Normal  45.16 KB        57.62%  168969914150282478893277211064871807700

#use cassandra-cli:
[2hei.net apache-cassandra-0.7.6-2]$bin/cassandra-cli –host localhost
[default@unknown] create keyspace FisherKeyspace;
2b1e86b8-ac65-11e0-9677-2edcd0f45bc6
Waiting for schema agreement…
… schemas agree across the cluster
[default@unknown] use FisherKeyspace;
Authenticated to keyspace: FisherKeyspace
[default@FisherKeyspace] create column family 2hei with comparator=UTF8Type and default_validation_class=UTF8Type;
3a0e8809-ac65-11e0-9677-2edcd0f45bc6
Waiting for schema agreement…
… schemas agree across the cluster
[default@FisherKeyspace] set Users[2hei][first] = ‘Fisher’;
Users not found in current keyspace.
[default@FisherKeyspace] set 2hei[2hei][first] = ‘Fisher’;
Value inserted.
[default@FisherKeyspace]  set 2hei[2hei][last] = ‘fishman’;
Value inserted.
[default@FisherKeyspace] set 2hei[2hei][age] = long(42);
Value inserted.
[default@FisherKeyspace] get 2hei[2hei];
=> (column=age, value=42, timestamp=1310461245929000)
=> (column=first, value=Fisher, timestamp=1310461237981000)
=> (column=last, value=fishman, timestamp=1310461242014000)
Returned 3 results.

[default@unknown] show keyspaces;
Keyspace: FisherKeyspace:
  Replication Strategy: org.apache.cassandra.locator.SimpleStrategy
    Replication Factor: 1
  Column Families:
    ColumnFamily: 2hei
      default_validation_class: org.apache.cassandra.db.marshal.UTF8Type
      Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
      Row cache size / save period in seconds: 0.0/0
      Key cache size / save period in seconds: 200000.0/14400
      Memtable thresholds: 0.0234375/5/1440 (millions of ops/minutes/MB)
      GC grace seconds: 864000
      Compaction min/max thresholds: 4/32
      Read repair chance: 1.0
   &nbsp
;  Built indexes: []

#other useful command of nodetool
bin/nodetool -host localhost ring
bin/nodetool -host localhost info
[2hei.net apache-cassandra-0.7.6-2]$ bin/nodetool -host localhost info
70927753273796620281025030712152398970
Gossip active    : true
Load             : 57.4 KB
Generation No    : 1310523824
Uptime (seconds) : 645
Heap Memory (MB) : 25.27 / 183.31
[2hei.net apache-cassandra-0.7.6-2]$ bin/nodetool -host localhost cfstats
Keyspace: FisherKeyspace
    Read Count: 0
    Read Latency: NaN ms.
    Write Count: 0
    Write Latency: NaN ms.
    Pending Tasks: 0
        Column Family: 2hei
        SSTable count: 0
        Space used (live): 0
        Space used (total): 0
        Memtable Columns Count: 0
        Memtable Data Size: 0
        Memtable Switch Count: 0
        Read Count: 0
        Read Latency: NaN ms.
        Write Count: 0
        Write Latency: NaN ms.
        Pending Tasks: 0
        Key cache capacity: 200000
        Key cache size: 0
        Key cache hit rate: NaN
        Row cache: disabled
        Compacted row minimum size: 0
        Compacted row maximum size: 0
        Compacted row mean size: 0

——————————–
接下来会继续完善cassandra的应用及api。

 

本文固定链接: https://www.2hei.net/2011/07/13/cassandra_cluster_install_and_configuration/ | 2hei.net

该日志由 u2 于2011年07月13日发表在 OpenSource 分类下,
原创文章转载请注明: cassandra cluster install and configuration | 2hei.net

报歉!评论已关闭.