BigData

분산DB-YugabyteDB - 클라우드 네이티브 분산 SQL 데이터베이스 설치 가이드

IT오이시이 2025. 10. 14. 13:38
728x90

 

(Linux)YugabyteDB Quick start  | YugabyteDB Docs

(MacOS) YugabyteDB Quick start | YugabyteDB Docs

🧠 YugabyteDB란?

YugabyteDB오픈 소스이며, 클라우드 네이티브 환경에 최적화된 분산 SQL 데이터베이스입니다. PostgreSQL과 호환되며, 고가용성과 확장성을 갖춘 구조로 설계되어 있어 대규모 클라우드 애플리케이션적합합니다.

 

🔍 주요 특징

  • 오픈 소스: 누구나 자유롭게 사용하고 수정할 수 있으며, 커뮤니티 중심으로 발전합니다.
  • 클라우드 네이티브: 퍼블릭 클라우드, 프라이빗 클라우드, Kubernetes 환경 등 다양한 클라우드 인프라에 쉽게 배포 가능.
  • 분산 SQL: 데이터를 여러 노드에 분산 저장하면서도 SQL 기능을 그대로 지원. PostgreSQL 호환 API(YSQL)와 Cassandra 기반 API(YCQL)를 제공.
  • 고가용성 및 복원력: 노드, 랙, 지역 단위의 장애에도 견딜 수 있는 구조. 자동 복구 및 스냅샷 기능 포함.
  • 확장성: 수평적 확장 지원. 노드를 추가함으로써 읽기/쓰기 성능을 향상시킬 수 있음.
  • 보안 기능: 인증, 권한 관리, 암호화(전송 중/저장 중), 감사 로깅 등 다양한 보안 기능 내장.

 

🛠️ 활용 예시

  • 멀티 리전 배포: 글로벌 비즈니스,  ActiveActiveDR구성 등 같은 여러 지역에 걸쳐 데이터베이스를 배포하여 지연 시간 최소화 및 데이터 지역성 확보.
  • 트랜잭션 처리: 분산 환경에서도 ACID 트랜잭션을 지원.
  • 개발자 친화적: Java, Python, Go 등 다양한 언어와 ORM/드라이버를 통해 쉽게 애플리케이션과 연결 가능.

 

🛠️ 1단계: 사전 준비

  • 운영체제: Linux, macOS, Windows (WSL 사용 가능)
  • 필수 도구:
    • Python 3.11 이상
    • wget 또는 curl
    • tar 명령어 (압축 해제용)

 

1.1  Basic Download and  Installation (Linux, MacOS)

#!/bin/bash

# 최신 버전 다운로드
#     https://docs.yugabyte.com/preview/releases/
#     https://docs.yugabyte.com/preview/releases/ybdb-releases/v2025.1/

# for MacOS
curl -OL https://software.yugabyte.com/releases/2025.1.1.1/yugabyte-2025.1.1.1-b1-darwin-x86_64.tar.gz

# for linux
wget https://software.yugabyte.com/releases/2025.1.1.1/yugabyte-2025.1.1.1-b1-linux-x86_64.tar.gz


# 압축 해제
tar xvfz yugabyte-2.25.2.0-b359-linux-x86_64.tar.gz


# 디렉토리 이동
cd yugabyte-2.25.2.0/


# 클러스터 시작
./bin/yugabyted start
./bin/yb-ctl create

# 특정 Port로 시작하는 경우
#./bin/yugabyted start --advertise_address 127.0.0.1
#./bin/yugabyted start --advertise_address 192.168.56.10

 

* yugabyted start log

더보기

# sh yugadb_run.sh start
Starting yugabyted...
✅ YugabyteDB Started
✅ UI ready
✅ Data placement constraint successfully verified

⚠ WARNINGS:
- open files ulimits value set low. Please set soft and hard limits to 1048576.
- max user processes ulimits value set low. Please set soft and hard limits to 12000.
- Cluster started in an insecure mode without authentication and encryption enabled. For non-production use only, not to be used without firewalls blocking the internet traffic.

Please review the following docs and rerun the start command:
- Quick start for Linux: https://docs.yugabyte.com/preview/quick-start/linux/

