웹사이트 검색

Debian 11에 Apache Cassandra를 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. 자바 설치
  3. 카산드라 설치
  4. Apache Cassandra 클러스터 확인\n
  5. Cassandra 구성
  6. 결론

Apache Cassandra는 무료 오픈 소스 분산 데이터베이스 관리 시스템입니다. 여러 서버에서 대량의 데이터를 처리할 수 있으며 단일 장애 지점 없이 고가용성을 제공합니다. Github, NetFlix, Reddit 및 Instagram을 포함한 많은 회사에서 사용합니다. Cassandra는 피어 투 피어 아키텍처에서 작동하며 각 노드는 다른 모든 노드에 연결됩니다. 각 Cassandra 노드는 모든 데이터베이스 작업을 수행하고 마스터 노드 없이도 클라이언트 요청을 처리할 수 있습니다.

이 게시물에서는 Debian 11에 Apache Cassandra 데이터베이스 관리 시스템을 설치하는 방법을 보여줍니다.

전제 조건

  • Debian 11을 실행하는 서버.\n
  • 루트 암호는 서버에서 구성됩니다.\n

자바 설치

시작하기 전에 서버에 Java를 설치해야 합니다. 다음 명령을 실행하여 설치할 수 있습니다.

apt-get install openjdk-11-jre -y

Java를 설치한 후 다음 명령을 사용하여 Java 설치를 확인하십시오.

java -version

다음 출력이 표시되어야 합니다.

openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)

카산드라 설치

기본적으로 Cassandra 패키지는 Debian 11 기본 리포지토리에 포함되어 있지 않습니다. 따라서 Cassandra 저장소를 APT에 추가해야 합니다.

먼저 다음 명령을 사용하여 필요한 종속 항목을 설치합니다.

apt-get install curl gnupg2 -y

다음으로 다음 명령을 사용하여 Cassandra GPG 키와 리포지토리를 추가합니다.

curl https://downloads.apache.org/cassandra/KEYS | apt-key add -
echo "deb https://downloads.apache.org/cassandra/debian 40x main" | tee -a /etc/apt/sources.list.d/cassandra.list

리포지토리가 추가되면 리포지토리를 업데이트하고 다음 명령을 사용하여 Cassandra 패키지를 설치합니다.

apt-get update -y
apt-get install cassandra -y

Cassandra가 설치되면 다음 명령을 사용하여 Cassandra의 상태를 확인할 수 있습니다.

systemctl status cassandra

다음 출력이 표시되어야 합니다.

? cassandra.service - LSB: distributed storage system for structured data
     Loaded: loaded (/etc/init.d/cassandra; generated)
     Active: active (running) since Sat 2021-09-25 17:23:08 UTC; 23s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 24537 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS)
      Tasks: 53 (limit: 9510)
     Memory: 2.2G
        CPU: 23.439s
     CGroup: /system.slice/cassandra.service
             ??24666 /usr/bin/java -ea -da:net.openhft... -XX:+UseThreadPriorities -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+AlwaysPreTouc>

Sep 25 17:23:08 debian11 systemd[1]: Starting LSB: distributed storage system for structured data...
Sep 25 17:23:08 debian11 systemd[1]: Started LSB: distributed storage system for structured data.

Apache 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  69.09 KiB  16      100.0%            2813344d-5006-4360-a57e-61deeea9fe70  rack1

그런 다음 다음 명령을 사용하여 Cassandra 클러스터에 연결합니다.

cqlsh

다음 출력이 표시되어야 합니다.

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

카산드라 구성

Cassandra 클러스터 이름을 변경하려면 다음 명령을 실행합니다.

cqlsh> UPDATE system.local SET cluster_name = 'New Cluster' WHERE KEY = 'local';

그런 다음 다음 명령을 사용하여 cqlsh 셸을 종료합니다.

cqlsh> exit

다음으로 Cassandra 기본 구성 파일을 편집합니다.

nano /etc/cassandra/cassandra.yaml

아래와 같이 Cassandra 클러스터 이름을 변경합니다.

cluster_name: 'New Cluster'

파일을 저장하고 닫은 다음 Cassandra 서비스를 다시 시작하여 변경 사항을 적용합니다.

systemctl restart cassandra

그런 다음 다음 명령을 사용하여 클러스터 이름을 확인합니다.

cqlsh

다음 출력에 새 클러스터 이름이 표시되어야 합니다.

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

결론

축하합니다! Debian 11에 Apache Cassandra를 성공적으로 설치했습니다. 이제 요구 사항에 따라 Apache Cassandra를 사용할 수 있습니다.