如何在 Rocky Linux 9 上安装 Apache Cassandra

Linux命令 Edge插件网 2年前 (2023-03-09) 386次浏览 已收录 0个评论

Apache Cassandra是一个功能强大且高度可扩展的NoSQL数据库,非常适合需要高写入和读取吞吐量的用例。它是一个分布式、无主和对等数据库,易于扩展并向集群添加新节点,而不会中断整个系统。如何在 Rocky Linux 9 上安装 Apache Cassandra

在 Rocky Linux 9 上安装 Apache Cassandra

第 1 步。第一步是将系统更新到最新版本的软件包列表。为此,请运行以下命令:

<span class="pln">sudo dnf check</span><span class="pun">-</span><span class="pln">update
sudo dnf install dnf</span><span class="pun">-</span><span class="pln">utils</span>

第 2 步。安装爪哇。

Cassandra是用Java编写的,所以我们需要确保Java安装在我们的Rocky Linux系统上。现在运行以下命令来安装 Java:

<span class="pln">sudo dnf install java</span><span class="pun">-</span><span class="lit">11</span><span class="pun">-</span><span class="pln">openjdk</span>

使用以下命令检查是否安装了 Java:

<span class="pln">java </span><span class="pun">-</span><span class="pln">version</span>

有关 Java 的其他资源,请阅读下面的帖子:

  • 如何在 Rocky Linux √ 上安装 Java

第 3 步。安装蟒蛇。

您还需要安装Python,因为该工具是用python编写的。Cqlsh 是 Cassandra 的命令行界面;你需要安装 Python 来运行 Cassandra:cqlsh

<span class="pln">sudo dnf install python38</span>

接下来,使用 pip Python 包管理器进行安装:cqlsh

<span class="pln">pip3 install </span><span class="pun">--</span><span class="pln">user cqlsh</span>

有关 Python 的其他资源,请阅读下面的帖子:

  • 如何在 Rocky Linux √ 上安装 Python

第 4 步。在 Rocky Linux 9安装 Apache Cassandra

默认情况下,Apache Cassandra 在 Rocky Linux 9 AppStream 存储库中不可用。现在运行以下命令将 Apache Cassandra 存储库添加到您的系统中:

<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">yum</span><span class="pun">.</span><span class="pln">repos</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">cassandra</span><span class="pun">.</span><span class="pln">repo</span>

添加以下行:

<span class="pun">[</span><span class="pln">cassandra</span><span class="pun">]</span><span class="pln">
name</span><span class="pun">=</span><span class="typ">Apache</span> <span class="typ">Cassandra</span><span class="pln">
baseurl</span><span class="pun">=</span><span class="pln">https</span><span class="pun">:</span><span class="com">//downloads.apache.org/cassandra/redhat/40x/</span><span class="pln">
gpgcheck</span><span class="pun">=</span><span class="lit">1</span><span class="pln">
repo_gpgcheck</span><span class="pun">=</span><span class="lit">1</span><span class="pln">
gpgkey</span><span class="pun">=</span><span class="pln">https</span><span class="pun">:</span><span class="com">//downloads.apache.org/cassandra/KEYS</span>

保存并关闭文件,然后更新存储库缓存:

<span class="pln">sudo dnf update</span>

添加存储库后,我们可以安装 Cassandra。运行以下命令进行安装:

<span class="pln">sudo dnf install cassandra</span>

安装 Cassandra 后,我们可以启动该服务。运行以下命令以启动它:

<span class="pln">sudo systemctl enable cassandra
sudo systemctl start cassandra</span>

第5步。验证安装。

要验证 Cassandra 是否已安装并正确启动,请运行以下命令:

<span class="pln">nodetool status</span>

输出:

<span class="typ">Datacenter</span><span class="pun">:</span><span class="pln"> datacenter1
</span><span class="pun">=======================</span>
<span class="typ">Status</span><span class="pun">=</span><span class="typ">Up</span><span class="pun">/</span><span class="typ">Down</span>
<span class="pun">|</span><span class="str">/ State=Normal/</span><span class="typ">Leaving</span><span class="pun">/</span><span class="typ">Joining</span><span class="pun">/</span><span class="typ">Moving</span>
<span class="pun">--</span>  <span class="typ">Address</span>    <span class="typ">Load</span>       <span class="typ">Tokens</span>  <span class="typ">Owns</span> <span class="pun">(</span><span class="pln">effective</span><span class="pun">)</span>  <span class="typ">Host</span><span class="pln"> ID                               </span><span class="typ">Rack</span><span class="pln">
UN  </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span>  <span class="lit">46.12</span> <span class="typ">KiB</span>  <span class="lit">16</span>      <span class="lit">100.0</span><span class="pun">%</span>            <span class="lit">3De7fcci</span><span class="pun">-</span><span class="typ">Bgf9</span><span class="pun">-</span><span class="lit">4636</span><span class="pun">-</span><span class="lit">9bff</span><span class="pun">-</span><span class="lit">90d3tf10dc03</span><span class="pln">  rack1</span>

您还可以使用该命令与 Cassandra 集群进行交互:cqlsh

<span class="pln">cqlsh</span>

第 6 步。配置 Cassandra。

Cassandra 配置文件的默认位置为 。日志和数据目录的默认位置是 和 。/etc/cassandra/var/log/cassandra/var/lib/cassandra

在此文件中,您可以配置各种设置,例如集群名称、种子、侦听地址、数据文件目录等。

您使用本教程在 Rocky Linux 9 系统上安装 Apache Cassandra NoSQL 数据库。有关其他帮助或有用信息,我们建议您查看 Apache 官方网站


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Rocky Linux 9 上安装 Apache Cassandra
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址