+--------------------------------------------------------------------------------------------------------+
|                                               yugabyted                                                |
+--------------------------------------------------------------------------------------------------------+
| Status              : Running.                                                                         |
| YSQL Status         : Ready                                                                            |
| Replication Factor  : 1                                                                                |
| YugabyteDB UI       : http://10.0.2.15:15433                                                           |
| JDBC                : jdbc:postgresql://10.0.2.15:5433/yugabyte?user=yugabyte&password=yugabyte        |
| YSQL                : bin/ysqlsh -h 10.0.2.15  -U yugabyte -d yugabyte                                 |
| YCQL                : bin/ycqlsh 10.0.2.15 9042 -u cassandra                                           |
| Data Dir            : /root/var/data                                                                   |
| Log Dir             : /root/var/logs                                                                   |
| Universe UUID       : 241b4daf-84b1-463a-9ff2-ea3115149b70                                             |
+--------------------------------------------------------------------------------------------------------+
🚀 YugabyteDB started successfully! To load a sample dataset, try 'yugabyted demo'.
🎉 Join us on Slack at https://www.yugabyte.com/slack
👕 Claim your free t-shirt at https://www.yugabyte.com/community-rewards/

 

* yb-ctl create  log

더보기

# ./bin/yb-ctl create
Creating cluster.
Waiting for cluster to be ready.


----------------------------------------------------------------------------------------------------
| Node Count: 1 | Replication Factor: 1                                                            |
----------------------------------------------------------------------------------------------------
| JDBC                : jdbc:postgresql://127.0.0.1:5433/yugabyte                                  |
| YSQL Shell          : bin/ysqlsh                                                                 |
| YCQL Shell          : bin/ycqlsh                                                                 |
| YEDIS Shell         : bin/redis-cli                                                              |
| Web UI              : http://127.0.0.1:7000/                                                     |
| Cluster Data        : /root/yugabyte-data                                                        |
----------------------------------------------------------------------------------------------------

For more info, please use: yb-ctl status

 

# for firewalld or iptables

# - zone(public)에 7000, 15433번 TCP Port를 오픈
# - --permanent 옵션을 사용하면 저장 후 재부팅 시에도 설정이 유지
sudo firewall-cmd --permanent --add-port=7000/tcp  --zone=public
sudo firewall-cmd --permanent --add-port=15433/tcp --zone=public

# - 변경된 포트 설정을 즉시 적용
sudo firewall-cmd --reload



# sudo firewall-cmd --list-ports
7000/tcp 15433/tcp



# sudo firewall-cmd --list-all-zones
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3 enp0s8
  sources:
  services: cockpit dhcpv6-client ssh
  ports: 7000/tcp 15433/tcp
  protocols:
  forward: yes
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

1. 2. Docker를 이용한 Install

# Docker 다운로드

docker pull software.yugabyte.com/yugabytedb/yugabyte:2025.1.1.1-b1
docker run -d --name yugabyte -p7000:7000 -p9000:9000 -p15433:15433 -p5433:5433 -p9042:9042  yugabytedb/yugabyte:2025.1.1.1-b1 bin/yugabyted start  --background=false

 

# Docker 실행과 접속

docker exec -it yugabyte bash -c '/home/yugabyte/bin/ysqlsh --echo-queries --host $(hostname)'

(참고) Install on  Docker - Download

 

2. YugaByteDB 실행

 

# Make sure you have downloaded and extracted the tar.gz file as shown above

./bin/ysqlsh

 

 

 

3. DB 스키마 생성 및 SQL 작성

 

3. 1. Load Sample Dataset

# 1. Load Sample Dataset

YugaByte=# CREATE DATABASE yb_demo;
YugaByte=# \c yb_demo;


yb_demo=# \i share/schema.sql
yb_demo=# \i share/products.sql
yb_demo=# \i share/users.sql
yb_demo=# \i share/orders.sql
yb_demo=# \i share/reviews.sql

 

3.2. Run Queries

 

yb_demo=# SELECT users.id, users.name, users.email, orders.id, orders.total\
            FROM orders INNER JOIN users ON orders.user_id=users.id\
            LIMIT 10;

 

 

 


