下载 https://github.com/strapdata/elassandra
说明文档地址 http://doc.elassandra.io/en/latest/installation.html
解压 tar -xzf elassandra-6.2.3.17.tar.gz(或6.8.4.3)稳定版bug较少
修改环境变量
vim /etc/profile
export CASSANDRA_HOME=/home/tools/elassandra
生效source /etc/profile
查看echo $CASSANDRA_HOME
4. 启动(不能用root用户)
[root@localhost elassandra]# chown -R test /home/tools/elassandra
[root@localhost elassandra]# su test
bash-4.2$ bin/cassandra -e
查看
[root@localhost bin]# ./nodetool status
Datacenter: DC1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 80.98 KiB 8 100.0% 624413b4-b36b-4592-9855-c2fc267b87a7 r1
[root@localhost bin]# ./cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.3.5 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> desc keyspaces;
system_schema system system_distributed
system_auth elastic_admin system_traces
cqlsh> exit;
[root@localhost bin]# curl -X GET http://localhost:9200/
{
"name" : "127.0.0.1",
"cluster_name" : "Test Cluster",
"cluster_uuid" : "624413b4-b36b-4592-9855-c2fc267b87a7",
"version" : {
"number" : "6.2.3",
"build_hash" : "9d89799",
"build_date" : "2018-12-28T17:54:08.720333Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
测试(add/update)_id=1
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -H 'Content-Type: application/json' -d '
{
"user": "Poulpy",
"post_date": "2017/10/4 13:12:00",
"message": "Elassandra adds dynamic mapping to Cassandra"
}'
注意:必须用该方法创建表然后在Cassandra中用insert等操作才可以用es查询。
[root@localhost bin]# ./cqlsh
cqlsh> select * from twitter.tweet;
_id | message | post_date | user
-----+--------------------------------------------------+------------------------+------------
1 | ['Elassandra adds dynamic mapping to Cassandra'] | ['2017/10/4 13:12:00'] | ['Poulpy']
(1 rows)
cqlsh> INSERT INTO twitter.tweet ("_id", user, post_date, message) VALUES ( '2', ['Jimmy'], ['xxxx'], ['New data is indexed automatically']);
[root@localhost bin]# curl "localhost:9200/twitter/_search?q=user:Jimmy&pretty"
外网访问
vim conf/cassandra.yaml
rpc_address: 0.0.0.0
broadcast_rpc_address: 1.2.3.4
http://10.76.X.XX:9200/twitter/_search?q=user:Jimmy&pretty
elassandra的bug
问题一
"datas": {
"2018-05-07 05:00:00": {
"1.5": 92.515625
}
}
"1.5"插入报错,field不能含.而elasticsearch没这问题
问题二
"var": "rppi2"
--------------
"var": ["cappi","rppi2"]
var为数组,但是数组只有一个时,显示"var": “rppi2"而正确应该是"var”: [“rppi2”]
elasticsearch没这问题
问题三
不能删除
1、整表删除
cqlsh> drop table griddata.griddata ;
curl -XDELETE http://localhost:9200/griddata
rm -rm xx/elassandra/data/data/griddata
过几分钟数据自动恢复了,删除不了
2、删除某条数据
curl -XPOST http://localhost:9200/griddata/griddata/_delete_by_query
{
"query": {
"match": {"type": "radar_pub"
}
}
}
已删除数据过几分钟自动恢复
3、更新某条数据(更改改记录需更改索引)
过几分钟自动恢复(无法更新)
问题四
索引条数多了,无法新建和删除
参考:https://github.com/strapdata/elassandra/issues/105