2023-01-10 LightDB高可用版本安装.md

LightDB-高可用版本安装

一主一从高可用版本安装

  • 安装环境
操作系统:
    centos7
服务器IP:
    1.192.168.121.112 (主)
    2.192.168.121.113 (从)
    3.192.168.121.114 (哨兵-可选)
  • 安装前准备

参考单机版安装

设置服务器之间的免密认证

#如果使用lightdb用户安装高可用,则在lightdb用户下执行
#免密认证,所有服务器都要执行
$ ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa

#证书同步,所有服务器都要执行
$ ssh-copy-id lightdb@192.168.121.112
$ ssh-copy-id lightdb@192.168.121.113
$ ssh-copy-id lightdb@192.168.121.114

#重启SSH服务
$ service sshd restart

#免密验证,主机ssh连接从机,无需输入密码
ssh lightdb@192.168.121.113
  • 版本安装

命令行方式安装

#切换用户
$ su - lightdb
#进入lightdb安装包,/home/lightdb/lightdb-x-13.8-22.3-7953-el7.x86_64
$ cd /home/lightdb/lightdb-x-13.8-22.3-7953-el7.x86_64
#执行install.sh
$./install.sh
Whether to use the graphical user interface (GUI, Make sure DISPLAY is configured, Such as [export DISPLAY
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)
2
Config Server for High Availability Mode!
Virtual IP:  vip和主机处于同一网段
    示例IP:192.168.121.110
Primary Server: 主机
    示例IP:192.168.121.112
Standby Server: 从机
    示例IP:192.168.121.113
  同步和异步的选择:
    1.和主机配置同一网段,同步异步都可以
    2.和主机配置不同网段,只能选择异步
Witness Server: 哨兵
    示例IP:192.168.121.114
    1.一主一从模式可选
    2.一主多从模式下必须
#接上面后续操作
Config Server for High Availability Mode!
Please enter a virtual IP address with network, such as (192.168.217.234/16):
192.168.121.110/16
The cluster need a primary server(required), one or more standby server(optional) and a witness server(optional).
Please input a primary server ip which is actually the ip of the current server(required). such as (192.168.217.234/16):
192.168.121.112/16
Please input a standby server ip(required), such as (192.168.217.234/16):
192.168.121.113/16
Please enter status of the standby server [192.168.121.113]
1 sync:
2 async:
1
Continue to add standby nodes?(enter [exit] to left.):
exit
Please input a witness server ip(optional), such as (192.168.217.234/16):
192.168.121.114/16
======================================= Servers =======================================
Vip: 192.168.121.110
Ip: 192.168.121.112 Role: primary Status: none
Ip: 192.168.121.113 Role: standby Status: sync
Ip: 192.168.121.114 Role: witness Status: none
======================================= Servers =======================================
Please check the servers of the cluster. 1 continue; 2 clear server config (Default 1)
1
====================================== Generate pg_hba ================================
====================================== Generate end ===================================
====================================== Copying files takes time =======================
192.168.121.113: start copy
192.168.121.113: end copy
192.168.121.114: start copy
192.168.121.114: end copy
====================================== Copying files end ==============================
Assign a port to the LightDB!
Listen Port(The default port is 5432):

Check system parameters and dependency packages!
========================================= 192.168.121.112 =========================================
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: 1976983552, current value: 1976979456, status: WARNING
name: shmall, recommend value: 482662, current value: 482661, 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.121.113 =========================================
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.121.114 =========================================
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)
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)
1
Specify a path for installing all LightDB software and storing configuration information.
Please enter base location(The default is /usr/local/lightdb):

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):

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)
1
Please enter LightDB password!(ps:密码长度为 6-16 个字符,且至少包含数字,英文字母)
Please enter original password:

Please enter confirm password:

Do you want to deploy immediately?(Yes or No, The default is yes)
yes
[>>>>>                                             ] 10%

Ntp Server
Enter the ip address or domain name of the ntp server, Allowed to change.(Default ntp ip:192.168.121.112)

Execute follow commands as root
Execute follow commands to start keepalived:
cd /usr/local/lightdb/lightdb-x/13.8-22.3/tools/bin
./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf

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?(ps:在操作前先进行keepalived和ntp的配置)

NTP Server: 
集群多机器之间的时间同步是非常重要的,LightDB 默认采用高可用主机时间为参考,
向备机和 witness 机器同步时间。如果你有自己的时间服务器,可以在这里修改为你自己的 ntp 服务器
地址。

#启动keepalived
新开一个会话,使用root用户,按照上面输出的提示执行
[root@localhost bin]# cd /usr/local/lightdb/lightdb-x/13.8-22.3/tools/bin

