硬件要求:
两台windows电脑,并装好了jdk,环境变量也配好了
pc_1:172.16.50.110 pc_2:172.16.50.159
cassandra 版本:apache-cassandra-1.1.2-bin.tar.gz http://cassandra.apache.org/download/
文件放置的目录
D:\nosql\apache-cassandra-1.1.2(把apache-cassandra-1.1.2-bin.tar.gz 放到路径D:\nosql下并解压到当前文件夹下)
新建几个目录:
D:\nosql\apache-cassandra-1.1.2\work\data
D:\nosql\apache-cassandra-1.1.2\work\commitlog
D:\nosql\apache-cassandra-1.1.2\work\saved_caches
D:\nosql\apache-cassandra-1.1.2\work\log
pc_1:172.16.50.110
D:\nosql\apache-cassandra-1.1.2\conf\cassandra.yaml 文件修改
data_file_directories:
-d:/nosql/apache-cassandra-1.1.2/work/data
# commit log
commitlog_directory:d:/nosql/apache-cassandra-1.1.2/work/commitlog
# saved caches
saved_caches_directory: d:/nosql/apache-cassandra-1.1.2/work/saved_caches
seeds listen_address rpc_address
- seeds: "172.16.50.110,172.16.50.159"
rpc_address: 172.16.50.110
rpc_address: 172.16.50.110
行了
然后,在命令行,cmd
d:
cd D:\nosql\apache-cassandra-1.1.2\bin
cassandra
C:\Users\xyuser>cassandra
Starting Cassandra Server
INFO 14:36:13,154 Logging initialized
INFO 14:36:13,154 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.6.0_3
0
INFO 14:36:13,154 Heap size: 1065025536/1065025536
INFO 14:36:13,154 Classpath: D:\nosql\apache-cassandra-1.1.2\conf;D:\nosql\apac
he-cassandra-1.1.2\lib\antlr-3.2.jar;D:\nosql\apache-cassandra-1.1.2\lib\apache-
cassandra-1.1.2.jar;D:\nosql\apache-cassandra-1.1.2\lib\apache-cassandra-clientu
til-1.1.2.jar;D:\nosql\apache-cassandra-1.1.2\lib\apache-cassandra-thrift-1.1.2.
jar;D:\nosql\apache-cassandra-1.1.2\lib\avro-1.4.0-fixes.jar;D:\nosql\apache-cas
sandra-1.1.2\lib\avro-1.4.0-sources-fixes.jar;D:\nosql\apache-cassandra-1.1.2\li
b\commons-cli-1.1.jar;D:\nosql\apache-cassandra-1.1.2\lib\commons-codec-1.2.jar;
D:\nosql\apache-cassandra-1.1.2\lib\commons-lang-2.4.jar;D:\nosql\apache-cassand
ra-1.1.2\lib\compress-lzf-0.8.4.jar;D:\nosql\apache-cassandra-1.1.2\lib\concurre
ntlinkedhashmap-lru-1.3.jar;D:\nosql\apache-cassandra-1.1.2\lib\guava-r08.jar;D:
\nosql\apache-cassandra-1.1.2\lib\high-scale-lib-1.1.2.jar;D:\nosql\apache-cassa
ndra-1.1.2\lib\jackson-core-asl-1.9.2.jar;D:\nosql\apache-cassandra-1.1.2\lib\ja
ckson-mapper-asl-1.9.2.jar;D:\nosql\apache-cassandra-1.1.2\lib\jamm-0.2.5.jar;D:
\nosql\apache-cassandra-1.1.2\lib\jline-0.9.94.jar;D:\nosql\apache-cassandra-1.1
.2\lib\json-simple-1.1.jar;D:\nosql\apache-cassandra-1.1.2\lib\libthrift-0.7.0.j
ar;D:\nosql\apache-cassandra-1.1.2\lib\log4j-1.2.16.jar;D:\nosql\apache-cassandr
a-1.1.2\lib\metrics-core-2.0.3.jar;D:\nosql\apache-cassandra-1.1.2\lib\servlet-a
pi-2.5-20081211.jar;D:\nosql\apache-cassandra-1.1.2\lib\slf4j-api-1.6.1.jar;D:\n
osql\apache-cassandra-1.1.2\lib\slf4j-log4j12-1.6.1.jar;D:\nosql\apache-cassandr
a-1.1.2\lib\snakeyaml-1.6.jar;D:\nosql\apache-cassandra-1.1.2\lib\snappy-java-1.
0.4.1.jar;D:\nosql\apache-cassandra-1.1.2\lib\snaptree-0.1.jar;D:\nosql\apache-c
assandra-1.1.2\build\classes\main;D:\nosql\apache-cassandra-1.1.2\build\classes\
thrift;D:\nosql\apache-cassandra-1.1.2\lib\jamm-0.2.5.jar
INFO 14:36:13,154 JNA not found. Native methods will be disabled.
INFO 14:36:13,170 Loading settings from file:/D:/nosql/apache-cassandra-1.1.2/c
onf/cassandra.yaml
INFO 14:36:13,279 DiskAccessMode 'auto' determined to be mmap, indexAccessMode
is mmap
INFO 14:36:13,419 Global memtable threshold is enabled at 338MB
INFO 14:36:13,653 Initializing key cache with capacity of 50 MBs.
INFO 14:36:13,669 Scheduling key cache save to each 14400 seconds (going to sav
e all keys).
INFO 14:36:13,669 Initializing row cache with capacity of 0 MBs and provider or
g.apache.cassandra.cache.SerializingCacheProvider
INFO 14:36:13,669 Scheduling row cache save to each 0 seconds (going to save al
l keys).
INFO 14:36:13,887 Couldn't detect any schema definitions in local storage.
INFO 14:36:13,887 Found table data in data directories. Consider using the CLI
to define your schema.
INFO 14:36:13,903 No commitlog files found; skipping replay
INFO 14:36:13,919 Cassandra version: 1.1.2
INFO 14:36:13,919 Thrift API version: 19.32.0
INFO 14:36:13,919 CQL supported versions: 2.0.0,3.0.0-beta1 (default: 2.0.0)
INFO 14:36:13,965 Loading persisted ring state
INFO 14:36:13,965 Starting up server gossip
INFO 14:36:13,965 Enqueuing flush of Memtable-LocationInfo@81035498(162/202 ser
ialized/live bytes, 3 ops)
INFO 14:36:13,965 Writing Memtable-LocationInfo@81035498(162/202 serialized/liv
e bytes, 3 ops)
INFO 14:36:14,012 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\LocationInfo\system-LocationInfo-hd-1-Data.db (234 bytes) for commitlog p
osition ReplayPosition(segmentId=28388064008672, position=586)
INFO 14:36:14,028 Starting Messaging Service on port 7000
INFO 14:36:14,028 This node will not auto bootstrap because it is configured to
be a seed node.
WARN 14:36:14,043 Generated random token 42287584298666643063700995775504136179
. Random tokens will result in an unbalanced ring; see http://wiki.apache.org/ca
ssandra/Operations
INFO 14:36:14,043 Enqueuing flush of Memtable-LocationInfo@96507428(77/96 seria
lized/live bytes, 2 ops)
INFO 14:36:14,043 Writing Memtable-LocationInfo@96507428(77/96 serialized/live
bytes, 2 ops)
INFO 14:36:14,059 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\LocationInfo\system-LocationInfo-hd-2-Data.db (163 bytes) for commitlog p
osition ReplayPosition(segmentId=28388064008672, position=767)
INFO 14:36:14,075 Node /172.16.50.110 state jump to normal
INFO 14:36:14,075 Bootstrap/Replace/Move completed! Now serving reads.
INFO 14:36:14,075 Will not load MX4J, mx4j-tools.jar is not in the classpath
INFO 14:36:14,090 Binding thrift service to /172.16.50.110:9160
INFO 14:36:14,090 Using TFastFramedTransport with a max frame size of 15728640
bytes.
INFO 14:36:14,090 Using synchronous/threadpool thrift server on /172.16.50.110
: 9160
INFO 14:36:14,106 Listening for thrift clients...
INFO 14:41:46,383 Node /172.16.50.159 is now part of the cluster
INFO 14:41:46,383 InetAddress /172.16.50.159 is now UP
INFO 14:41:46,383 Enqueuing flush of Memtable-LocationInfo@2118052890(47/58 ser
ialized/live bytes, 1 ops)
INFO 14:41:46,383 Writing Memtable-LocationInfo@2118052890(47/58 serialized/liv
e bytes, 1 ops)
INFO 14:41:46,445 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\LocationInfo\system-LocationInfo-hd-3-Data.db (89 bytes) for commitlog po
sition ReplayPosition(segmentId=28388064008672, position=865)
INFO 14:58:39,629 Enqueuing flush of Memtable-schema_keyspaces@1443170494(202/2
52 serialized/live bytes, 4 ops)
INFO 14:58:39,629 Writing Memtable-schema_keyspaces@1443170494(202/252 serializ
ed/live bytes, 4 ops)
INFO 14:58:39,691 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\schema_keyspaces\system-schema_keyspaces-hd-1-Data.db (250 bytes) for com
mitlog position ReplayPosition(segmentId=28388064008672, position=1124)
INFO 14:59:28,112 Enqueuing flush of Memtable-schema_columnfamilies@457397894(1
149/1436 serialized/live bytes, 20 ops)
INFO 14:59:28,112 Writing Memtable-schema_columnfamilies@457397894(1149/1436 se
rialized/live bytes, 20 ops)
INFO 14:59:28,175 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\schema_columnfamilies\system-schema_columnfamilies-hd-1-Data.db (1205 byt
es) for commitlog position ReplayPosition(segmentId=28388064008672, position=233
0)
INFO 15:01:31,363 Enqueuing flush of Memtable-schema_columnfamilies@20911796(11
49/1436 serialized/live bytes, 20 ops)
INFO 15:01:31,363 Writing Memtable-schema_columnfamilies@20911796(1149/1436 ser
ialized/live bytes, 20 ops)
INFO 15:01:31,426 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\schema_columnfamilies\system-schema_columnfamilies-hd-2-Data.db (1205 byt
es) for commitlog position ReplayPosition(segmentId=28388064008672, position=438
8)
INFO 15:01:31,426 Enqueuing flush of Memtable-schema_columns@895877835(839/1048
serialized/live bytes, 15 ops)
INFO 15:01:31,426 Writing Memtable-schema_columns@895877835(839/1048 serialized
/live bytes, 15 ops)
INFO 15:01:31,457 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\schema_columns\system-schema_columns-hd-1-Data.db (895 bytes) for commitl
og position ReplayPosition(segmentId=28388064008672, position=4388)
INFO 15:01:31,472 Creating new index : ColumnDefinition{name=616765, validator=
org.apache.cassandra.db.marshal.UTF8Type, index_type=KEYS, index_name='user_age_
idx'}
INFO 15:01:31,488 Submitting index build of user.user_age_idx for data in
INFO 15:01:31,488 Enqueuing flush of Memtable-IndexInfo@1128410379(44/55 serial
ized/live bytes, 1 ops)
INFO 15:01:31,488 Writing Memtable-IndexInfo@1128410379(44/55 serialized/live b
ytes, 1 ops)
INFO 15:01:31,504 Completed flushing D:\nosql\apache-cassandra-1.1.2\work\data\
system\IndexInfo\system-IndexInfo-hd-1-Data.db (92 bytes) for commitlog position
ReplayPosition(segmentId=28388064008672, position=4489)
INFO 15:01:31,519 Index build of user.user_age_idx complete
机器二: pc_2:172.16.50.159
cassandra 版本:apache-cassandra-1.1.2-bin.tar.gz http://cassandra.apache.org/download/
文件放置的目录
D:\nosql\apache-cassandra-1.1.2(把apache-cassandra-1.1.2-bin.tar.gz 放到路径D:\nosql下并解压到当前文件夹下)
新建几个目录:
D:\nosql\apache-cassandra-1.1.2\work\data
D:\nosql\apache-cassandra-1.1.2\work\commitlog
D:\nosql\apache-cassandra-1.1.2\work\saved_caches
D:\nosql\apache-cassandra-1.1.2\work\log
pc_1:172.16.50.110
D:\nosql\apache-cassandra-1.1.2\conf\cassandra.yaml 文件修改
data_file_directories:
-d:/nosql/apache-cassandra-1.1.2/work/data
# commit log
commitlog_directory:d:/nosql/apache-cassandra-1.1.2/work/commitlog
# saved caches
saved_caches_directory: d:/nosql/apache-cassandra-1.1.2/work/saved_caches
seeds listen_address rpc_address
- seeds: "172.16.50.110,172.16.50.159"
rpc_address: 172.16.50.159
rpc_address: 172.16.50.159
行了
然后,在命令行,cmd
d:
cd D:\nosql\apache-cassandra-1.1.2\bin
cassandra
cassandra
就成了
C:\Users\xyuser>nodetool -host 172.16.50.110 ring
Starting NodeTool
Address DC Rack Status State Load Effective
-Ownership Token
100806591474214765194180135658536037084
172.16.50.110 datacenter1 rack1 Up Normal 38.8 KB 65.61%
42287584298666643063700995775504136179
172.16.50.159 datacenter1 rack1 Up Normal 54.14 KB 34.39%
100806591474214765194180135658536037084
C:\Users\xyuser>nodetool -host 172.16.50.110 info
Starting NodeTool
Token : 42287584298666643063700995775504136179
Gossip active : true
Thrift active : true
Load : 38.8 KB
Generation No : 1342593373
Uptime (seconds) : 3093
Heap Memory (MB) : 35.60 / 1015.69
Data Center : datacenter1
Rack : rack1
Exceptions : 0
Key Cache : size 240 (bytes), capacity 52428768 (bytes), 11 hits, 16 requ
ests, 1.000 recent hit rate, 14400 save period in seconds
Row Cache : size 0 (bytes), capacity 0 (bytes), 0 hits, 0 requests, NaN r
ecent hit rate, 0 save period in seconds
C:\Users\xyuser>
C:\Users\xyuser>nodetool -host 172.16.50.110 cfstats
Starting NodeTool
Keyspace: system
Read Count: 26
Read Latency: 1.118923076923077 ms.
Write Count: 14
Write Latency: 1.288357142857143 ms.
Pending Tasks: 0
Column Family: NodeIdInfo
SSTable count: 0
Space used (live): 0
Space used (total): 0
Number of Keys (estimate): 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
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 0
Compacted row minimum size: 0
Compacted row maximum size: 0
Compacted row mean size: 0
Column Family: Versions
SSTable count: 0
Space used (live): 0
Space used (total): 0
Number of Keys (estimate): 0
Memtable Columns Count: 3
Memtable Data Size: 148
Memtable Switch Count: 0
Read Count: 0
Read Latency: NaN ms.
Write Count: 3
Write Latency: NaN ms.
Pending Tasks: 0
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 0
Compacted row minimum size: 0
Compacted row maximum size: 0
Compacted row mean size: 0
Column Family: Schema
SSTable count: 0
Space used (live): 0
Space used (total): 0
Number of Keys (estimate): 0
Memtable Columns Count: 0
Memtable Data Size: 0
Memtable Switch Count: 0
Read Count: 1
Read Latency: NaN ms.
Write Count: 0
Write Latency: NaN ms.
Pending Tasks: 0
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 0
Compacted row minimum size: 0
Compacted row maximum size: 0
Compacted row mean size: 0
Column Family: schema_columns
SSTable count: 1
Space used (live): 5343
Space used (total): 5343
Number of Keys (estimate): 128
Memtable Columns Count: 0
Memtable Data Size: 0
Memtable Switch Count: 1
Read Count: 5
Read Latency: NaN ms.
Write Count: 1
Write Latency: NaN ms.
Pending Tasks: 0
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 16
Compacted row minimum size: 771
Compacted row maximum size: 924
Compacted row mean size: 924
Column Family: schema_keyspaces
SSTable count: 1
Space used (live): 4700
Space used (total): 4700
Number of Keys (estimate): 128
Memtable Columns Count: 0
Memtable Data Size: 0
Memtable Switch Count: 1
Read Count: 0
Read Latency: NaN ms.
Write Count: 1
Write Latency: NaN ms.
Pending Tasks: 0
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 16
Compacted row minimum size: 216
Compacted row maximum size: 258
Compacted row mean size: 258
Column Family: schema_columnfamilies
SSTable count: 2
Space used (live): 11320
Space used (total): 11320
Number of Keys (estimate): 256
Memtable Columns Count: 0
Memtable Data Size: 0
Memtable Switch Count: 2
Read Count: 1
Read Latency: NaN ms.
Write Count: 2
Write Latency: NaN ms.
Pending Tasks: 0
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 32
Compacted row minimum size: 1110
Compacted row maximum size: 1331
Compacted row mean size: 1331
Column Family: Migrations
SSTable count: 0
Space used (live): 0
Space used (total): 0
Number of Keys (estimate): 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
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 0
Compacted row minimum size: 0
Compacted row maximum size: 0
Compacted row mean size: 0
Column Family: IndexInfo
SSTable count: 1
Space used (live): 4535
Space used (total): 4535
Number of Keys (estimate): 128
Memtable Columns Count: 0
Memtable Data Size: 0
Memtable Switch Count: 1
Read Count: 2
Read Latency: NaN ms.
Write Count: 1
Write Latency: NaN ms.
Pending Tasks: 0
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 16
Compacted row minimum size: 87
Compacted row maximum size: 103
Compacted row mean size: 103
Column Family: HintsColumnFamily
SSTable count: 0
Space used (live): 0
Space used (total): 0
Number of Keys (estimate): 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
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 0
Compacted row minimum size: 0
Compacted row maximum size: 0
Compacted row mean size: 0
Column Family: LocationInfo
SSTable count: 3
Space used (live): 13836
Space used (total): 13836
Number of Keys (estimate): 384
Memtable Columns Count: 0
Memtable Data Size: 0
Memtable Switch Count: 3
Read Count: 17
Read Latency: 0.222 ms.
Write Count: 6
Write Latency: NaN ms.
Pending Tasks: 0
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 48
Compacted row minimum size: 73
Compacted row maximum size: 124
Compacted row mean size: 107
----------------
Keyspace: Twissandra
Read Count: 0
Read Latency: NaN ms.
Write Count: 0
Write Latency: NaN ms.
Pending Tasks: 0
Column Family: user
SSTable count: 0
Space used (live): 0
Space used (total): 0
Number of Keys (estimate): 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
Bloom Filter False Postives: 0
Bloom Filter False Ratio: 0.00000
Bloom Filter Space Used: 0
Compacted row minimum size: 0
Compacted row maximum size: 0
Compacted row mean size: 0
----------------
C:\Users\xyuser>