赞
踩
相关配置要求如下:
配置:内存16G以上(最好16G),硬盘 20G以上,固定IP地址和mac地址;镜像包(Centos7.9)下载,root 账户密码6个1:111111(推荐);各节点IP是同一网段,并互相能连通;关闭防火墙、关闭seLinux服务
安装包和镜像下载: https://blog.csdn.net/wiserhowe/article/details/128833346
连接linux的工具(任意一个即可):
Putty、Xshell、SecureCRT、SecureFX 等
其他相关资料:
《GBase 8c GDCA 认证培训课前准备课前准备》
https://blog.csdn.net/wiserhowe/article/details/128833346
《GBase 8c V5 分布式集群版安装示例》
https://blog.csdn.net/wiserhowe/article/details/126725440
《GBase 学习资料》
https://edu.gbase.cn/page/2355055?navIndex=4
[root@ufo001 ~]# free -m
total used free shared buff/cache available
Mem: 15362 385 14610 0 366 14713
Swap: 0 0 0
[root@ufo001 /]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 7.5G 0 7.5G 0% /dev
tmpfs tmpfs 7.6G 0 7.6G 0% /dev/shm
tmpfs tmpfs 7.6G 540K 7.6G 1% /run
tmpfs tmpfs 7.6G 0 7.6G 0% /sys/fs/cgroup
/dev/vda1 ext4 40G 2.1G 36G 6% /
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
# 创建 8G 的 Swap 文件 [root@ufo001 /]# dd if=/dev/zero of=/etc/swapfile bs=1024 count=8192000 8192000+0 records in 8192000+0 records out 8388608000 bytes (8.4 GB) copied, 41.2087 s, 204 MB/s # 制作为 Swap 文件 [root@ufo001 /]# mkswap /etc/swapfile Setting up swapspace version 1, size = 8191996 KiB no label, UUID=52381280-e69b-4701-963a-32b5254d0544 # 令 Swap 文件生效 [root@ufo001 /]# swapon /etc/swapfile swapon: /etc/swapfile: insecure permissions 0644, 0600 suggested. # 查看当前SWAP [root@ufo001 /]# swapon -s Filename Type Size Used Priority /etc/swapfile file 8191996 0 -2 # 自动挂载,追加 /etc/swapfile swap swap defaults 0 0 [root@ufo001 /]# vim /etc/fstab # # /etc/fstab # Created by anaconda on Wed Feb 8 02:15:09 2023 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=627df7a6-36cf-4152-ac9c-326dc141c9a2 / ext4 defaults 1 1 /etc/swapfile swap swap defaults 0 0 # 查看创建好的 SWAP,已经增长了 8G [root@ufo001 /]# free -m total used free shared buff/cache available Mem: 15362 390 6376 0 8595 14643 Swap: 7999 0 7999
IP | 账号 | 密码 | 节点角色 |
172.16.144.1 | root | ###### | gha_server(高可用服务)、dcs(分布式配置存储)、gtm(全局事务管理)、coordinator(协调器) |
172.16.144.2 | root | ###### | datanode(数据节点) 1 |
172.16.144.3 | root | ###### | datanode(数据节点) 2 |
# 如果系统提示以下信息说明防火墙已被禁用
[root@ufo001 ~]# systemctl status firewalld.service
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
# 如果防火墙没有关闭,则执行
# systemctl stop firewalld.service
# systemctl disable firewalld.service
# 以上两条命令关闭防火墙并禁止防火墙开机自启动
# 如果系统提示以下信息说明 selinux 已被禁用
[root@ufo001 ~]# sestatus
SELinux status: disabled
# 如果 SELINUX 没有关闭,需要编辑当前节点的 selinux 配置文件。
# 将 SELINUX 关键字的值修改为 disabled,存盘退出,
[root@ufo001 ~]# vim /etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted
# 重启操作系统,生效
[root@ufo001 ~]# shutdown -r
# 三个节点重新设置主机名
[root@ufo001 ~]# hostnamectl set-hostname ufo001
[root@ufo002 ~]# hostnamectl set-hostname ufo002
[root@ufo003 ~]# hostnamectl set-hostname ufo003
# 配置三个节点的 IP 主机名映射
# 编辑三个节点的 hosts 文件
[root@ufo001 ~]# vim /etc/hosts
# 将以下三行信息追加到 hosts 文件中
172.16.144.1 ufo001 ufo001
172.16.144.2 ufo002 ufo002
172.16.144.3 ufo003 ufo003
[root@ufo001 ~]# useradd gbase
[root@ufo001 ~]# passwd gbase
Changing password for user gbase.
New password:
BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic
Retype new password:
passwd: all authentication tokens updated successfully.
[root@ufo001 ~]# visudo
root ALL=(ALL) ALL
gbase ALL=(ALL) NOPASSWD:ALL
注意:个别操作系统,经过以上的设置后,gbase 用户执行 sudo 命令时,第一次还是有密码提示。需要有以下补救措施:
# root 账户下进入 /etc/sudoers.d/ 目录
cd /etc/sudoers.d/
# 生成新文件 gbase
vim gbase
# 添加如下信息后,存盘即可:
gbase ALL=(ALL) NOPASSWD:ALL
参考:https://blog.csdn.net/qq_42226855/article/details/112691157
[gbase@ufo001 ~]$ mkdir ~/.ssh [gbase@ufo001 ~]$ [gbase@ufo001 ~]$ chmod 700 ~/.ssh [gbase@ufo001 ~]$ [gbase@ufo001 ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/gbase/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/gbase/.ssh/id_rsa. Your public key has been saved in /home/gbase/.ssh/id_rsa.pub. The key fingerprint is: SHA256:d654ol43lMWPxNLtp+U5rIpQhVACkEINxhy/Q0TziOY gbase@ufo001 The key is randomart image is: +---[RSA 2048]----+ |+===o..o.. | |.++o+ o .+ . | | o.+ . ...* . | |o . . .= + | | E o S.+ o o o| | . .o o .=.| | .. o . .+.| | .oooo . .| | .o..+.... | +----[SHA256]-----+ [gbase@ufo001 ~]$ echo 'StrictHostKeyChecking no' >> ~/.ssh/config; echo 'UserKnownHostsFile ~/.ssh/known_hosts' >> ~/.ssh/config; chmod 644 ~/.ssh/config [gbase@ufo001 ~]$ ssh-copy-id gbase@172.16.144.1 [gbase@ufo001 ~]$ ssh-copy-id gbase@172.16.144.2 [gbase@ufo001 ~]$ ssh-copy-id gbase@172.16.144.3
参考:https://blog.csdn.net/lixiangchibang/article/details/116422775
[root@ufo001 ~]# vim /etc/ntp.conf # Access Control Support restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap nopeer noquery restrict 172.16.0.0 mask 255.240.0.0 nomodify notrap nopeer noquery restrict 100.64.0.0 mask 255.192.0.0 nomodify notrap nopeer noquery restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer noquery # local clock server 127.127.1.0 fudge 127.127.1.0 stratum 10 [root@ufo002 ~]# vim /etc/ntp.conf # local clock server 172.16.144.1 fudge 172.16.144.1 stratum 10 [root@ufo003 ~]# vim /etc/ntp.conf # local clock server 172.16.144.1 fudge 172.16.144.1 stratum 10 # CentOS 版本不同,启动方式不同 # 启动NTP服务 sudo service ntpd start # 设置 NTP 服务开机自启 sudo chkconfig ntpd on
# 使用的 Putty 工具,上传安装包到所有节点,目录 /home/gbase/gbase_package C:\Users\zhaoyuntao>pscp C:\Users\zhaoyuntao\Desktop\GBase8cV5_S3.0.0B76_centos7.8_x86_64.tar.gz gbase@47.99.146.16:/home/gbase/gbase_package/ gbase@47.99.146.16's password: GBase8cV5_S3.0.0B76_cento | 262299 kB | 1847.2 kB/s | ETA: 00:00:00 | 100% [gbase@ufo001 gbase_package]$ scp GBase8cV5_S3.0.0B76_centos7.8_x86_64.tar.gz gbase@172.16.144.2:/home/gbase/gbase_package/ GBase8cV5_S3.0.0B76_centos7.8_x86_64.tar.gz 100% 256MB 186.0MB/s 00:01 [gbase@ufo001 gbase_package]$ scp GBase8cV5_S3.0.0B76_centos7.8_x86_64.tar.gz gbase@172.16.144.3:/home/gbase/gbase_package/ GBase8cV5_S3.0.0B76_centos7.8_x86_64.tar.gz [gbase@ufo001 gbase_package]$ tar xvf GBase8cV5_S3.0.0B76_centos7.8_x86_64.tar.gz GBase8cV5_S3.0.0B76_CentOS_x86_64_om.sha256 GBase8cV5_S3.0.0B76_CentOS_x86_64_om.tar.gz GBase8cV5_S3.0.0B76_CentOS_x86_64_pgpool.tar.gz GBase8cV5_S3.0.0B76_CentOS_x86_64.sha256 GBase8cV5_S3.0.0B76_CentOS_x86_64.tar.bz2 [gbase@ufo001 gbase_package]$ tar xvf GBase8cV5_S3.0.0B76_CentOS_x86_64_om.tar.gz ...
注意:配置文件中的缩进一定要对齐,否则后边执行安装会读取文件报错
[gbase@ufo001 gbase_package]$ vim /home/gbase/gbase_package/gbase.yml gha_server: - gha_server1: host: 172.16.144.1 port: 20001 dcs: - host: 172.16.144.1 port: 2379 - host: 172.16.144.2 port: 2379 - host: 172.16.144.3 port: 2379 gtm: - gtm1: host: 172.16.144.1 agent_host: 172.16.144.1 role: primary port: 6666 agent_port: 8001 work_dir: /home/gbase/data/gtm/gtm1 coordinator: - cn1: host: 172.16.144.1 agent_host: 172.16.144.1 role: primary port: 5432 agent_port: 8003 work_dir: /home/gbase/data/coord/cn1 datanode: - dn1: - dn1_1: host: 172.16.144.2 agent_host: 172.16.144.2 role: primary port: 15432 agent_port: 8005 work_dir: /home/gbase/data/dn1/dn1_1 - dn2: - dn2_1: host: 172.16.144.3 agent_host: 172.16.144.3 role: primary port: 20010 agent_port: 8007 work_dir: /home/gbase/data/dn2/dn2_1 env: # cluster_type allowed values: multiple-nodes, single-inst, default is multiple-nodes cluster_type: multiple-nodes pkg_path: /home/gbase/gbase_package prefix: /home/gbase/gbase_db version: V5_S3.0.0B76 user: gbase port: 22 # constant: # virtual_ip: 100.0.1.254/24
[gbase@ufo001 ~]$ cd /home/gbase/gbase_package/script [gbase@ufo001 script]$ ./gha_ctl install -c gbase -p /home/gbase/gbase_package { "ret":-1, "msg":"Host localhost install or upgrade dependency {'bzip2': None, 'libaio': None} failed! Host 172.16.144.2 install or upgrade depende ncy {'bzip2': None, 'libaio': None} failed! Host 172.16.144.3 install or upgrade dependency {'bzip2': None, 'libaio': None} failed! " } # 安装报错,缺少依赖包 [root@ufo001 sudoers.d]# yum install bzip2 -y [root@ufo001 sudoers.d]# yum install libaio -y # 如下所示,安装成功 [gbase@ufo001 script]$ ./gha_ctl install -c gbase -p /home/gbase/gbase_package { "ret":0, "msg":"Success" }
[gbase@ufo001 script]$ ./gha_ctl monitor -l http://172.16.144.1:2379 { "cluster": "gbase", "version": "V5_S3.0.0B76", "server": [ { "name": "gha_server1", "host": "172.16.144.1", "port": "20001", "state": "running", "isLeader": true ... 或 [gbase@ufo001 script]$ ./gha_ctl monitor -l http://172.16.144.1:2379 -H +----+-------------+--------------+-------+---------+--------+ | No | name | host | port | state | leader | +----+-------------+--------------+-------+---------+--------+ | 0 | gha_server1 | 172.16.144.1 | 20001 | running | True | +----+-------------+--------------+-------+---------+--------+ +----+------+--------------+------+---------------------------+---------+---------+ | No | name | host | port | work_dir | state | role | +----+------+--------------+------+---------------------------+---------+---------+ | 0 | gtm1 | 172.16.144.1 | 6666 | /home/gbase/data/gtm/gtm1 | running | primary | +----+------+--------------+------+---------------------------+---------+---------+ +----+------+--------------+------+----------------------------+---------+---------+ | No | name | host | port | work_dir | state | role | +----+------+--------------+------+----------------------------+---------+---------+ | 0 | cn1 | 172.16.144.1 | 5432 | /home/gbase/data/coord/cn1 | running | primary | +----+------+--------------+------+----------------------------+---------+---------+ +----+-------+-------+--------------+-------+----------------------------+---------+---------+ | No | group | name | host | port | work_dir | state | role | +----+-------+-------+--------------+-------+----------------------------+---------+---------+ | 0 | dn1 | dn1_1 | 172.16.144.2 | 15432 | /home/gbase/data/dn1/dn1_1 | running | primary | | 1 | dn2 | dn2_1 | 172.16.144.3 | 20010 | /home/gbase/data/dn2/dn2_1 | running | primary | +----+-------+-------+--------------+-------+----------------------------+---------+---------+ +----+--------------------------+--------+---------+----------+ | No | url | name | state | isLeader | +----+--------------------------+--------+---------+----------+ | 0 | http://172.16.144.3:2379 | node_2 | healthy | True | | 1 | http://172.16.144.2:2379 | node_1 | healthy | False | | 2 | http://172.16.144.1:2379 | node_0 | healthy | False | +----+--------------------------+--------+---------+----------+
[gbase@ufo001 script]$ ./gha_ctl stop all -l http://172.16.144.1:2379
{
"ret":0,
"msg":"Success"
}
[gbase@ufo001 script]$ ./gha_ctl start all -l http://172.16.144.1:2379
{
"ret":0,
"msg":"Success"
}
在主节点(172.16.144.1)执行以下命令即可:
# 停止所有节点的集群服务: [gbase@ufo001 script]$ ./gha_ctl stop all -l http://172.16.144.1:2379 { "ret":0, "msg":"Success" } # 集群程序的卸载: [gbase@ufo001 script]$ ./gha_ctl uninstall -l http://172.16.144.1:2379 { "ret":0, "msg":"Success" } # 移除 dcs 集群: [gbase@ufo001 script]$ ./gha_ctl destroy dcs -l http://172.16.144.1:2379 { "ret":0, "msg":"Success" }
在主节点(172.16.144.1)执行。
[gbase@ufo001 script]$ gsql -d postgres -p 5432 gsql ((multiple_nodes GBase8cV5 3.0.0B76 build 47948f99) compiled at 2023-02-27 16:04:20 commit 0 last mr 1232 ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. postgres=# postgres=# postgres=# create database testdb; CREATE DATABASE postgres=# create table student(ID int, Name varchar(10)); CREATE TABLE postgres=# insert into student values(1, 'Mike'),(2,'John'); INSERT 0 2 postgres=# select * from student; id | name ----+------ 1 | Mike 2 | John (2 rows)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。