LightDB虚拟机搭建分布式环境

  1. 首先先去centos官网下载x86镜像
    centos官网镜像下载
  2. 虚拟机版本VMware® Workstation 16 Pro
    安装过程略
    注意:这里安装3个centos
    也就是要搭建1cn,2dn的分布式环境
    安装好之后ip分别为
    cn:192.168.160.129
    dn1:192.168.160.130
    dn2:192.168.160.131
  3. 下载LightDB安装包
    LightDB官网
    这里下载的版本是:lightdb-x-13.8-22.3-7953-el7.x86_64(安装包名称)
  4. 安装前准备
    通过ssh分别连接到3台虚拟机中
    执行脚本(3台)
#!/bin/bash

firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --permanent --add-port=123/udp

iptables -A INPUT -p tcp --dport 5432 -j ACCEPT
iptables -A INPUT -p udp --dport 123 -j ACCEPT

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
setenforce 0

timedatectl set-timezone Asia/Shanghai

# 安 装 包 通 用 运 行 依 赖 ,GUI安 装 和 命 令 行 安 装 均 需 要
yum install -y procps-ng
yum install -y coreutils
# GUI安 装 运 行 依 赖 , 仅GUI安 装 需 要
yum install -y gtk2
yum install -y libXtst
yum install -y dejavu-fonts # 麒 麟v10sp1可 能 需 要 安 装 字 体
# 数 据 库 的 运 行 依 赖
yum install -y readline
yum install -y zlib
yum install -y libxml2
yum install -y openssl-libs
yum install -y uuid
yum install -y c-ares libpcap snappy # tshark
yum install -y ncurses-libs # iftop
yum install -y libnl3 # keepalived ipv6
yum install -y libzstd # canopy
yum install -y sysstat
yum install -y json-c
yum install -y libicu

groupadd lightdb
useradd -g lightdb -m lightdb

mkdir -p /usr/local/lightdb
chown -R lightdb:lightdb /usr/local/lightdb

echo "kernel.shmmni=4096" >> /etc/sysctl.conf
echo "kernel.shmmax=$(expr $(getconf _PHYS_PAGES) / 2 \* $(getconf PAGE_SIZE))" \
>> /etc/sysctl.conf
echo "kernel.shmall=$(expr $(getconf _PHYS_PAGES) / 2)" >> /etc/sysctl.conf
echo "kernel.sem=500 2048000 200 4096" >> /etc/sysctl.conf
echo "fs.aio-max-nr=1048576" >> /etc/sysctl.conf
echo "fs.file-max=524288" >> /etc/sysctl.conf
echo "vm.swappiness=5" >> /etc/sysctl.conf
echo "vm.overcommit_memory=2" >> /etc/sysctl.conf
echo "vm.overcommit_ratio=75" >> /etc/sysctl.conf
echo "vm.dirty_background_ratio=5" >> /etc/sysctl.conf
echo "vm.dirty_ratio=40" >> /etc/sysctl.conf
echo "vm.dirty_expire_centisecs=500" >> /etc/sysctl.conf
echo "vm.dirty_writeback_centisecs=250" >> /etc/sysctl.conf
echo "net.core.somaxconn=2000" >> /etc/sysctl.conf
echo "net.ipv4.tcp_max_syn_backlog=2000" >> /etc/sysctl.conf
echo "net.ipv4.tcp_tw_reuse=1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_syn_retries=3" >> /etc/sysctl.conf
echo "net.ipv4.tcp_retries2=5" >> /etc/sysctl.conf
echo "net.ipv4.tcp_slow_start_after_idle=0" >> /etc/sysctl.conf

sysctl -p

echo "lightdb hard core unlimited" >> /etc/security/limits.conf
echo "lightdb soft core unlimited" >> /etc/security/limits.conf
echo "lightdb hard nofile 524288" >> /etc/security/limits.conf
echo "lightdb soft nofile 524288" >> /etc/security/limits.conf
echo "lightdb hard nproc 16384" >> /etc/security/limits.conf
echo "lightdb soft nproc 16384" >> /etc/security/limits.conf

sysctl -p

echo '============================success============================='

再配置lightdb用户的密码:lt123456

[root@localhost home]# passwd lightdb 
Changing password for user lightdb.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

