Custom Search
Showing posts with label Cassandra. Show all posts
Showing posts with label Cassandra. Show all posts

Friday, December 18, 2015

cassandra cluster status when a node goes down

1)
When all 3 nodes in the cluster up

# nodetool status

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address       Load       Tokens  Owns (effective)  Host ID                               Rack
UN  10.140.15.59  75.4 KB    256     100.0%            a07836a2-8c56-4da7-803d-4389f87a4854  rack1
UN  10.140.15.61  256.7 KB   256     100.0%            00c51f6a-2d08-4b27-81f9-b9754b6b0b66  rack1
UN  10.140.15.60  90.74 KB   256     100.0%            d89d9cd8-d154-43d9-97ec-6b827c9a7ced  rack1

2)
When the node 10.140.15.61 is down

# nodetool status

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address       Load       Tokens  Owns (effective)  Host ID                               Rack
UN  10.140.15.59  75.4 KB    256     100.0%            a07836a2-8c56-4da7-803d-4389f87a4854  rack1
DN  10.140.15.61  256.7 KB   256     100.0%            00c51f6a-2d08-4b27-81f9-b9754b6b0b66  rack1
UN  10.140.15.60  90.74 KB   256     100.0%            d89d9cd8-d154-43d9-97ec-6b827c9a7ced  rack1

Tuesday, December 15, 2015

How to setup cassandra zookeeper and rabbitmq cluster

1)
Nodes:

ct1-multinode-cont : 11.120.15.59
ct2-multinode-cont : 11.120.15.60
ct3-multinode-cont : 11.120.15.61

2)
zookeeper cluster:


a)
config:


$vim /etc/zookeeper/conf/zoo.cfg

server.59=11.120.15.59:2888:3888
server.60=11.120.15.60:2888:3888
server.61=11.120.15.61:2888:3888

b)
Check cluster status

b1)
$ /usr/share/zookeeper/bin/zkServer.sh status
JMX enabled by default
Using config: /etc/zookeeper/conf/zoo.cfg
Mode: follower

b2)
$ /usr/share/zookeeper/bin/zkServer.sh status
JMX enabled by default
Using config: /etc/zookeeper/conf/zoo.cfg
Mode: leader
 
b3)
From  11.120.15.61



$ /usr/share/zookeeper/bin/zkServer.sh status
JMX enabled by default
Using config: /etc/zookeeper/conf/zoo.cfg
Mode: follower

c)
docs:

http://myjeeva.com/zookeeper-cluster-setup.html

http://hanishblogger.blogspot.in/2013/11/zookeeper-setup-in-distributed-mode.html

3)
cassandra cluster:


a)
config:


$/etc/cassandra/cassandra.yaml
cluster_name: 'contrail'

seed_provider:
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          - seeds: 11.120.15.59,11.120.15.60,11.120.15.61
b)
Check cluster status  
 
# nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address       Load       Tokens  Owns (effective)  Host ID                               Rack
UN  11.120.15.59  75.4 KB    256     100.0%            a07836a2-8c56-4da7-803d-4389f87a4854  rack1
UN  11.120.15.61  256.7 KB   256     100.0%            00c51f6a-2d08-4b27-81f9-b9754b6b0b66  rack1
UN  11.120.15.60  90.74 KB   256     100.0%            d89d9cd8-d154-43d9-97ec-6b827c9a7ced  rack1


c)
docs:

https://docs.datastax.com/en/cassandra/2.0/cassandra/initialize/initializeSingleDS.html

4)
rabbitmq cluster config:


a)
config:

http://blog.hemantthorat.com/setup-rabbitmq-clusters-on-ubuntu/#.Vm-7a5PoEc0

b)
Check cluster status  
 
$ sudo rabbitmqctl cluster_status
Cluster status of node 'rabbit@ct1-multinode-cont' ...
[{nodes,[{disc,['rabbit@ct1-multinode-cont','rabbit@ct2-multinode-cont',
                'rabbit@ct3-multinode-cont']}]},
 {running_nodes,['rabbit@ct2-multinode-cont','rabbit@ct3-multinode-cont',
                 'rabbit@ct1-multinode-cont']},
 {cluster_name,<<"rabbit@localhost">>},
 {partitions,[]}]


Wednesday, March 18, 2015

how to cassandra Convert hex byte values into a human readable format

1)
Open cassandra cli

#cassandra-cli

[..] help;
[..] show keyspaces;
[..] use config_db_uuid; <== select a keyspace/database
[..] List obj_uuid_table; <== Reading Rows and Columns of a table



* Cassandra stores all data internally as hex byte arrays by default. If you do not specify a default row key validation class, column comparator and column validation class when you define the column family, Cassandra CLI will expect input data for row keys, column names, and column values to be in hex format (and data will be returned in hex format).
http://www.datastax.com/docs/1.1/dml/using_cli


ASSUME obj_uuid_table KEYS AS utf8;
ASSUME obj_uuid_table COMPARATOR AS utf8;
ASSUME obj_uuid_table VALIDATOR AS utf8;


OR

ASSUME obj_uuid_table KEYS AS ascii;
ASSUME obj_uuid_table COMPARATOR AS ascii;
ASSUME obj_uuid_table VALIDATOR AS ascii;


[..]List obj_uuid_table <== Reading Rows and Columns of a table

2)
Reset

ASSUME obj_uuid_table KEYS AS bytes;
ASSUME obj_uuid_table COMPARATOR AS bytes;
ASSUME obj_uuid_table VALIDATOR AS bytes;



