官方安装文档:http://cassandra.apache.org/doc/latest/getting_started/installing.html
1.1.1. 一、下载并解压。
cassandra 是用java开发的,在linux 和windows 下面可以用一个安装包。所以linux 和windows下面都直接下面下面的安装包。
下载地址http://cassandra.apache.org/download/ 进去之后。点击下面的连接,进入下载页面。
这里我的下载是 http://mirrors.tuna.tsinghua.edu.cn/apache/cassandra/3.11.4/apache-cassandra-3.11.4-bin.tar.gz 。
下载完成后,直接解压。就可以使用。
1.1.2. 二、启动服务。
到apache-cassandra-3.11.4\bin
目录下面运行下面的命令。就可以运行cassandra服务:
- windows下面运行
cassandra.bat -f
启动服务。 - linux 下面运行
cassandra -f
启动服务。
使用-f选项告诉Cassandra保留在前台,而不是作为后台进程运行。如果一切顺利,您可以看到Cassandra服务器启动。
1.1.3. 三、查看服务是否启动。
使用 .\nodetool.bat status
用查看服务是否启动:
PS G:\apache-cassandra-3.11.4\bin> .\nodetool.bat status
Datacenter: datacenter1
========================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 187.63 KiB 256 100.0% dc71762e-61cb-41bc-85c2-62c49cf658c4 rack1
如果我们看到上面的信息,那么我们的测试服务已经正常启动了。而且会在 apache-cassandra-3.11.4 目录下生成 data 和 logs 两个目录。
1.1.4. 四、启动客户端。
以前可以通过apache-cassandra-3.11.4/bin/cassandra-cli.bat
操作cassandra数据库,从cassandra2.x之后,就没有了Cassandra CLI 的工具,而是CQL替代(即cqlsh.bat)。
cqlsh的官方文档:http://cassandra.apache.org/doc/latest/getting_started/querying.html#cqlsh
- windows下面运行 cqlsh.bat 启动客户端,连接服务器。
- linux 下面运行 cqlsh 启动客户端,连接服务器。
在启动 cqlsh 的时候可以指定节点和相应的端口:
bin/cqlsh localhost 9042
默认情况下就是连接本机的9042端口。
1.1.5. 参考博客:
https://www.iteblog.com/archives/2532.html
http://www.lingjiaocheng.com/d/cassandra_cassandra-create-keyspace-html/115/5383