3台机器配置免密
均切换到lightdb用户:

su - lightdb

129上执行:

ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
ssh-copy-id lightdb@192.168.160.130
ssh-copy-id lightdb@192.168.160.131

130上执行:

ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
ssh-copy-id lightdb@192.168.160.129
ssh-copy-id lightdb@192.168.160.131

131上执行:

ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
ssh-copy-id lightdb@192.168.160.129
ssh-copy-id lightdb@192.168.160.130
  1. 开始安装
    上传安装包到129的lightdb账户上
    1)解压安装包(lightdb用户)
unzip lightdb-x-13.8-22.3-7953-el7.x86_64.zip

解压之后先安装安装包中的zstd(root用户安装,3台机器都要装)

rpm -ivh /home/lightdb/lightdb-x-13.8-22.3-7953-el7.x86_64/system-lib/libzstd-1.5.2-1.el7.x86_64.rpm
  1. 进到安装目录中(lightdb用户)
cd lightdb-x-13.8-22.3-7953-el7.x86_64
  1. 执行安装脚本
[lightdb@localhost lightdb-x-13.8-22.3-7953-el7.x86_64]$ ./install.sh 
Whether to use the graphical user interface (GUI, Make sure DISPLAY is configured, Such as [export DISPLAY=127.0.0.1:0.0])?(Yes or No)
no
Choice a kind of configuration mode!
1: Only install.
2: Install database and Create instance.
3: Developer
Please enter 1 2 or 3(The default is 1):
2
Choice a kind of install mode!

1: Single Mode.
2: High Availability Mode
3: Distributed Mode
Please enter 1, 2 or 3:(The default is 1)
3
Please select distributed mode!
Please enter distributed mode:
1 Normal mode;
2 Multi-server single instance;
3 Single server multi-instance.(Default 1)
2
Configure the directory and port for the single-node multi-instance.
Please enter coordinator node:
Please enter the ip of coordinator node, such as 192.168.217.234:
192.168.160.129
Please enter the port of coordinator node. (Default port 5432):

Please enter worker node:
Please enter the ip of worker node, such as 192.168.217.234:
192.168.160.130
Please enter the port of worker node. (Default port 5432):

Please enter the ip of worker node, such as 192.168.217.234:
192.168.160.131
Please enter the port of worker node. (Default port 5432):

Continue to add worker node?(1[yes],2[no])
2
======================================= Servers =======================================
Coordinator Node : 192.168.160.129
Worker Node : 192.168.160.130
Worker Node : 192.168.160.131
======================================= Servers =======================================
Please check the servers of Multi-server single instance. 1 continue; 2 clear server config (Default 1)

====================================== Generate pg_hba ================================
====================================== Generate end ===================================
====================================== Copying files takes time =======================
192.168.160.130: start copy