4. 마이그레이션툴 : yb-voyager - Installation on Linux Centos, Rocky Package 

 

YugabyteDB로의 데이터 마이그레이션을 도와주는 오픈 소스 도구입니다.  기존에 사용하던 데이터베이스(MySQL, PostgreSQL, Oracle 등)의 데이터를 YugabyteDB로 안전하고 효율적으로 옮길 수 있게 해주는 마이그레이션 엔진 입니다.

🚀 yb-voyager의 핵심 기능

  • 데이터베이스 마이그레이션: MySQL, PostgreSQL, Oracle 등에서 YugabyteDB로 데이터 이전
  • 스키마 변환: 테이블 구조, 인덱스, 제약 조건 등을 YugabyteDB에 맞게 자동 변환
  • 데이터 추출 및 로딩: 대용량 데이터도 안정적으로 추출하고 YugabyteDB에 삽입
  • 병렬 처리 지원: 빠른 마이그레이션을 위한 멀티스레드 처리
  • CLI 기반: 명령줄에서 간단한 명령으로 마이그레이션 수행 가능

 

 

  • 기존 시스템을 YugabyteDB로 전환하고 싶을 때
  • 클라우드 네이티브 환경으로 데이터베이스를 이전할 때
  • PostgreSQL 호환성을 유지하면서 분산 데이터베이스로 확장하고 싶을 때

 

 

🚀 yb-voyager  사용방법

Perform the following steps to install yb-voyager using yum for RHEL 9 and CentOS 9:

  1. Update the yum package manager, and all the packages and repositories installed on your machine using the following command:

 

sudo dnf update

 

  • Install the yugabyte yum repository using the following command:
 sudo dnf install https://software.yugabyte.com/repos/reporpms/rhel-9/yb-yum-repo-1.1-0.noarch.rpm -y

 

  • Install the epel-release repository using the following command:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y

 

  • Install mysql-community-release repository using the following command:
sudo dnf install https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm -y

 

  • Install the PostgreSQL repositories using the following command:These repositories contain the rest of the dependencies required to run yb-voyager.
sudo dnf --disablerepo=* install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y

 

  • Disable the default PostgreSQL yum module on your machine using the following command:
sudo dnf -qy module disable postgresql

 

  • Install perl-open on your machine using the following command:
sudo dnf install perl-open.noarch -y

 

  • Install Oracle Instant Clients using the following command:
OIC_URL="https://download.oracle.com/otn_software/linux/instantclient/215000" && \
sudo dnf install -y \
    ${OIC_URL}/oracle-instantclient-tools-21.5.0.0.0-1.x86_64.rpm \
    ${OIC_URL}/oracle-instantclient-basic-21.5.0.0.0-1.x86_64.rpm \
    ${OIC_URL}/oracle-instantclient-devel-21.5.0.0.0-1.x86_64.rpm \
    ${OIC_URL}/oracle-instantclient-jdbc-21.5.0.0.0-1.x86_64.rpm \
    ${OIC_URL}/oracle-instantclient-sqlplus-21.5.0.0.0-1.x86_64.rpm

 

  • Update the yum package manager and all the packages and repositories installed on your machine using the following command:
sudo dnf update

 

 

🚀 yb-voyager  설치와 실행

 

  • Install yb-voyager and its dependencies using the following command:To install a specific version of yb-voyager on your machine, use the following command:
sudo dnf install yb-voyager-<VERSION>

 

sudo dnf install yb-voyager

 

  • Check that yb-voyager is installed using the following command:
  • yb-voyager version

 

Upgrade yb-voyager

Upgrade yb-voyager using the following command:

sudo yum update yb-voyager

 

🚀 yb-voyager  사용방법

# 스키마 추출
yb-voyager export schema --source-type mysql --source-db-name mydb --export-dir ./export

# 데이터 추출
yb-voyager export data --source-type mysql --source-db-name mydb --export-dir ./export

# YugabyteDB로 스키마 및 데이터 로딩
yb-voyager import schema --target-db-name ybdb --export-dir ./export
yb-voyager import data --target-db-name ybdb --export-dir ./export

 

 

 

 

 

 

 

 

 

 

 

728x90
반응형