Cassandra 集群安装部署

文章目录

    • 一、概述
      • 1.官方文档
      • 2. 克隆服务器
      • 3.安装说明
      • 4.安装准备
        • 4.1.安装 JDK 11
        • 4.2.安装 Python
        • 4.3.下载文件
    • 二、安装部署
      • 1.配置 Cassandra
      • 2.启动 Cassandra
      • 3.关闭Cassandra
      • 4.查看状态
      • 5.客户端连接服务器
      • 6.服务运行脚本

  • 开源中间件
# Cassandra

https://iothub.org.cn/docs/middleware/
https://iothub.org.cn/docs/middleware/cassandra/cassandra-deploy-cluster/

一、概述

1.官方文档

https://cassandra.apache.org/_/index.html
https://cassandra.apache.org/_/download.html


# 下载 cassandra-4.0.1
https://archive.apache.org/dist/cassandra/
https://archive.apache.org/dist/cassandra/4.0.1/

在这里插入图片描述

2. 克隆服务器

# 克隆机器

# 修改IP地址
cd /etc/sysconfig/network-scripts
vim ifcfg-ens33
192.168.202.156

# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld

# 设置主机名
hostnamectl set-hostname cassandra

3.安装说明

采用3台CentOS x64系统(虚拟机)

为每台虚拟机设置静态IP

  • 192.168.202.151 (seed)
  • 192.168.202.152 (seed)
  • 192.168.202.153

选择 151,、152 两台机器作为集群的种子节点(seed)。

服务器名称IP地址备注
Cassan-1192.168.202.151seed
Cassan-2192.168.202.152seed
Cassan-3192.168.202.153

4.安装准备

安装准备工作 3 台服务器都要操作。

4.1.安装 JDK 11

注意:Cassandra 使用 JAVA 语言开发,首先保证当前机器中已经安装 JDK 11

# 安装JDK 11 

# yum install java-11-openjdk -y

# java -version

# cd /usr/lib/jvm
[root@cassandra cassandra]# yum install java-11-openjdk -y


[root@cassandra cassandra]# java -version
openjdk version "11.0.22" 2024-01-16 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.22.0.7-1.el7_9) (build 11.0.22+7-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.22.0.7-1.el7_9) (build 11.0.22+7-LTS, mixed mode, sharing)


[root@cassandra cassandra]# cd /usr/lib/jvm
[root@cassandra jvm]# ll
total 0
drwxr-xr-x. 6 root root 68 Feb 28 19:22 java-11-openjdk-11.0.22.0.7-1.el7_9.x86_64
lrwxrwxrwx. 1 root root 21 Feb 28 19:22 jre -> /etc/alternatives/jre
lrwxrwxrwx. 1 root root 24 Feb 28 19:22 jre-11 -> /etc/alternatives/jre_11
lrwxrwxrwx. 1 root root 32 Feb 28 19:22 jre-11-openjdk -> /etc/alternatives/jre_11_openjdk
lrwxrwxrwx. 1 root root 42 Feb 28 19:22 jre-11-openjdk-11.0.22.0.7-1.el7_9.x86_64 -> java-11-openjdk-11.0.22.0.7-1.el7_9.x86_64
lrwxrwxrwx. 1 root root 29 Feb 28 19:22 jre-openjdk -> /etc/alternatives/jre_openjdk

在这里插入图片描述

4.2.安装 Python

注意:Cassandra的客户端的使用需要用的Python2.X版本。需要先安装Python2.X

[root@cassandra cassandra]# python -V
Python 2.7.5

在这里插入图片描述

4.3.下载文件
# 下载 4.0.1
# wget https://archive.apache.org/dist/cassandra/4.0.1/apache-cassandra-4.0.1-bin.tar.gz


# 解压
# tar -zxvf apache-cassandra-4.0.1-bin.tar.gz

[root@cassandra cassandra]# ll
total 48248
drwxr-xr-x. 8 root root      176 Feb 28 19:09 apache-cassandra-4.0.1
-rw-r--r--. 1 root root 49404559 Feb 28 19:08 apache-cassandra-4.0.1-bin.tar.gz


# 移动文件
[root@cassandra cassandra]# mv apache-cassandra-4.0.1 /usr/local/

[root@cassandra apache-cassandra-4.0.1]# ll
total 600
drwxr-xr-x. 2 root root    230 Feb 28 19:09 bin
-rw-r--r--. 1 root root   4832 Aug 30  2021 CASSANDRA-14092.txt
-rw-r--r--. 1 root root 434601 Aug 30  2021 CHANGES.txt
drwxr-xr-x. 3 root root   4096 Feb 28 19:09 conf
drwxr-xr-x. 3 root root     33 Feb 28 19:09 doc
drwxr-xr-x. 3 root root   4096 Feb 28 19:09 lib
-rw-r--r--. 1 root root  12960 Aug 30  2021 LICENSE.txt
-rw-r--r--. 1 root root 135759 Aug 30  2021 NEWS.txt
-rw-r--r--. 1 root root    349 Aug 30  2021 NOTICE.txt
drwxr-xr-x. 3 root root    230 Feb 28 19:09 pylib
drwxr-xr-x. 4 root root    169 Feb 28 19:09 tools

在这里插入图片描述

二、安装部署

1.配置 Cassandra

1.进入解压后的目录,创建3个 Cassandra 的数据文件夹

[root@cassandra apache-cassandra-4.0.1]# mkdir data
[root@cassandra apache-cassandra-4.0.1]# mkdir commitlog
[root@cassandra apache-cassandra-4.0.1]# mkdir saved-caches
[root@cassandra apache-cassandra-4.0.1]# pwd
/usr/local/apache-cassandra-4.0.1
[root@cassandra apache-cassandra-4.0.1]# mkdir data
[root@cassandra apache-cassandra-4.0.1]# mkdir commitlog
[root@cassandra apache-cassandra-4.0.1]# mkdir saved-caches

在这里插入图片描述

2.修改配置文件

在 conf 目录中找到 cassandra.yaml 配置文件,配置上面创建的3个数据目录

  • 配置 data_file_directories
data_file_directories:
    - /usr/local/apache-cassandra-4.0.1/data
  • 配置 commitlog_directory
commitlog_directory: /usr/local/apache-cassandra-4.0.1/commitlog
  • 配置 saved_caches_directory
saved_caches_directory: /usr/local/apache-cassandra-4.0.1/saved_caches
  • 集群配置

需要在每台机器的配置文件cassandra.yml中进行一些修改,包括

cluster_name 集群名字,每个节点都要一样

seeds 填写2个节点的ip作为 种子节点,每个节点的内容都要一样

listen_address 填写当前节点所在机器的IP地址

rpc_address 填写当前节点所在机器的IP地址

具体修改如下:

192.168.202.151机器修改的内容:7000

cluster_name: 'Cassandra Cluster'
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
    parameters:
         - seeds: "192.168.202.151,192.168.202.152"
listen_address: 192.168.202.151
rpc_address: 192.168.202.151

192.168.202.152 机器的修改内容

cluster_name: 'Cassandra Cluster'
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
    parameters:
         - seeds: "192.168.202.151,192.168.202.152"
listen_address: 192.168.202.152
rpc_address: 192.168.202.152

192.168.202.153 机器的修改内容

cluster_name: 'Cassandra Cluster'
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
    parameters:
         - seeds: "192.168.202.151,192.168.202.152"
listen_address: 192.168.202.153
rpc_address: 192.168.202.153

修改完成后,启动每个节点。可以在192.168.202.151机器上使用noodtools status 命令进行测试

2.启动 Cassandra

# cd /usr/local/apache-cassandra-4.0.1/bin

# ./cassandra -R
[root@cassandra /]# cd /usr/local/apache-cassandra-4.0.1/bin
[root@cassandra bin]# ll
total 152
-rwxr-xr-x. 1 root root 10542 Aug 30  2021 cassandra
-rw-r--r--. 1 root root  5667 Aug 30  2021 cassandra.in.sh
-rwxr-xr-x. 1 root root  2995 Aug 30  2021 cqlsh
-rwxr-xr-x. 1 root root 95408 Aug 30  2021 cqlsh.py
-rwxr-xr-x. 1 root root  1894 Aug 30  2021 debug-cql
-rwxr-xr-x. 1 root root  3491 Aug 30  2021 nodetool
-rwxr-xr-x. 1 root root  1770 Aug 30  2021 sstableloader
-rwxr-xr-x. 1 root root  1778 Aug 30  2021 sstablescrub
-rwxr-xr-x. 1 root root  1778 Aug 30  2021 sstableupgrade
-rwxr-xr-x. 1 root root  1781 Aug 30  2021 sstableutil
-rwxr-xr-x. 1 root root  1778 Aug 30  2021 sstableverify
-rwxr-xr-x. 1 root root  1175 Aug 30  2021 stop-server

在这里插入图片描述

[root@cassandra bin]# ./cassandra -R
[root@cassandra bin]# OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
CompileCommand: dontinline org/apache/cassandra/db/Columns$Serializer.deserializeLargeSubset(Lorg/apache/cassandra/io/util/DataInputPlus;Lorg/apache/cassandra/db/Columns;I)Lorg/apache/cassandra/db/Columns;
CompileCommand: dontinline org/apache/cassandra/db/Columns$Serializer.serializeLargeSubset(Ljava/util/Collection;ILorg/apache/cassandra/db/Columns;ILorg/apache/cassandra/io/util/DataOutputPlus;)V
CompileCommand: dontinline org/apache/cassandra/db/Columns$Serializer.serializeLargeSubsetSize(Ljava/util/Collection;ILorg/apache/cassandra/db/Columns;I)I

在这里插入图片描述

输入命令来查看正在运行的cassandra的 pid

ps -ef|grep cassandra

显示如图,pid 是 1746:
在这里插入图片描述

3.关闭Cassandra

刚才已经查到了 pid,现在可以使用命令杀掉这个pid对应的进程

kill -9 1746

4.查看状态

运行bin 目录下的 nodetool

[root@localhost bin]# ./nodetool status

# ./nodetool -Dcom.sun.jndi.rmiURLParsing=legacy status
# ./nodetool -h ::FFFF:127.0.0.1 status

在这里插入图片描述

# 问题
[root@cassandra bin]# ./nodetool status
nodetool: Failed to connect to '127.0.0.1:7199' - URISyntaxException: 'Malformed IPv6 address at index 7: rmi://[127.0.0.1]:7199'.


# 解决办法
[root@cassandra bin]# ./nodetool -Dcom.sun.jndi.rmiURLParsing=legacy status
[root@cassandra bin]# ./nodetool -h ::FFFF:127.0.0.1 status

5.客户端连接服务器

进入Cassandra的 bin 目录,输入

./cqlsh 192.168.202.151 9042


[root@cassandra-1 bin]# ./cqlsh 192.168.202.151 9042
Python 2.7 support is deprecated. Install Python 3.6+ or set CQLSH_NO_WARN_PY2 to suppress this message.

Connected to Cassandra Cluster at 192.168.202.151:9042
[cqlsh 6.0.0 | Cassandra 4.0.1 | CQL spec 3.4.5 | Native protocol v5]
Use HELP for help.
cqlsh> 

在这里插入图片描述

6.服务运行脚本

为了方便管理,可以编写脚本来管理,在 /usr/local/apache-cassandra-4.0.1 下创建一个 startme.sh,输入一下内容:

#!/bin/sh
CASSANDRA_DIR="/usr/local/apache-cassandra-4.0.1"
 echo "************cassandra***************"
case "$1" in
        start)

                echo "*                                  *"
                echo "*            starting              *"
                nohup $CASSANDRA_DIR/bin/cassandra -R >> $CASSANDRA_DIR/logs/system.log 2>&1 &
                echo "*            started               *"
                echo "*                                  *"
                echo "************************************"
                ;;
        stop)

                echo "*                                  *"
                echo "*           stopping               *"
                PID_COUNT=`ps aux |grep CassandraDaemon |grep -v grep | wc -l`
                PID=`ps aux |grep CassandraDaemon |grep -v grep | awk {'print $2'}`
                if [ $PID_COUNT -gt 0 ];then
                        echo "*           try stop               *"
                        kill -9 $PID
                        echo "*          kill  SUCCESS!          *"
                else
                        echo "*          there is no !           *"
                echo "*                                  *"
                echo "************************************"
                fi
                ;;
        restart)

                echo "*                                  *"
                echo "*********     restarting      ******"
                $0 stop
                $0 start
                echo "*                                  *"
                echo "************************************"
                ;;
        status)
                $CASSANDRA_DIR/bin/nodetool status
                ;;

        *)
        echo "Usage:$0 {start|stop|restart|status}"

        exit 1
esac

接下来就可以使用这个脚本进行 启动,重启,关闭 的操作

[root@cassandra-1 apache-cassandra-4.0.1]# ./startme.sh start
[root@cassandra-1 apache-cassandra-4.0.1]# ./startme.sh restart
[root@cassandra-1 apache-cassandra-4.0.1]# ./startme.sh stop
# chmod +x startme.sh


[root@cassandra-1 apache-cassandra-4.0.1]# ./startme.sh start
************cassandra***************
*                                  *
*            starting              *
*            started               *
*                                  *
************************************
[root@cassandra-1 apache-cassandra-4.0.1]# ./startme.sh restart
************cassandra***************
*                                  *
*********     restarting      ******
************cassandra***************
*                                  *
*           stopping               *
*           try stop               *
*          kill  SUCCESS!          *
************cassandra***************
*                                  *
*            starting              *
*            started               *
*                                  *
************************************
*                                  *
************************************
[root@cassandra-1 apache-cassandra-4.0.1]# ./startme.sh stop
************cassandra***************
*                                  *
*           stopping               *
*           try stop               *
*          kill  SUCCESS!          *
  • 开源中间件
# Cassandra

https://iothub.org.cn/docs/middleware/
https://iothub.org.cn/docs/middleware/cassandra/cassandra-deploy-cluster/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/456665.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

TikTok新手如何起号?环境因素与内容创新技巧

相信很多刚入行的TikTok玩家都遇到过一个难题,那就是账号权重低,播放量在个位数徘徊,其实都是因为还没起号!那么具体如何起号呢?下面小编也给大家分享一下技巧。 一、如何起号 1、明确注册 TikTok 账号的目的 无论是…

嵌入式3-14

1、整理思维导图 2、重写链表的代码 3、实现链表,按值查找返回位置的功能,按位置查找返回值,释放单链表,链表逆置 node_p create_link_list()//创建头结点 { node_p p(node_p)malloc(sizeof(node)); if(pNULL) { …

python中的常用模块

os和sys模块 os和sys是Python标准库中两个非常重要的模块,它们提供了丰富的方法来与Python解释器以及操作系统交互。 os模块 os模块提供了许多函数,用于处理文件和目录等操作系统任务,如路径管理、执行命令、获取进程信息等。 常用方法&a…

计算机网络-第7章 网络安全(1)

主要内容:安全威胁与问题、对称密钥密码体制和公钥密码体制、数字签名与鉴别、网络层和运输层安全协议、应用层电子邮件、系统安全:防火墙与入侵检测 当网络中的用户都来自社会各个阶层和部门时,网络中存储和传输的数据需要保护。 7.1 网络安…

【python开发】并发编程(上)

并发编程(上) 一、进程和线程(一)多线程(二)多进程(三)GIL锁 二、多线程开发(一)t.start()(二)t.join()(三)t.…

深入了解栈和队列

小伙伴们,今天我们来继续学习数据结构的第二部分内容,就是栈和队列了。那么栈和队列有什么用呢? 栈和队列是两种重要的线性结构。从数据结构的角度看,栈和队列也是线性表,其特殊性在于栈和队列的基本操作是线性表操作…

Linux系统部署Swagger Editor结合内网穿透实现公网管理本地接口文档

文章目录 Swagger Editor本地接口文档公网远程访问1. 部署Swagger Editor2. Linux安装Cpolar3. 配置Swagger Editor公网地址4. 远程访问Swagger Editor5. 固定Swagger Editor公网地址 正文开始前给大家推荐个网站,前些天发现了一个巨牛的 人工智能学习网站&#xf…

数据结构:图的存储与遍历(待续)

图(Graph)是一种较线性表和树更为复杂的非线性结构。在图结构中,对结点(图中常称为顶点)的前驱和后继个数不加限制, 即结点之间的关系是任意的。 一、基本概念和一般结论 因为一条边关联两个顶点&#xff0…

计算机服务器中了devos勒索病毒怎么解密,devos勒索病毒解密工具流程

随着网络技术的不断发展与更新,越来越多的企业利用网络开展了各项工作业务,网络也为企业提供了极大便利,大大提高了办公效率。但网络是一把双刃剑,企业的数据安全问题一直是企业关心的主要话题,近日,云天数…

如何在Windows搭建WebDav服务,并外网可访问

目录 1. 安装IIS必要WebDav组件 2. 客户端测试 3. 使用cpolar内网穿透,将WebDav服务暴露在公网 3.1 打开Web-UI管理界面 3.2 创建隧道 3.3 查看在线隧道列表 4. 公网远程访问 4.1 浏览器访问测试 4.2 映射本地盘符访问 4.3 安装Raidrive客户端 总结&…

由世界第一个AI软件工程师Devin引发的热潮背后----程序员到底会不会被代替?AI发展至如今是否初衷已变?

目录 一.Devin的登场是突破也是导火索 二.Devin的"逆天"能力 1、端到端构建和部署程序 2、自主查找并修复bug 3、训练和微调自己的AI模型 4、修复开源库 5、成熟的生产库也能做贡献 6、学习能力 三.Devin的出现甚至整个AI领域的进步,编程还有未来吗? 1.业…

机试:蛇形矩阵

问题描述: 代码示例: //蛇形矩阵 #include <bits/stdc.h> using namespace std;int main(){int n;cout << "输入样例" << endl; cin >> n;int k 1; for(int i 0; i < n; i){if( i %2 0){//单数行for(int j 0; j < n; j){ cout &…

国际前十正规外汇实时行情走势app软件最新排名(综合版)

外汇交易&#xff0c;作为当今世界金融市场上一个重要的板块&#xff0c;备受关注和热议。随着金融市场的日益发展&#xff0c;外汇交易也发展成为一个新兴的投资交易渠道。为了更好地满足投资者对外汇市场的需求&#xff0c;外汇实时行情走势app软件应运而生&#xff0c;它为投…

字符指针

1、字符指针 在指针的类型中我们知道有一种指针类型为字符指针 char* 一般使用方式&#xff1a; 还有使用方式如下&#xff1a; 注意观察区别&#xff1a;%C 与 %S &#xff1a; 这种方式是将字符串的首地址放到指针中&#xff0c;通过指针可以找到该字符串&#xff08;千万不要…

配置华为交换机环路检测案例

知识改变命运&#xff0c;技术就是要分享&#xff0c;有问题随时联系&#xff0c;免费答疑&#xff0c;欢迎联系&#xff01; ①微思网络&#xff0c;始于2002年&#xff01;专注IT认证培训22年。 ② 领取学习资料/课程咨询&#xff1a;小美老师&#xff08;wx&#xff09;&…

使用采购管理软件构建更高效的采购模式

采购流程是企业整个采购部门的关键要素。无论企业规模大小&#xff0c;构建采购流程的模式都将直接影响企业控制成本、管理风险和保持流程弹性的能力。 下面我们将解释采购模式的类型、优缺点&#xff0c;以及如何确定哪种模式最适合你的采购部门。 集中采购的优缺点 在集中采…

关于腾讯云服务器“地域”选择,地域四点因素请牢记!

腾讯云服务器地域怎么选择&#xff1f;不同地域之间有什么区别&#xff1f;腾讯云哪个地域好&#xff1f;地域选择遵循就近原则&#xff0c;访客距离地域越近网络延迟越低&#xff0c;速度越快。腾讯云百科txybk.com告诉大家关于地域的选择还有很多因素&#xff0c;地域节点选择…

关于nginx做正向代理的那些事

声明&#xff1a;该文章只是用于技术探索的实践与讨论&#xff0c;没有其他用途。 准备&#xff1a; 一台能访问外网的服务器&#xff1b;一个域名&#xff0c;映射到上面的服务器&#xff1b;https的证书及密钥&#xff1b;nginx安装包&#xff1b; 协议使用&#xff1a; 开…

neo4j网页无法打开,启动一会儿后自动关闭,查看neo4j status显示Neo4j is not running.

目录 前情提要User limit of inotify watches reached无法访问此网站 前情提要 公司停电&#xff0c;服务器未能幸免&#xff0c;发现无法访问此网站&#xff0c;http://0.0.0.0:7474 在此之前都还好着 User limit of inotify watches reached (base) [rootlocalhost ~]# n…

ctf_show笔记篇(web入门---sql注入)171-189

sql注入 171&#xff1a;简单的sql注入&#xff0c;尝试万能密码直接过 172&#xff1a;基础联合查询可过 173&#xff1a;过滤flag那就利用substr少取几个flag的名字或者replace 174&#xff1a;两种方法&#xff0c;使用盲注或者利用replace嵌套替换&#xff0c;然后在逆…
最新文章