192.168.160.130: end copy
192.168.160.131: start copy
192.168.160.131: end copy
====================================== Copying files end ==============================
Check system parameters and dependency packages!
========================================= 192.168.160.129 =========================================
NETWORK
name: sem, recommend value: 500,2048000,200,4096, current value: 500,2048000,200,4096, status: OK
name: aio_max_nr, recommend value: 1048576, current value: 1048576, status: OK
name: somaxconn, recommend value: 2000, current value: 2000, status: OK
name: tcp_max_syn_backlog, recommend value: 2000, current value: 2000, status: OK
name: tcp_tw_reuse, recommend value: 1, current value: 1, status: OK
name: tcp_syn_retries, recommend value: 3, current value: 3, status: OK
name: tcp_retries2, recommend value: 5, current value: 5, status: OK
name: tcp_slow_start_after_idle, recommend value: 0, current value: 0, status: OK
PAGE_CACHE
name: dirty_background_ratio, recommend value: 5, current value: 5, status: OK
name: dirty_ratio, recommend value: 40, current value: 40, status: OK
name: dirty_expire_centisecs, recommend value: 500, current value: 500, status: OK
name: dirty_writeback_centisecs, recommend value: 250, current value: 250, status: OK
MEMORY
name: shmmni, recommend value: 4096, current value: 4096, status: OK
name: shmmax, recommend value: 1976979456, current value: 1976983552, status: WARNING
name: shmall, recommend value: 482661, current value: 482662, status: WARNING
name: swappiness, recommend value: 5, current value: 5, status: OK
name: overcommit_memory, recommend value: 2, current value: 2, status: OK
name: overcommit_ratio, recommend value: 75, current value: 75, status: OK
FILE_HANDLER
name: file_max, recommend value: 524288, current value: 524288, status: OK
ULIMIT
name: ulimit_core, recommend value: unlimited, current value: unlimited, status: OK
name: ulimit_nofile, recommend value: 8192, current value: 524288, status: OK
Dependency Package
name: JSON-C-0.11 is existed: yes
name: C-ARES-1 is existed: yes
name: LIBNL3 is existed: yes
name: LIBPCAP-1 is existed: yes
name: LIBZSTD-1 is existed: yes
name: LZ4-1 is existed: yes
name: NCURSES-LIBS-5 is existed: yes
name: READLINE-6 is existed: yes
name: SNAPPY-1 is existed: yes
name: UUID-1.6 is existed: yes
name: LIBICU-50 is existed: yes
System service
name: ntp is install: no
========================================= 192.168.160.130 =========================================
NETWORK
name: sem, recommend value: 500,2048000,200,4096, current value: 500,2048000,200,4096, status: OK
name: aio_max_nr, recommend value: 1048576, current value: 1048576, status: OK
name: somaxconn, recommend value: 2000, current value: 2000, status: OK
name: tcp_max_syn_backlog, recommend value: 2000, current value: 2000, status: OK
name: tcp_tw_reuse, recommend value: 1, current value: 1, status: OK
name: tcp_syn_retries, recommend value: 3, current value: 3, status: OK
name: tcp_retries2, recommend value: 5, current value: 5, status: OK
name: tcp_slow_start_after_idle, recommend value: 0, current value: 0, status: OK
PAGE_CACHE
name: dirty_background_ratio, recommend value: 5, current value: 5, status: OK
name: dirty_ratio, recommend value: 40, current value: 40, status: OK
name: dirty_expire_centisecs, recommend value: 500, current value: 500, status: OK
name: dirty_writeback_centisecs, recommend value: 250, current value: 250, status: OK
MEMORY
name: shmmni, recommend value: 4096, current value: 4096, status: OK
name: shmmax, recommend value: 1976979456, current value: 1976979456, status: OK
name: shmall, recommend value: 482661, current value: 482661, status: OK
name: swappiness, recommend value: 5, current value: 5, status: OK
name: overcommit_memory, recommend value: 2, current value: 2, status: OK
name: overcommit_ratio, recommend value: 75, current value: 75, status: OK
FILE_HANDLER
name: file_max, recommend value: 524288, current value: 524288, status: OK
ULIMIT
name: ulimit_core, recommend value: unlimited, current value: unlimited, status: OK
name: ulimit_nofile, recommend value: 8192, current value: 524288, status: OK
Dependency Package
name: JSON-C-0.11 is existed: yes
name: C-ARES-1 is existed: yes
name: LIBNL3 is existed: yes
name: LIBPCAP-1 is existed: yes
name: LIBZSTD-1 is existed: yes
name: LZ4-1 is existed: yes
name: NCURSES-LIBS-5 is existed: yes
name: READLINE-6 is existed: yes
name: SNAPPY-1 is existed: yes
name: UUID-1.6 is existed: yes
name: LIBICU-50 is existed: yes
System service
name: ntp is install: no
========================================= 192.168.160.131 =========================================
NETWORK
name: sem, recommend value: 500,2048000,200,4096, current value: 500,2048000,200,4096, status: OK
name: aio_max_nr, recommend value: 1048576, current value: 1048576, status: OK
name: somaxconn, recommend value: 2000, current value: 2000, status: OK
name: tcp_max_syn_backlog, recommend value: 2000, current value: 2000, status: OK
name: tcp_tw_reuse, recommend value: 1, current value: 1, status: OK
name: tcp_syn_retries, recommend value: 3, current value: 3, status: OK
name: tcp_retries2, recommend value: 5, current value: 5, status: OK
name: tcp_slow_start_after_idle, recommend value: 0, current value: 0, status: OK
PAGE_CACHE
name: dirty_background_ratio, recommend value: 5, current value: 5, status: OK
name: dirty_ratio, recommend value: 40, current value: 40, status: OK
name: dirty_expire_centisecs, recommend value: 500, current value: 500, status: OK
name: dirty_writeback_centisecs, recommend value: 250, current value: 250, status: OK
MEMORY
name: shmmni, recommend value: 4096, current value: 4096, status: OK
name: shmmax, recommend value: 1976979456, current value: 1976979456, status: OK
name: shmall, recommend value: 482661, current value: 482661, status: OK
name: swappiness, recommend value: 5, current value: 5, status: OK
name: overcommit_memory, recommend value: 2, current value: 2, status: OK
name: overcommit_ratio, recommend value: 75, current value: 75, status: OK
FILE_HANDLER
name: file_max, recommend value: 524288, current value: 524288, status: OK
ULIMIT
name: ulimit_core, recommend value: unlimited, current value: unlimited, status: OK
name: ulimit_nofile, recommend value: 8192, current value: 524288, status: OK
Dependency Package
name: JSON-C-0.11 is existed: yes
name: C-ARES-1 is existed: yes
name: LIBNL3 is existed: yes
name: LIBPCAP-1 is existed: yes
name: LIBZSTD-1 is existed: yes
name: LZ4-1 is existed: yes
name: NCURSES-LIBS-5 is existed: yes
name: READLINE-6 is existed: yes
name: SNAPPY-1 is existed: yes
name: UUID-1.6 is existed: yes
name: LIBICU-50 is existed: yes
System service
name: ntp is install: no
Choice a kind of Compatible Type!
1: LightdDB(Compatible with PostgreSQL).
2: ORACLE(Compatible with ORACLE).
3: MYSQL(Compatible with MYSQL).
Please enter 1, 2 or 3:(The default is 1)
Choice a kind of LightDB workload!
1: OLTP(On-line Transaction Processing).
2: OLAP(On-Line Analytical Processing).
Please enter 1 or 2:(The default is 1)