#启动keepalive服务(在所有primary server,standby server,witness server执行)
[root@localhost bin]# ./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf

#开启ntp服务(在所有primary server,standby server机器上执行,witness server不执行)
[root@localhost bin]# 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

#查看keepalived进程
[root@localhost bin]# ps aux|grep keepalived
root      42978  0.0  0.0  48100  1008 ?        Ss   16:47   0:00 ./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf
root      42979  0.0  0.0  48100  1852 ?        S    16:47   0:00 ./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf
root      42980  0.0  0.0  48100  1408 ?        S    16:47   0:00 ./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf
root      43343  0.0  0.0 112824   980 pts/1    S+   16:47   0:00 grep --color=auto keepalived
  • 查看安装后的进程

[lightdb@localhost ~]$ ps aux|grep ltcluster
lightdb    3727  0.1  0.0 116976  1700 ?        Sl   15:54   0:44 /usr/local/lightdb/lightdb-x/13.8-22.3/bin/ltclusterd -d -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/ltcluster/ltcluster.conf -p /usr/local/lightdb/lightdb-x/13.8-22.3/etc/ltcluster/ltclusterd.pid

[lightdb@localhost ~]$ ps aux|grep lightdb
root       3692  0.0  0.0 191892  2344 pts/0    S    15:29   0:00 su - lightdb
lightdb    3693  0.0  0.0 115544  2088 pts/0    S    15:29   0:00 -bash
lightdb    4826  0.3  9.2 1655932 357760 ?      Ss   15:50   0:15 /usr/local/lightdb/lightdb-x/13.8-22.3/bin/lightdb -D /usr/local/lightdb/lightdb-x/13.8-22.3/data/defaultCluster
lightdb    4829  0.0  0.0 247244  3060 ?        Ss   15:50   0:00 lightdb: logger 
lightdb    4831  0.0  0.7 1657384 27420 ?       Ss   15:50   0:01 lightdb: checkpointer 
lightdb    4832  0.1  0.4 1657284 16192 ?       Ss   15:50   0:05 lightdb: background writer 
lightdb    4833  0.0  3.4 1655752 134656 ?      Ss   15:50   0:03 lightdb: walwriter 
lightdb    4834  0.0  0.1 1659936 4376 ?        Ss   15:50   0:00 lightdb: autovacuum launcher 
lightdb    4835  0.0  0.0 249572  3256 ?        Ss   15:50   0:00 lightdb: archiver last was 000000010000000000000002.00000028.backup
lightdb    4836  0.1  0.0 249988  3488 ?        Ss   15:50   0:04 lightdb: stats collector 
lightdb    4837  0.6  0.7 1661096 28348 ?       Ss   15:50   0:29 lightdb: lt_cron launcher 
lightdb    4838  0.0  0.1 1659656 4116 ?        Ss   15:50   0:00 lightdb: logical replication launcher 
lightdb    4926  0.0  0.3 1663648 11992 ?       Ss   15:50   0:03 lightdb: ltcluster ltcluster 192.168.121.112(54860) idle
lightdb    4928  0.1  0.0 116884  1596 ?        Sl   15:50   0:05 /usr/local/lightdb/lightdb-x/13.8-22.3/bin/ltclusterd -d -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/ltcluster/ltcluster.conf -p /usr/local/lightdb/lightdb-x/13.8-22.3/etc/ltcluster/ltclusterd.pid
lightdb    5447  0.5  0.1 1662696 5812 ?        Ss   15:52   0:22 lightdb: walsender ltcluster 192.168.121.113(47010) streaming 0/61CF9500
lightdb    5522  0.0  0.6 1662376 24468 ?       Ss   15:52   0:03 lightdb: ltcluster ltcluster 192.168.121.113(47020) idle
lightdb    6010  0.0  0.2 1662376 9160 ?        Ss   15:53   0:00 lightdb: ltcluster ltcluster 192.168.121.114(50002) idle
root      42978  0.0  0.0  48100  1008 ?        Ss   16:47   0:00 ./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf
root      42979  0.0  0.0  48100  1852 ?        S    16:47   0:00 ./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf
root      42980  0.0  0.0  48100  1408 ?        S    16:47   0:00 ./keepalived -f /usr/local/lightdb/lightdb-x/13.8-22.3/etc/keepalived/keepalived.conf
root      43215  0.0  0.0  47120  2376 ?        Ss   16:47   0:00 /usr/local/lightdb/lightdb-x/13.8-22.3/tools/bin/ntpd -g -c /usr/local/lightdb/lightdb-x/13.8-22.3/etc/ntp/ntp.conf
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值