Apache Cassandra:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第74行: 第74行:
<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
DESCRIBE keyspaces;
DESCRIBE keyspaces;
</syntaxhighlight>
使用<code>ks1</code>然後列出table:
<syntaxhighlight lang="sql">
USE ks1;
DESCRIBE tables;
</syntaxhighlight>
</syntaxhighlight>



2021年8月19日 (四) 17:43的版本

Apache Cassandra是一套资料库。

需求

开机就大约吃1.3GB左右,用2GB记忆体机器开机完就已经有吃到Swap了,最好是4GB记忆体,我这边是用AWSt4g.medium跑测试环境。

安装

先安装OpenJDK 11:

sudo apt install -y openjdk-11-jdk; sudo apt clean

再来安装Cassandra 4:

curl -L https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -; echo "deb http://www.apache.org/dist/cassandra/debian 40x main" | sudo tee /etc/apt/sources.list.d/cassandra.list; sudo apt update; sudo apt install -y cassandra

设定

防火墙

Port Usage Comment
7000/tcp Cluster communication
7001/tcp Cluster communication (TLS mode)
7199/tcp JMX
9042/tcp Native protocol

/etc/cassandra/cassandra.yaml

基本上一定会改的:

  • cluster_name改成自己要的名称。
  • listen_address改成自己的IP位置(但不能是0.0.0.0,有挡),这样外部才能连线。可以考虑直接用listen_interface
  • seeds改成第一台机器的IP位置与Port,这个参数只在第一次初始化整个Cassandra时用一次,后续的机器资讯都会存到硬碟里。如果没有用Cluster架构的话不需要改。

其他会改的:

  • commitlog_compression改用LZ4Compressor
  • endpoint_snitch改成Ec2Snitch或是Ec2MultiRegionSnitch,如果你的Cassandra架在AWS上。
  • hints_compression改用LZ4Compressor
  • internode_compression改成all

常用指令

cqlsh

使用cqlsh:

cqlsh cassandra-1.example.com -u root -p password

列出所有的keyspace:

DESCRIBE keyspaces;

使用ks1然后列出table:

USE ks1;
DESCRIBE tables;

其他指令

看目前Cluster的状态:

nodetool status

连结