Specify a path for installing all LightDB software and storing configuration information.
Please enter base location(The default is /usr/local/lightdb):

The directory [/usr/local/lightdb] already exists and is being used!

Base Location: /usr/local/lightdb
Install Location: /usr/local/lightdb/lightdb-x/13.8-22.3
Please enter instance location(The default is /usr/local/lightdb/lightdb-x/13.8-22.3/data/defaultCluster/):

Instance location: /usr/local/lightdb/lightdb-x/13.8-22.3/data/defaultCluster/
Please configure memory(MB) and character set!
Please enter shared_buffers, Default value is (942):
500
Please enter effective_cache_size, Default value is (2639):

Please choice a kind of Character Set.
1. UTF8
2. GBK
3. SQL_ASCII
4. LATIN1
The default choice 1(UTF8)

Please enter LightDB password!
Please enter original password:

Please enter confirm password:

Do you want to deploy immediately?(Yes or No, The default is yes)

[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]100%
Ntp Server
Enter the ip address or domain name of the ntp server, Allowed to change.(Default ntp ip:192.168.160.129)

Execute follow commands as root
Execute follow commands to start ntp:

sh /home/lightdb/lightdb-x-13.8-22.3-7953-el7.x86_64/script/13_ntp_start.sh /usr/local/lightdb/lightdb-x/13.8-22.3

Check service:
Please enter any key to continue for checking?

Choose whether to install LVS to load balance coordinator node ?(Yes or No,The default is no)

Install Finish
  1. 查看分布式状态
    129上执行:
ltsql -dpostgres

执行sql

lightdb@postgres=# select * from pg_dist_node;
 nodeid | groupid |    nodename     | nodeport | noderack | hasmetadata | isactive | noderole | nodecluster | metadatasynced | shouldhaveshards 
--------+---------+-----------------+----------+----------+-------------+----------+----------+-------------+----------------+------------------
      1 |       0 | 192.168.160.129 |     5432 | default  | t           | t        | primary  | default     | t              | f
      2 |       1 | 192.168.160.130 |     5432 | default  | t           | t        | primary  | default     | t              | t
      3 |       2 | 192.168.160.131 |     5432 | default  | t           | t        | primary  | default     | t              | t
(3 rows)

到这里安装成功。

详细语法可参考LightDB官网查看https://www.hs.net/lightdb
更多请登录LightDB官网进行查看:https://www.hs.net/lightdb

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

追魂曲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值