Getting Started Using the Cassandra CLI

1)
Open cassandra cli

#cassandra-cli

[..] help;
[..] show keyspaces;
[..] show schema
[..] use config_db_uuid: <== select a keyspace/database
[..]List obj_uuid_table <== Reading Rows and Columns of a table



* Cassandra stores all data internally as hex byte arrays by default. If you do not specify a default row key validation class, column comparator and column validation class when you define the column family, Cassandra CLI will expect input data for row keys, column names, and column values to be in hex format (and data will be returned in hex format).
http://www.datastax.com/docs/1.1/dml/using_cli

2)
Query from table with id


[..] get obj_uuid_table[utf8('d123ad89-f047-40ee-8878-4b9b05dfa513')];
<=== passing id of ipam in utf8()
=> (name=66715f6e616d65, value=["default-domain", "admin", "ipam34"], timestamp=1426111375529317)
=> (name=706172656e743a70726f6a6563743a35663037653331622d643961382d346539392d613963642d663039643161663164623231, value=null, timestamp=1426111375529098)
=> (name=706172656e745f74797065, value="project", timestamp=1426111375529317)
=> (name=70726f703a646973706c61795f6e616d65, value="ipam34", timestamp=1426111375529289)
=> (name=70726f703a69645f7065726d73, value={"enable": true, "uuid": {"uuid_mslong": 15070079586065137902, "uuid_lslong": 9833692915554034963}, "creator": null, "created": "2015-03-11T22:02:55.529187", "user_visible": true, "last_modified": "2015-03-11T22:02:55.529187", "permissions": {"owner": "cloud-admin", "owner_access": 7, "other_access": 7, "group": "admin", "group_access": 7}, "description": null}, timestamp=1426111375529239)
=> (name=70726f703a6e6574776f726b5f6970616d5f6d676d74, value={"ipam_dns_method": "default-dns-server", "ipam_dns_server": {"tenant_dns_server_address": {}, "virtual_dns_server_name": null}}, timestamp=1426111375529153)
=> (name=74797065, value="network_ipam", timestamp=1426111375529317)
Returned 7 results.
Elapsed time: 20 msec(s).
[..]

OR

[..]ASSUME obj_uuid_table KEYS AS utf8
[..]get obj_uuid_table['d123ad89-f047-40ee-8878-4b9b05dfa513'];



3)

Convert hex values into a human-readable format

ASSUME obj_uuid_table KEYS AS utf8;
ASSUME obj_uuid_table COMPARATOR AS utf8;
ASSUME obj_uuid_table VALIDATOR AS utf8;


OR

ASSUME obj_uuid_table KEYS AS ascii;
ASSUME obj_uuid_table COMPARATOR AS ascii;
ASSUME obj_uuid_table VALIDATOR AS ascii;


[..]List obj_uuid_table <== Reading Rows and Columns of a table


Sunday, March 15, 2015

Tutorial Cassandra Query Language (CQL) commands using cqlsh utility

The Cassandra installation includes the cqlsh utility, a python-based command line client for executing Cassandra Query Language (CQL) commands. The cqlsh command is used on the Linux or Windows command line to start the cqlsh utility.

You can use cqlsh to execute CQL commands interactively. cqlsh supports tab completion. http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cqlsh.html



#cqlsh

cqlsh> help

cqlsh> help DESCRIBE

cqlsh> DESCRIBE KEYSPACES;

cqlsh> DESCRIBE KEYSPACE [mykeyspce];

cqlsh> DESCRIBE TABLES <== Show all the tables in all keyspaces

cqlsh> help USE

cqlsh> USE [name]; <== Goto keyspace/database

cqlsh:> DESCRIBE TABLES <== Show all the tables in selected keyspace

cqlsh:> DESCRIBE TABLE  [tablename]; <== Describe the table in the selected keyspace.

cqlsh:> help SELECT


1)
Delete  Keyspace
cqlsh> DROP KEYSPACE config_db_uuid;

2)
a)
cqlsh> DESCRIBE TABLES
Keyspace "DISCOVERY_SERVER"
---------------------------
discovery

b)
cqlsh> DESCRIBE table DISCOVERY_SERVER.discovery

CREATE TABLE discovery (
  key blob,
  column1 ascii,
  column2 text,
  column3 text,
  value ascii,
  PRIMARY KEY (key, column1, column2, column3)
) WITH COMPACT STORAGE AND
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=0 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

cqlsh>

c)
cqlsh> use "DISCOVERY_SERVER";
cqlsh:DISCOVERY_SERVER>

* Imp, use double quotes

d)
cqlsh:DISCOVERY_SERVER> select * from discovery limit 1;

 key                | column1 | column2                | column3        | value
--------------------+---------+------------------------+----------------+--------------------------------------------------------------------------------
 0x4f70536572766572 |  client | vpc-cfg1:ContrailWebUI | $client-entry$ | {"instances": 20, "client_type": "ContrailWebUI", "remote": "192.168.100.185"}

e)
Get all services/publisher
cqlsh:DISCOVERY_SERVER> select * from discovery where column1 = 'service' ALLOW FILTERING;

f)
Get all clients
cqlsh:DISCOVERY_SERVER> select * from discovery where column1 = 'client' ALLOW FILTERING;

g)
Get all subscribers
cqlsh:DISCOVERY_SERVER> select * from discovery where column1 = 'subscriber' ALLOW FILTERING;