美文网首页Linux学习|Gentoo/Arch/FreeBSDLinuxHowtoLinux
如何在 Debian 10上安装 Apache Cassandr

如何在 Debian 10上安装 Apache Cassandr

作者: 等会再说 | 来源:发表于2019-12-26 16:53 被阅读0次
如何在 Debian 10上安装 Apache Cassandra

Apache Cassandra 是一个开源的、分布式、无中心、弹性可扩展、高可用、容错、一致性可调、面向行的数据库,它基于 Amazon Dynamo 的分布式设计和 Google Bigtable 的数据模型,由 Facebook 创建,在一些最流行的网站中得到应用。

Apache Cassandra 可以在 Linux、Unix、Mac OS 以及 Windows 上进行安装。在本文中,我们将说明如何在Debian 10 Buster上安装Apache Cassandra。

前提条件

这些说明假定您以root 用户具有sudo特权的用户身份登录。

安装Java

由于Apache Cassandra运行需要使用到Java,所以我们首先安装Java运行环境。在撰写本文时,Apache Cassandra的最新稳定版本是3.11并且需要OpenJDK 8。当然如果你安装的是Oracle JDK8也是没问题的。

Debian10上OpenJDK8的安装可以参考下面这篇文章,这里不在过多讲解。

如何在 Debian 10 上安装和卸载 OpenJDK11/OpenJDK8

https://www.linux265.com/news/3837.html

安装Apache Cassandra

将Cassandra的Apache存储库添加到/etc/apt/sources.list.d/cassandra.sources.list中,例如版本3.6:

echo "deb http://www.apache.org/dist/cassandra/debian 36x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

添加Apache Cassandra存储库密钥:

curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -

更新存储库:

sudo apt-get update

如果遇到此错误:

GPG error: http://www.apache.org 36x InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A278B781FE4B2BDA

然后,按如下所示添加公钥A278B781FE4B2BDA:

sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDA

实际的密钥可能有所不同,您可以从错误消息本身中获得密钥。 有关Apache贡献者公钥的完整列表,请参考此链接

更新软件包的索引并安装Apache Cassandra软件包:

sudo apt-get update
sudo apt-get install cassandra

安装过程完成后,Cassandra服务将自动启动。要验证Cassandra是否正在运行,请键入:

nodetool status

您应该看到类似下面的内容:

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load        Tokens       Owns (effective)  Host ID                               Rack
UN  127.0.0.1  103.71 KiB  256          100.0%            dd8f6709-08ef-45b8-881e-5c1b5bbfc7f7  rack1

而已。Apache Cassandra已成功安装。

配置Apache Cassandra

Apache Cassandra数据存储在/var/lib/cassandra目录中。配置文件位于中/etc/cassandra,并且可以在/etc/default/cassandra文件中配置Java启动选项。

默认情况下,Cassandra仅在localhost上侦听。如果连接到数据库的客户端也正在同一台计算机上运行,则无需更改绑定接口。

要通过命令行与Cassandra交互,请使用cqlsh随Cassandra软件包一起提供的工具。

cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.5 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> 

重命名Apache Cassandra集群

默认情况下,Cassandra群集被命名为“测试群集”。如果要更改它,请执行以下步骤:

01、使用以下命令登录到Cassandra CQL终端cqlsh

cqlsh

02、发出以下命令以将群集名称更改为“ Linuxize Cluster”:

UPDATE system.local SET cluster_name = 'Linuxize Cluster' WHERE KEY = 'local';

用您想要的名称更改“ Linux265 Cluster”。完成后,键入exit以退出终端。

03、编辑/etc/cassandra/cassandra.yaml配置文件,然后输入新的集群名称:

cluster_name: 'Linux265 Cluster'

04、清除系统缓存:

nodetool flush system

05、通过运行以下命令重新启动Cassandra服务:

sudo systemctl restart cassandra

写在最后

我们已经向您展示了如何安装Apache Cassandra Debian 10以及如何重命名默认集群。有关如何开始使用Cassandra的更多信息,请访问官方文档页面。

如果您遇到问题或有反馈,请在下面发表评论。

如果想了解更多Linux中命令使用,可以下载【Linux命令中文手册】,关注我后,公号里面回复“命令”即可下载。

相关文章

网友评论

    本文标题:如何在 Debian 10上安装 Apache Cassandr

    本文链接:https://www.haomeiwen.com/subject/tglloctx.html