Greenplum是一款全球领先的开源大数据平台,为全球各行各业提供具备实时处理、弹性扩容、弹性计算、混合负载、云原生和集成数据分析能力的强大的大数据引擎,目前广泛的应用于包括金融、保险、证券、通信、航空、物流、零售、媒体、政府、医疗、制造、能源等行业。
目前Greenplum的二进制发行版本只能运行在X86服务器。无论是Greenplum的官方开发商Pivotal公司,还是其他Greenplum发行商,都没有提供Greenplum的ARM发行版。不过,Greenplum是开源软件,我们可以通过编译Greenplum源代码自行构建Greenplum的ARM版本。
本文将详细讲述如何在ARM服务器上编译并运行开源版Greenplum。
1. 环境准备
1.1 arm内核配置yum源
到目录 /etc/yum.repos.d ,创建/替换下面文件
- CentOS-Base.repo
[root@localhost yum.repos.d]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirrors.ustc.edu.cn/centos-altarch/$releasever/os/$basearch/
baseurl=http://mirrors.ustc.edu.cn/centos-altarch/7/os/$basearch/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32
#released updates
[updates]
name=CentOS-$releasever - Updates
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirrors.ustc.edu.cn/centos-altarch/$releasever/updates/$basearch/
baseurl=http://mirrors.ustc.edu.cn/centos-altarch/7/updates/$basearch/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirrors.ustc.edu.cn/centos-altarch/$releasever/extras/$basearch/
baseurl=http://mirrors.ustc.edu.cn/centos-altarch/7/extras/$basearch/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirrors.ustc.edu.cn/centos-altarch/$releasever/centosplus/$basearch/
baseurl=http://mirrors.ustc.edu.cn/centos-altarch/7/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32
- 清空/重建yum 缓存
yum clean all
yum makecache
1.2 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
1.3 设置用户使用资源
vim /etc/security/limits.conf
# 可打开的文件描述符的最大数,超过会警告(软限制)
* soft nofile 524288
# 可打开的文件描述符的最大数,超过会报错(硬限制)
* hard nofile 524288
# 单个用户可用的最大进程数量,超过会警告(软限制)
* soft nproc 131072
# 单个用户可用的最大进程数量,超过会报错(硬限制)
* hard nproc 131072
1.4 关闭SELinux
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
# 查看 SELINUX 状态
[root@localhost ~]# sestatus
SELinux status: disabled
# 如果状态没有修改则需要重启服务器
1.5 修改内核参数
vim /etc/sysctl.conf
# 新增参数
# 用于设置系统范围内共享内存段的最大数量。该参数的默认值是 4096.
kernel.shmmni = 4096
# 系统任意时刻可以分配的所有共享内存段的总和的最大值(以页为单位)
kernel.shmall = 4000000000
# 表示设置的信号量
kernel.sem = 250 512000 100 2048
# 启用SsyRq
kernel.sysrq = 1
# 设置pid作为文件扩展名
kernel.core_uses_pid = 1
# 每个消息队列的最大字节限制
kernel.msgmnb = 65536
# 单个消息的最大size
kernel.msgmax = 65536
# 整个系统的最大数量的消息队列。
kernel.msgmni = 2048
# 开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。
net.ipv4.tcp_tw_recycle = 1
# 定义了处于SYN_RECV的TCP最大连接数
net.ipv4.tcp_max_syn_backlog = 4096
# ARP响应有关
net.ipv4.conf.default.arp_filter = 1
# 增加客户端端口可用范围
net.ipv4.ip_local_port_range = 1025 65535
# 当网卡接收数据包的速度大于内核处理的速度时,会有一个队列保存这些数据包。这个参数表示该队列的最大值。
net.core.netdev_max_backlog = 10000
# 接收缓冲区最大值
net.core.rmem_max = 2097152
# 发送缓冲区最大值
net.core.wmem_max = 2097152
# 表示内核允许分配超过所有物理内存和交换空间总和的内存。
vm.overcommit_memory = 2
# 原本参数
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_forward = 0
# 重启或刷新配置
sysctl -p
- 遇见的问题
[root@localhost rpm]# yum localinstall epel-release-latest-7.noarch.rpm
上次元数据过期检查:0:42:55 前,执行于 2022年02月15日 星期二 10时42分51秒。
错误:
问题: conflicting requests 相互矛盾的请求
- nothing provides redhat-release >= 7 needed by epel-release-7-14.noarch
没有提供 redhat-release 7 needed by epel-release-7-14.noarch
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
尝试添加“--skip-broken”以跳过可卸载包 或“--nobest”以不仅使用最佳候选包
1.8 安装编译所需的工具及软件包
# 1. epel-release
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# 或使用下面命令强制安装
rpm -ivh --force --nodeps https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# 使用强制安装
rpm -ivh --force --nodeps epel-release-latest-7.noarch.rpm
yum makecache
# 2. 安装所需编译环境
yum groupinstall 'Development Tools' # GCC, libtools etc
# 3. 安装所需编译环境
yum install curl-devel bzip2-devel python-devel openssl-devel readline-devel perl-ExtUtils-Embed libxml2-devel perl-devel zstd git
# 下面为安装明细与检查
yum install curl-devel # ok
yum install python-devel # ok
yum install openssl-devel # ok
yum install readline-devel # ok
yum install libdb-devel # ok
yum install bzip2-devel # ok
yum install perl-ExtUtils-Embed # ok
yum install libxml2-devel # ok
yum install perl-devel # ok
yum install zstd # ok -
yum install git # ok
yum install epel-release # ok
yum install libzstd-devel # ok
yum install glibc-langpack-tr ok
1.9 安装python 组件
# 3. 下载文件
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
# 4. 使用 Python 安装 pip
python get-pip.py
# 5. 使用 pip 安装插件
pip install psutil lockfile paramiko setuptools epydoc conan
# 明细
pip install lockfile
pip install paramiko
pip install setuptools
pip install epydoc
pip install conan
# 安装Python组件明细
======= 默认 ========
configobj==5.0.6
configparser==3.5.0b2
mysqlclient==1.3.12 ==》 删除
pycairo==1.19.1 ==》 删除
PyGObject==3.36.1
python-xlib==0.15rc1 ==》 删除
pyxdg==0.26
six==1.15.0
======== psutil ========
pip 20.3.4
psutil 5.9.0
setuptools 44.1.1
wheel 0.37.1
======== lockfile ========
lockfile 0.12.2
======== paramiko ========
bcrypt 3.1.7
cffi 1.15.0
cryptography 3.3.2
enum34 1.1.10
ipaddress 1.0.23
paramiko 2.10.3
pycparser 2.21
PyNaCl 1.4.0
======== setuptools ========
已装
======== epydoc ========
epydoc 3.0.1
======== conan ========
Package Version
------------------- -----------
bottle 0.12.19
certifi 2021.10.8
chardet 4.0.0
colorama 0.4.4
conan 1.47.0
contextlib2 0.6.0.post1
distro 1.6.0
fasteners 0.16.3
idna 2.10
importlib-resources 3.3.1
Jinja2 2.11.3
MarkupSafe 1.1.1
monotonic 1.6
node-semver 0.6.1
patch-ng 1.17.4
pathlib2 2.3.7.post1
pluginbase 1.0.1
Pygments 2.5.2
PyJWT 1.7.1
python-dateutil 2.8.2
PyYAML 5.4.1
requests 2.27.1
scandir 1.10.0
singledispatch 3.7.0
tqdm 4.64.0
typing 3.10.0.0
urllib3 1.26.9
zipp 1.2.0
pip download -d your_offline_packages psutil
# 离线下载安装包
# 下载单个离线包 -
pip download -d your_offline_packages <package_name>
# 批量下载离线包 -
pip download -d your_offline_packages -r requirements.txt
# 离线安装
# 安装单个离线包 -
pip install --no-index --find-links=/your_offline_packages/ package_name
# 批量安装离线包 -
pip install --no-index --find-links=/your_offline_packages/ -r requirements.txt
2. 编译Greenplum源代码
2.1 创建 gpadmin 用户
# 增加用户组
groupadd -g 530 gpadmin
# 增加用户
useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin
# 对文件夹进行赋权
chown -R gpadmin:gpadmin /home/gpadmin/
# 为新用户创建密码
[root@localhost ~]# passwd gpadmin
更改用户 gpadmin 的密码
新的 密码: (gpadmin)
#密码提示太简单,连续输入两次即可。
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新
2.2 下载Greenplum源代码
# 切换用 gpadmin 用户
su gpadmin
# 下载源码
git clone https://github.com/greenplum-db/gpdb
# 进入 gpdb 目录
cd gpdb
# 切换版本
git checkout 6.9
2.3 编译安装
注意编译的时候使用的 Python2 版本, 但要是 2.2 之后的版本
# 1. 编译
CFLAGS="-O0 -g3 -ggdb3" \
./configure --with-python --with-libxml --enable-debug --enable-cassert \
--disable-orca --disable-gpcloud --disable-gpfdist \
--disable-gpfdist
# 打印日志
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking for default port number... 5432
checking for block size... 32kB
checking for segment size... 1GB
checking for WAL block size... 32kB
......
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking src/backend/port/sysv_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/unix_latch.c to src/backend/port/pg_latch.c
config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
# 2. 编译
sudo make
# 打印日志
make[1]: 进入目录“/home/gpadmin/gpdb/src”
make -C common all
make[2]: 进入目录“/home/gpadmin/gpdb/src/common”
make -C ../backend submake-errcodes
make[3]: 进入目录“/home/gpadmin/gpdb/src/backend”
make -C utils errcodes.h
make[4]: 进入目录“/home/gpadmin/gpdb/src/backend/utils”
'/usr/bin/perl' ./generate-errcodes.pl ../../../src/backend/utils/errcodes.txt > errcodes.h
make[4]: 离开目录“/home/gpadmin/gpdb/src/backend/utils”
......
n -fPIC -shared -o pxf.so src/pxfprotocol.o src/pxfbridge.o src/pxfuriparser.o src/libchurl.o src/pxfutils.o src/pxfheaders.o src/pxffragment.o src/gpdbwritableformatter.o src/pxffilters.o -L../../src/port -L../../src/common -Wl,--as-needed -Wl,-rpath,'/usr/local/gpdb/lib',--enable-new-dtags -lcurl
make[2]: 离开目录“/home/gpadmin/gpdb/gpcontrib/pxf”
make[1]: 离开目录“/home/gpadmin/gpdb/gpcontrib”
All of Greenplum Database successfully made. Ready to install.
# 3. 安装
sudo make install
# 打印日志
/usr/bin/install -c -m 755 pxf.so '/usr/local/gpdb/lib/postgresql/pxf.so'
/usr/bin/install -c -m 644 pxf.control '/usr/local/gpdb/share/postgresql/extension/'
/usr/bin/install -c -m 644 pxf--1.0.sql '/usr/local/gpdb/share/postgresql/extension/'
make[2]: 离开目录“/home/gpadmin/gpdb/gpcontrib/pxf”
make[1]: 离开目录“/home/gpadmin/gpdb/gpcontrib”
Greenplum Database installation complete.
- 问题 zstd library not found
configure: error: zstd library not found
If you have libzstd already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-zstd to disable zstd support.
# 解决办法 --
yum install epel-release
yum install libzstd-devel
# 这是安装时遇见的问题, 已经在前面增加了此软件的安装命令
- 问题 configure: error: libperl library is required for Perl
checking for libperl... no
configure: error: libperl library is required for Perl
# 解决
wget https://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/aarch64/os/Packages/p/perl-devel-5.34.0-485.fc36.aarch64.rpm
# 下载源码
wget https://vault.centos.org/8.5.2111/AppStream/Source/SPackages/perl-5.30.1-452.module_el8.4.0+646+45e06e4a.src.rpm
# 编译源码
rpmbuild --rebuild --clean perl-5.30.1-452.module_el8.4.0+646+45e06e4a.src.rpm
# 编译失败需要依赖
错误:构建依赖失败:
gdbm-devel 被 perl-4:5.30.1-452.ky10.ky10.aarch64 需要
glibc-langpack-tr 被 perl-4:5.30.1-452.ky10.ky10.aarch64 需要
libdb-devel 被 perl-4:5.30.1-452.ky10.ky10.aarch64 需要
# 安装依赖 --
yum install gdbm-devel # 安装失败
yum install glibc-langpack-tr # 找不到
yum install libdb-devel # 安装成功
- 问题 bison’ is missing on your system
***
ERROR: `bison' is missing on your system. It is needed to create the
file `gram.c'. You can either get bison from a GNU mirror site
or download an official distribution of PostgreSQL, which contains
pre-packaged bison output.
***
make[3]: *** [gram.c] Error 1
make[3]: Leaving directory `/home/gpdb_src/gpdb-5.16.0/src/backend/parser'
make[2]: *** [parser/gram.h] Error 2
make[2]: *** Waiting for unfinished jobs....
AWK='gawk' /bin/sh Gen_fmgrtab.sh pg_proc_combined.h.tmp
make[3]: Leaving directory `/home/gpdb_src/gpdb-5.16.0/src/backend/utils'
make[2]: Leaving directory `/home/gpdb_src/gpdb-5.16.0/src/backend'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/gpdb_src/gpdb-5.16.0/src'
make: *** [all] Error 2
# 解决方式
yum install bison
3. 配置 Greenplum
3.1 设置免密登录
使用gpadmin登入,配置ssh免密码登录
# 生成秘钥
[root@localhost opt]# su gpadmin
[gpadmin@localhost opt]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/gpadmin/.ssh/id_rsa): #(回车)
Enter passphrase (empty for no passphrase):#(回车)
Enter same passphrase again:
Your identification has been saved in /home/gpadmin/.ssh/id_rsa.
Your public key has been saved in /home/gpadmin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:TTr5ZrIMSa+VXwFJJiAoUPmYskWTR8DLiFpraX0+7dg gpadmin@localhost
The key's randomart image is:
+---[RSA 2048]----+
|ooo*o ... o |
|. B .. + . |
|.= B + |
|+ B . = . |
|.= + . S . . |
|o = ...o + . |
| o oo.= + . |
| oB.* . |
| ooE . |
+----[SHA256]-----+
[gpadmin@localhost opt]$
[gpadmin@localhost opt]$ cd ~
[gpadmin@localhost .ssh]$ pwd
/home/gpadmin/.ssh
# 配置 localhost 免密登录
[gpadmin@localhost .ssh]$ ssh-copy-id localhost
gpadmin@localhost password: #(输入gpadmin用户的密码)
...
# 尝试免密登录 localhost
[gpadmin@localhost .ssh]$ ssh localhost
# 退出登录
[gpadmin@localhost ~]$ exit
登出
Connection to localhost closed.
3.2 创建节点列表文件
在管理节点配置
[gpadmin@localhost .ssh]$ mkdir /home/gpadmin/conf
[gpadmin@localhost .ssh]$
[gpadmin@localhost .ssh]$ cd /home/gpadmin/conf
#添加 GreenPlum 集群的所有节点
[gpadmin@localhost conf]$ vim hostlist
[gpadmin@localhost conf]$ cat hostlist
localhost
#添加 GreenPlum 集群的所有segment节点
[gpadmin@localhost conf]$ vim seg_hosts
[gpadmin@localhost conf]$ cat seg_hosts
localhost
3.3 创建数据存储空间
# 在 Master 节点创建元数据目录
[gpadmin@localhost ~]$ mkdir -p /home/gpadmin/data/master
# 创建数据存储目录
[gpadmin@localhost ~]$ mkdir -p /home/gpadmin/data/primary
[gpadmin@localhost ~]$ mkdir -p /home/gpadmin/data/mirror
3.4 配置 .bash_profile 环境变量
[gpadmin@localhost ~]$ vim /home/gpadmin/.bash_profile
# 添加下面内容
source /usr/local/gpdb/greenplum_path.sh # 这个路径对应安装 gp 的目录
export MASTER_DATA_DIRECTORY=/home/gpadmin/data/master/gpseg-1
export PGPORT=5432
export PGUSER=gpadmin
export PGDATABASE=Greenplum
# 将刚刚配置的加到环境变量中
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$MASTER_DATA_DIRECTORY
[gpadmin@localhost ~]$ source /home/gpadmin/.bash_profile
[gpadmin@localhost ~]$ echo $GPHOME
/usr/local/gpdb
3.5 初始化配置文件
配置文件模板为 $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config
[gpadmin@localhost ~]$ mkdir /home/gpadmin/gpconfigs
[gpadmin@localhost ~]$ cd /home/gpadmin/gpconfigs/
[gpadmin@localhost gpconfigs]$ pwd
/home/gpadmin/gpconfigs
# 创建 节点列表文件 hostfile_gpinitsystem
[gpadmin@localhost gpconfigs]$ echo localhost > hostfile_gpinitsystem
#将segment节点名称添加到该文件内
[gpadmin@localhost gpconfigs]$ cat /home/gpadmin/gpconfigs/hostfile_gpinitsystem
localhost
# 复制配置文件模板
[gpadmin@localhost gpconfigs]$ cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config .
# 修改配置
[gpadmin@localhost gpconfigs]$ vim gpinitsystem_config
# 修改以下配置
#数据库代号
ARRAY_NAME="Greenplum"
#segment前缀
SEG_PREFIX=gpseg
#primary segment 起始的端口号
PORT_BASE=6000
#指定primary segment的数据目录,网上写的是多个相同目录,多个目录表示一台机器有多个segment
declare -a DATA_DIRECTORY=(/home/gpadmin/data/primary)
#master所在机器的host name # 需要修改
MASTER_HOSTNAME=localhost
#master的数据目录 # 需要修改
MASTER_DIRECTORY=/home/gpadmin/data/master
#master的端口
MASTER_PORT=5432
#指定bash的版本
TRUSTED_SHELL=/usr/bin/ssh
#将日志写入磁盘的间隔,每个段文件通常 =16MB < 2 * CHECK_POINT_SEGMENTS + 1
CHECK_POINT_SEGMENTS=8
#字符集
ENCODING=UNICODE
#mirror segment 起始的端口号
MIRROR_PORT_BASE=7000
# mirror的数据目录,和主数据一样,一个对一个,多个对多个
declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/data/mirror)
DATABASE_NAME=Greenplum
MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem
4. Greenplum 初始化
[gpadmin@localhost gpconfigs]$ cd ~
[gpadmin@localhost ~]$ pwd
/home/gpadmin
[gpadmin@localhost ~]$ source /usr/local/gpdb/greenplum_path.sh
[gpadmin@localhost ~]$ gpinitsystem -c gpconfigs/gpinitsystem_config -h gpconfigs/hostfile_gpinitsystem
...
Continue with Greenplum creation Yy|Nn (default=N): #(y)
...
20200... gpstart:localhost:gpadmin-[INFO]:- Successful segment starts = 2
...
20200... gpinitsystem:localhost:gpadmin-[INFO]:-Greenplum Database instance successfully created
# GreenPlum 初始化成功
- 如果出现问题可以去下面路径查看日志
less /home/gpadmin/gpAdminLogs/
5. 连接 GreenPlum 测试
# 连接GreenPlum
[gpadmin@localhost ~]$ psql -d postgres
psql (9.4.24)
Type "help" for help.
postgres=# select version();
version
----------------------------------------------------------
PostgreSQL 9.4.24 (Greenplum Database 6.7.1 build ......
(1 row)
# 查看现有database
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------+----------+------------+------------+---------------------
postgres | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +
| | | | | gpadmin=CTc/gpadmin
template1 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +
| | | | | gpadmin=CTc/gpadmin
(3 rows)
# 新建database
postgres=# create database test;
CREATE DATABASE
# 查看 database 是否创建成功
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------+----------+------------+------------+---------------------
postgres | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +
| | | | | gpadmin=CTc/gpadmin
template1 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +
| | | | | gpadmin=CTc/gpadmin
test | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 |
(4 rows)
# 退出命令行
postgres=# \q
[gpadmin@localhost ~]$
命令集参考文档:https://gpdb.docs.pivotal.io/6-7/ref_guide/sql_commands/sql_ref.html
6. 远程登录授权
- 为 gpadmin 用户创建密码
[gpadmin@localhost ~]$ psql -d postgres
psql (9.4.24)
Type "help" for help.
postgres=#
postgres=#
postgres=# alter role gpadmin with password '123456';
ALTER ROLE
postgres=#
- 修改授权文件
[gpadmin@localhost ~]$ vim /home/gpadmin/data/master/gpseg-1/pg_hba.conf
#在末尾追加如下内容
host all gpadmin localhost/16 trust
# 重启 GreenPlum
[gpadmin@localhost ~]$ gpstop -M fast -a
[gpadmin@localhost ~]$ gpstart -a
- 配置说明
连接方式 | 连接的数据库 | 连接的用户 | 要连接GP的主机IP | 认证方式 |
---|---|---|---|---|
host | all | gpadmin | localhost/16 | trust |
7. 启停命令与日志
说明 | 命令 |
---|---|
启动 | gpstart |
关闭 | gpstop |
状态 | gpstate |
日志地址 | /home/gpadmin/gpAdminLogs |
日志地址 | /home/gpadmin/data/mirror/gpseg1/pg_log |
日志地址 | /home/gpadmin/data/primary/gpseg0/pg_log |