You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除/etc/apt/sources.list.d对象?并换方式安装Cassandra

移除/etc/apt/sources.list.d中的Cassandra源并更换安装方式

Got it, let's walk through removing that Cassandra APT source from /etc/apt/sources.list.d/ and then cover a couple of alternative installation methods. Here's how to do it step by step:

第一步:移除Cassandra的APT源配置

The /etc/apt/sources.list.d/ directory holds separate configuration files for each third-party APT repository. To remove the Cassandra one:

  • First, list all files in the directory to find the Cassandra-related config:
    ls /etc/apt/sources.list.d/
    
    Look for a file named something like cassandra.list or cassandra.sources (the exact name depends on how you added it).
  • Delete the file using sudo (replace <cassandra-config-file> with the actual filename you found):
    sudo rm /etc/apt/sources.list.d/<cassandra-config-file>
    
  • Update your APT cache to clear references to the removed source:
    sudo apt update
    

If you had previously installed Cassandra via APT, you might also want to purge the old installation and clean up residual files:

sudo apt remove --purge cassandra
sudo apt autoremove

第二步:替代安装方式

Here are two reliable alternatives to install Cassandra without using the APT source:

方式1:手动安装二进制包

This gives you full control over the installation directory and version:

  1. Download the binary tarball for your desired Cassandra version (you can grab it from the official Apache Cassandra site):
    wget https://downloads.apache.org/cassandra/<your-desired-version>/apache-cassandra-<your-desired-version>-bin.tar.gz
    
    Replace <your-desired-version> with the actual version number (e.g., 4.1.3).
  2. Extract the tarball:
    tar -xzf apache-cassandra-<your-desired-version>-bin.tar.gz
    
  3. Move the extracted directory to a permanent location (like /opt):
    sudo mv apache-cassandra-<your-desired-version> /opt/cassandra
    
  4. Set up environment variables to make Cassandra commands accessible system-wide. Edit your ~/.bashrc file (or /etc/profile for all users):
    nano ~/.bashrc
    
    Add these lines at the end:
    export CASSANDRA_HOME=/opt/cassandra
    export PATH=$PATH:$CASSANDRA_HOME/bin
    
  5. Apply the environment changes:
    source ~/.bashrc
    
  6. Start Cassandra (use -f to run in foreground, omit it for background):
    cassandra -f
    

方式2:用Docker安装Cassandra

If you prefer containerized deployments, Docker is a quick and clean option:

  1. First, install Docker if you don't have it already:
    sudo apt install docker.io
    sudo systemctl start docker
    sudo systemctl enable docker
    
  2. Pull the Cassandra Docker image for your desired version (use latest for the most recent stable version):
    sudo docker pull cassandra:<your-desired-version>
    
  3. Start a Cassandra container (maps port 9042, the default CQL port, to your host machine):
    sudo docker run -d --name cassandra-container -p 9042:9042 cassandra:<your-desired-version>
    
  4. Connect to the Cassandra instance using cqlsh inside the container:
    sudo docker exec -it cassandra-container cqlsh
    

内容的提问来源于stack exchange,提问作者MikiBelavista

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:05:32