본문 바로가기
연구노트

SingleStore Hands-On #1 DB 설치 : SingleStore, PostgreSQL, MySQL

by 에이플랫폼 [Team SingleStore Korea] 2023. 11. 2.

💻 Linux Machine Setup

하나의 장비에 SingleStore, PostgreSQL, MySQL 을 함께 설치할 Linux Server 를 설정합니다.

장비 사양

CPU : 8 vCPU

Memory: 16GB (32GB 권장)

HDD(SSD) : 70GB 이상

O/S : Red Hat 계열 version 7

(이 문서는 Oracle Linux 7 기준으로 작성되었습니다)

 

sudo 권한 확보

현재 사용하는 계정명은 opc 입니다. 이 계정에 sudo 권한을 설정할 경우 root 계정에서 다음 명령어를 수행합니다.

* 이미 sudo 권한이 부여됐다면 이 스텝은 건너 뛸 수 있습니다.

# visudo -f /etc/sudoers

가장 아래 라인에 다음 추가 
opc  ALL=(ALL)     NOPASSWD:ALL
 

 

SELinux Disable

SELinux 가 설정되어 있는 경우는 sestatus 명령어를 수행하면 enabled 로 나타납니다.

root 계정에서 SELINUX 항목을 disabled 로 수정하고 reboot 합니다.

* 이미 SELinux 가 disabled 로 설정되어 있다면 이 스텝은 건너 뛸 수 있습니다.

# sestatus

SELinux status: enabled
...

# vi /etc/selinux/config

SELINUX=disabled

# reboot

 

Firewall 설정

이번 포스트부터 6회에 걸쳐 테스트할 Hands-On 에서는 방화벽 설정이 필요없습니다.

혹시 Linux 환경이 달라 방화벽을 오픈해야 한다면 아래 명령어로 Port 를 Open 합니다.

sudo firewall-cmd --zone=public --permanent --add-port=22/tcp
sudo firewall-cmd --zone=public --permanent --add-port=3306/tcp
sudo firewall-cmd --zone=public --permanent --add-port=3307/tcp
sudo firewall-cmd --zone=public --permanent --add-port=3308/tcp
sudo firewall-cmd --zone=public --permanent --add-port=443/tcp
sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
sudo firewall-cmd --zone=public --permanent --add-port=3360/tcp
sudo firewall-cmd --zone=public --permanent --add-port=5432/tcp
sudo firewall-cmd --reload
 

🚀 SingleStore 설치

SingleStore Cluster 는 하나의 Box 에 1 Master Aggregator, 1 Leaf 를 동시에 두는 cluster-in-box 형식으로 설치합니다.

License Key 는 다음 링크를 통해 Sign Up 하면 무료 License Key 를 받을 수 있습니다.

http://www.singlestore.com

이미 가입하셨다면 SingleStore Portal 로 로그인해서 License Key 를 확인하실 수 있습니다.

http://portal.singlestore.com


다음 명령어를 수행해 SingleStore 를 설치합니다.

<LICENSE KEY> 는 위에서 받은 Key 를 사용합니다.

sudo yum-config-manager --add-repo https://release.memsql.com/production/rpm/x86_64/repodata/memsql.repo
sudo yum install -y singlestore-client singlestoredb-toolbox singlestoredb-studio
sdb-deploy cluster-in-a-box --password 1234 --license <LICENSE KEY>

설치가 모두 끝나면 아래와 같은 Node List 화면이 보입니다.

▶ MemSQL ID 는 Node 별로 랜덤하게 부여됩니다.

▶ Host 는 127.0.0.1 즉 localhost 하나로 설정되어 있습니다.

▶ 하나의 Host 에 Master / Leaf Node 가 각각 3306, 3307 Port 를 사용하며 설치되어 있습니다.

sts
+-----------+------------+-------------+---------------+
|   Host    | Local Host | SSH address | Identity File |
+-----------+------------+-------------+---------------+
| 127.0.0.1 | Yes        |             |               |
+-----------+------------+-------------+---------------+
Nodes
+------------+--------+-----------+------+---------------+--------------+---------+----------------+--------------------+--------------+
| MemSQL ID  |  Role  |   Host    | Port | Process State | Connectable? | Version | Recovery State | Availability Group | Bind Address |
+------------+--------+-----------+------+---------------+--------------+---------+----------------+--------------------+--------------+
| 157B219007 | Master | 127.0.0.1 | 3306 | Running       | True         | 7.8.14  | Online         |                    | 127.0.0.1    |
| 11F1FA1BA1 | Leaf   | 127.0.0.1 | 3307 | Running       | True         | 7.8.14  | Online         | 1                  | 127.0.0.1    |
+------------+--------+-----------+------+---------------+--------------+---------+----------------+--------------------+--------------+

 

SingleStore 에 접속합니다. 이 때 password 는 설치할 때 명시했던 1234 를 입력합니다.

테스트 전반에 걸쳐 Disk 부족현상을 줄이기 위해 Tansaction Log 파일 크기를 디폴트 256MB 에서 64MB 로 변경 후 database 를 생성합니다.

$ singlestore -p

set global log_file_size_partitions=67108864;

create database airportdb;
exit
 

🚘 PostgreSQL 설치

PostgreSQL 은 다음 명령어를 수행하여 설치합니다.

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql14-server
 

설치가 완료되면 PostgreSQL Cluster 를 초기화하고 postgresql-14 서비스를 기동합니다.

sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl start postgresql-14

 

향후 Socket 접속, 데이터 로딩, Query 테스트를 위해 다음 명령어를 수행합니다.

▶ create user 시 사용중인 O/S 계정(예 opc) 을 지정합니다.

▶ pg_read_server_files Role 을 부여할 때도 사용중인 O/S 계정(예 opc) 을 지정합니다.

sudo -u postgres psql

create user opc password '1234';
grant pg_read_server_files to opc;
create database airportdb;
exit

psql -d airportdb
exit
 

🚌 MySQL 설치

다음 명령어로 MySQL 을 설치합니다.

sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
sudo rpm -ivh mysql80-community-release-el7-7.noarch.rpm
sudo yum install -y mysql-server
sudo yum install -y mysql-shell
 

향후 테스트를 위해 설정을 일부 변경하고 MySQL Server 를 시작합니다.

▶ SingleStore 가 3306 port 를 사용하므로 3360 port 로 변경

▶ Local File Load 를 위해 local_infile=true 설정

▶ Table 크기 제한을 기본 4GB 에서 8GB 로 확장

▶ 임시 Table 크기 제한을 기본 4GB 에서 8GB 로 확장

echo 'port=3360'              | sudo tee -a /etc/my.cnf > /dev/null
echo 'local_infile=true'      | sudo tee -a /etc/my.cnf > /dev/null
echo 'max_heap_table_size=8G' | sudo tee -a /etc/my.cnf > /dev/null
echo 'tmp_table_size=8G'      | sudo tee -a /etc/my.cnf > /dev/null

sudo systemctl start mysqld
 

MySQL root 계정의 임시 비밀번호를 확인하고 mysql_secure_installation 을 실행하여 향후 사용할 비밀번호로 변경합니다.

sudo grep "temporary password" /var/log/mysqld.log

mysql_secure_installation

Enter password for user root: <임시비밀번호>
New password: Mysql09876*
Re-enter new password: Mysql09876*
나머지는 모두 <Enter> 입력
 

🎯 마무리

Linux Server 한 대에 SingleStore, PostgreSQL, MySQL 을 모두 최신 버전으로 설치했습니다.

다음 포스트에서는 동일한 데이터를 각각 Loading 합니다.