Professional Documents
Culture Documents
1101
. .
. .
ssnr
ssnr
(ts sm)
(olumn ml) -
(ksp) -
(olumn) (ro)
(ro k)
:
(olumn nm),
(lu).
(tmstmp)
,
.
http://habrahabr.ru/post/155115/
).
;
.
BtsTp:
AsTp: ASCII
UTF8Type: UTF-8
IntrTp:
Int32Type: 4LongType: 8UUIDType: UUID 1TimeUUIDType: UUID 1DateType: 8BoolnTp:
FloatType: 4DoubleType: 8DmlTp:
CounterColumnType: 8-
4: tru = 1
ls = 0
(consistent hashing).
(token)
(rplton tor).
(ring).
(t runn).
,
http://habrahabr.ru/post/155115/
ONE;
TWO
THREE
QUORUM
LOCAL_QUORUM
EACH_QUORUM
ALL
ANY
,
:
ONE
TWO
THREE
QUORUM
LOCAL_QUORUM
EACH_QUORUM
ALL
http://habrahabr.ru/post/155115/
http://habrahabr.ru/post/155115/
:
(read repair)
(hinted handoff)
notool rpr
,
http://habrahabr.ru/post/155115/
(tombstone)
HBs: 4
. Cssnr
,
.
Cassandra
cluster-level
Compaction
:
Thrift
Cassandra
:
ASF
/t/pt/sours.lst
su root
mc
/etc/apt/sources.list
/t/pt/sours.lst
f4,
f2, y
PUBLIC_KEY
Cassandra
apt-get update
apt-get install cassandra
service cassandra restart
. CQLSH
cqlsh
CQL.
CQL SQLCassandra Query Language.
cqlsh.
C*
.
ksp (
).
Column Fml (
(
CQL
SQL
.
).
Column Fml,
tl)
CQL
USE twissandra;
CREATE COLUMNFAMILY users (
KEY varchar PRIMARY KEY,
password varchar,
gender varchar,
session_token varchar,
state varchar,
birth_year bigint);
C*
,
PRIMAR KE.
ALTER COLUMNFAMIL
,
.
oupono
varchar:
ALTER TABLE users ADD coupon_code varchar;
ALTER COLUMNFAMIL,
,
.
oupono
,
,
INSERT
86400
UPDATE
smt,
(TTL).
UPDATE
,
<columnFamily> DROP <column>.
,
:
ALTER TABLE
oupono
,
sttk
rtr
usrs.
:
1101
..
. .
Cssnr
1000000
.
(SELECT * FROM
names) :
:
SQLt,
Cssnr
PostrSQL
Brkl
:
1101
. .
. .
Pton
Cassandra
Ap
Python
Apache
Cassandra
Pton
Cssnr
pp
- pip install pycassa
Ap
pss,
ColumnFamily
ColumnFml:
col_fam.insert('row_key',
{'col_name':'col_val','col_name2':'col_val2'})
col_fam.get('row_key')
col_fam.multiget(['row1', 'row2'])
col_fam.get_count('row_key')
pool =
pycassa.ConnectionPool(keyspace='Keyspace
1', server_list=['10.0.0.4:9160', '10.0.0.5:9160'])
:
1101
. .
. .
. .
Apache Cassandra
Java
Apache Cassandra
Eclipse IDE
Maven 2 Eclipse plug-in
Eclipse
Maven
:
groupId: com.example.cassandra
artifactId: simple-client
Prot Vr
Maven > Add Dependency
tst
om.tst.ssnr
com.example.cassandra.SimpleClient
:
1101
. .
. .
. .
Apache Cassandra
cassandra.yaml
.
cluster_name ,
data_file_directories -
.
,
commitlog_directory -
saved_caches_directory .
seeds -
IP.
listen_address ,
,
, . .
5%
30%
- lolost.
Single-Node Cluster
ssnr.ml
ustrn: 'MCustrN
initial_token: 0
Snl-No,
root
Ubuntu (IP192.168.1.101)
nos P (IP192.168.1.100)
:
: 'JDNots Clustr'
cluster_name -
data_file_directories : d:\cassandra_data\data
nos
commitlog_directory :/var/lib/cassandra/commitlog.
nos
: d:\cassandra_data\commitlog
saved_caches_directory :/var/lib/cassandra/saved_caches.
Windows: d:\cassandra_data\saved_caches
seeds Uuntu.
192.168.1.101.
: /var/lib/cassandra/data.
listen_address 192.168.1.100.
: 192.168.1.101.
Ubuntu - 192.168.1.101,
, . .
0.0.0.0 -
nos P Gossp.
./cassandra -f
ssnr.ml:
node2
cluster_name: 'MyDemoCluster'
initial_token:56713727820156410577229101238628035
seed_provider:
- seeds: "110.82.155.0,110.82.155.3"
listen_address: 110.82.155.2
rpc_address: 0.0.0.0
endpoint_snitch: RackInferringSnitch
node0
cluster_name: 'MyDemoCluster'
initial_token: 0
seed_provider:
- seeds: "110.82.155.0,110.82.155.3"
listen_address: 110.82.155.0
rpc_address: 0.0.0.0
endpoint_snitch: RackInferringSnitch
node1
lustrnm: 'MDmoClustr
initial_token:2835686391007820528861455061931
seed_provider:
-seeds: "110.82.155.0,110.82.155.3"
listen_address: 110.82.155.1
rpc_address: 0.0.0.0
endpoint_snitch: RackInferringSnitch
node3
cluster_name: 'MyDemoCluster'
initial_token:850705917302346158658436518579420528
seed_provider:
- seeds: "110.82.155.0,110.82.155.3"
listen_address: 110.82.155.3
rpc_address: 0.0.0.0
endpoint_snitch: RackInferringSnitch
node4
cluster_name: 'MyDemoCluster'
initial_token: 113427455640312821154458202477256070485
seed_provider:
- seeds: "110.82.155.0,110.82.155.3"
listen_address: 110.82.155.4
rpc_address: 0.0.0.0
endpoint_snitch: RackInferringSnitch
node5
cluster_name: 'MyDemoCluster'
initial_token: 141784319550391026443072753096570088106
seed_provider:
- seeds: "110.82.155.0,110.82.155.3"
listen_address: 110.82.155.5
rpc_address: 0.0.0.0
endpoint_snitch: RackInferringSnitch
:
1101
. .
. .
. .
Apache Cassandra
PostgreSQL
1000
1000
10000
100000
Cassandra
0,000752
0,000315
0,00087
0,000864
Postgre
0,000237
0,000225
0,000184
0,000162
1000
10000
100000
Cassandra
0,0005
0,000616
0,000638
0,000878
Postgre
0,000395
0,000706
0,00122
0,009146
Cassandra
PostgreSQL
2008
1989
Java
BSD, Linux, OS X, Windows
Relational DBMS
CQL
PSQL
API
, ADO.NET,
JDBC ODBC
:
1101
. .
. .
..
CQL
SQL,
SELECT
UPDATE,
INSERT
,
CREATE INDE.
Apache Cassandra [
]:
,http://profyclub.ru/docs/172,
NoSQL-,
:
.
Cssnr 2.0
[
]:
-,
http://habrahabr.ru/post/203200/,
[
]:
: http://wiki.apache.org/cassandra,
p ssnr [
-,
:
http://habrahabr.ru/post/155115/,
CQL3
:
.
,-
.
]: