Cassandra 安装部署

news2024/10/5 15:30:05

文章目录

    • 一、概述
      • 1.官方文档
      • 2. 克隆服务器
      • 3.安装准备
        • 3.1.安装 JDK 11
        • 3.2.安装 Python
        • 3.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/

一、概述

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.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

在这里插入图片描述

3.2.安装 Python

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

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

在这里插入图片描述

3.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
  • 配置 RPC
rpc_address: 192.168.202.156

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 是 1818:
在这里插入图片描述

3.关闭Cassandra

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

kill -9 1818

4.查看状态

运行bin 目录下的 nodetool

[root@localhost bin]# ./nodetool status

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

在这里插入图片描述

如果cassandra启动出错,可以在bin目录下 使用 journalctl -u cassandra 命令查看

[root@localhost bin]# journalctl -u cassandra
# 问题
[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.156 9042


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

Connected to Test Cluster at 192.168.202.156: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 apache-cassandra-4.0.1]# ./startme.sh start
[root@cassandra apache-cassandra-4.0.1]# ./startme.sh restart
[root@cassandra apache-cassandra-4.0.1]# ./startme.sh stop
# chmod +x startme.sh


[root@cassandra apache-cassandra-4.0.1]# ./startme.sh start
************cassandra***************
*                                  *
*            starting              *
*            started               *
*                                  *
************************************
[root@cassandra apache-cassandra-4.0.1]# ./startme.sh restart
************cassandra***************
*                                  *
*********     restarting      ******
************cassandra***************
*                                  *
*           stopping               *
*           try stop               *
*          kill  SUCCESS!          *
************cassandra***************
*                                  *
*            starting              *
*            started               *
*                                  *
************************************
*                                  *
************************************
[root@cassandra 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/

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

干货!不懂Python的math模块和random模块操作还不赶紧来学!

1.导入math模块 import math 2.向上取整:math.ceil() num 9.12print(math.ceil(num)) # 10 3.向下取整:math.floor() num1 9.99print(math.floor(num1)) # 9 4.开平方:math.sqrt()​​​​​​​ num2 16print(math.sqrt(num…

Python程序控制

一、程序的描述方式 1.1自然语言 (1)概念:自然语言就是使用人类语言、直接描述程序 (2)比如:之前提过的Input(输入)、Process(处理)、Output(输…

RabbitMQ - 02 - 基本消息模型

目录 部署demo项目 什么是基本消息模型 实现基本消息模型 部署demo项目 首先配置好一个mq的练习demo,并配置好相关依赖 链接:https://pan.baidu.com/s/1oXAqgoz9Y_5V7YxC_rLa-Q?pwdv2sg 提取码:v2sg 如图 父xml文件已经配置好了 AMQP依赖了 什么…

1.Python是什么?——跟老吕学Python编程

1.Python是什么?——跟老吕学Python编程 Python是一种什么样的语言?Python的优点Python的缺点 Python发展历史Python的起源Python版本发展史 Python的价值学Python可以做什么职业?Python可以做什么应用? Python是一种什么样的语言…

【Java从入门到精通】Java异常处理

异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免的。 比如说,你的代码少了一个分号,那么运行出来结果是提示是错误 java.lang.Error;如果你用System.out.println(11/0),那么…

Linux 安装Nginx (Nginx-1.25.4)

一、下载Nginx安装包 1.服务器联网的情况下,使用wget命令把Nginx安装包下载到/usr/local/目录中,如果没有wget命令,需要先安装:yum install -y wget cd /usr/local wget -c https://nginx.org/download/nginx-1.25.4.tar.gz ng…

AndroidStudio设计登录页源码(音悦app)

目录 一、代码 二、效果 一、代码 1.在activity_main.xml里的代码 <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android"android:layout_width"match_parent&quo…

elementUi中表格超出一行省略,鼠标放入显示完整提示

一、想要的效果 二、代码&#xff0c;加入show-overflow-tooltip即可 <el-table-column min-width"220" prop"content" show-overflow-tooltip> </el-table-column>

C语言深入理解指针(1)

前言 小陈也是学完了指针&#xff0c;还是有很多不多的地方&#xff0c;接下来会输出5篇博客去帮助自己彻底弄懂指针&#xff0c;以前的知识也需要复盘了呀。 内存和地址 1.1 内存 举个例子&#xff0c;去理解这两个的词&#xff0c;一个外卖员去送外卖&#xff0c;他首先需…

学习vue3使用在线官方开发环境play.vuejs.org进行测试

更多ruoyi-nbcio功能请看演示系统 gitee源代码地址 前后端代码&#xff1a; https://gitee.com/nbacheng/ruoyi-nbcio 演示地址&#xff1a; http://122.227.135.243:9666 更多nbcio-boot功能请看演示系统 gitee源代码地址 后端代码&#xff1a; https://gitee.com/nbach…

【maven下载、安装、配置教程】

一、下载 maven 官网&#xff1a;Maven – Download Apache Maven 注意&#xff1a;idea 和 maven 的版本问题&#xff0c;不然 idea 启动项目会发生兼容性错误。如 2020 版本 idea 支持 3.6.3 左右的 maven 版本&#xff0c;用 3.9版本的 maven 会报错。 二、配置maven全局配置…

meta元数据元素

文章目录 元数据Metadatameta标签的四种使用方式meta的属性meta使用示例 HTML <meta> 元素表示那些不能由其他 HTML标签&#xff08; <style>、 <script>等&#xff09;表示的元数据信息。 元数据Metadata Metadata元数据&#xff0c;简单地来说就是描述…

基岩多点位移计分体安装法的应用与技巧

在基岩多点位移计的安装过程中&#xff0c;当测杆过长或工作场地受限时&#xff0c;分体安装法成为了一种高效且实用的选择。这种安装方法能够确保位移计在复杂环境下仍能准确测量&#xff0c;为工程安全提供有力保障。 在分体安装法的实施过程中&#xff0c;需先将最深测点的测…

QPSK_NDATED_DDPED学习

该QPSK系统框图如下所示&#xff1a; 首先产生随机的四位整数&#xff0c;经过QPSK Modulator Baseband 进行星座图映射&#xff0c;然后经过脉冲整形和调制后发送到高斯带通信道中&#xff0c;在接收端首先进行解调&#xff0c;将带通信号转化为基带信号&#xff0c;再经过符号…

mysql中 多表查询介绍

在 MySQL 中&#xff0c;多表查询是 SQL 语句的重要组成部分&#xff0c;用于从两个或多个表中检索数据。多表查询可以帮助我们更灵活地处理复杂的数据关系&#xff0c;并从中获取所需的信息。以下是 MySQL 中常见的多表查询及其特点、区别和应用场景。 常见多表查询 1. **内连…

springboot264基于JAVA的民族婚纱预定系统的设计与实现

民族婚纱预定系统 摘 要 现代经济快节奏发展以及不断完善升级的信息化技术&#xff0c;让传统数据信息的管理升级为软件存储&#xff0c;归纳&#xff0c;集中处理数据信息的管理方式。本民族婚纱预定系统就是在这样的大环境下诞生&#xff0c;其可以帮助管理者在短时间内处理…

Lesson 6 Convolutional Neural Network(CNN)

听课&#xff08;李宏毅老师的&#xff09;笔记&#xff0c;方便梳理框架&#xff0c;以作复习之用。本节课主要讲了CNN的适用范围&#xff0c;整体架构与工作流程&#xff0c;CNN的应用&#xff0c;CNN的缺点以及解决方法。 1. CNN的输入与输出 CNN是专门为了图像而设计的一…

allegro PCB设计心得笔记(二) -- ERROR(SPMHUT-144): Illegal arc specification

使用Allegro PCB Editor设计PCB&#xff0c;其中使用了中文丝印&#xff0c;设计完成后&#xff0c;进行Tools -> Database Check&#xff0c;提示如下错误&#xff1a; 对PCB文件进行反复检查&#xff0c;也没有找到具体问题&#xff0c;但是删除中文丝印封装后&#xff0c…

算法---滑动窗口练习-1(长度最小的子数组)

长度最小的子数组 1. 题目解析2. 讲解算法原理3. 编写代码 1. 题目解析 题目地址&#xff1a;长度最小的子数组 2. 讲解算法原理 首先&#xff0c;定义变量n为数组nums的长度&#xff0c;sum为当前子数组的和&#xff0c;len为最短子数组的长度&#xff0c;初始值为INT_MAX&am…

Rust入门:C++和Rust动态库(dll)的相互调用

无论是C调用Rust动态库还是Rust调用C动态库&#xff0c;其操作基本都是一样地简单&#xff0c;基本和C调用C的动态库没什么区别&#xff0c;只需要列出所需要导入的函数&#xff0c;并链接到相应的lib文件即可。 这里&#xff0c;在windows中&#xff0c;我们以dll动态库为例说…