安装Greenplum
-
从官网Release页下载对应系统的安装包
-
创建gpadmin用户[Doc]
# Step 1: 创建gpadmin用户 groupadd gpadmin useradd gpadmin -r -m -g gpadmin passwd gpadmin # Step 2: 赋予gpadmin用户root权限 adduser gpadmin sudo # ubuntu usermod -aG wheel gpadmin # centos # Step 3: 生成ssh密钥 su gpadmin ssh-keygen -t rsa -b 4096
-
执行安装[Doc]
# Ubuntu:18.04 sudo apt --fix-broken install ./greenplum-db-<version>-<platform>.deb # CentOS sudo yum install ./greenplum-db-<version>-<platform>.rpm
至此,数据库已经安装到
/usr/local/greenplum-db
启动数据库
-
数据库配置[Doc]
在/usr/local/greenplum-db/docs/cli_help/gpconfigs
下可以查看greenplum的各种配置模板,初始化数据库主要用到:- gpinitsystem_config:本机数据库配置
- hostfile_gpinitsystem:段(segment)主机hostname列表
# Step 1: 创建 ~/gpconfigs/gpinitsystem_config 并添加以下内容 ARRAY_NAME="Greenplum Data Platform" SEG_PREFIX=gpseg PORT_BASE=6000 declare -a DATA_DIRECTORY=(/home/gpadmin/data1/primary /home/gpadmin/data1/primary /home/gpadmin/data2/primary /home/gpadmin/data2/primary) MASTER_HOSTNAME=<hostname> MASTER_DIRECTORY=/data/master MASTER_PORT=5432 TRUSTED_SHELL=ssh CHECK_POINT_SEGMENTS=8 ENCODING=UTF-8 # MIRROR_PORT_BASE=7000 # declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/data1/mirror /home/gpadmin/data1/mirror /home/gpadmin/data2/mirror /home/gpadmin/data2/mirror) DATABASE_NAME=gpadmin MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem # Step 2: 创建 ~/gpconfigs/hostfile_gpinitsystem 并添加本机 hostname
-
环境变量[Doc]
# 添加以下声明到 ~/.bashrc source /usr/local/greenplum-db/greenplum_path.sh export MASTER_DATA_DIRECTORY=/home/gpadmin/data/master/gpseg-1 # master host 路径 export PGPORT=5432 # 默认客户端登陆端口 export PGUSER=gpadmin # 默认登陆用户 export PGDATABASE=gpadmin # 默认登陆数据库
-
启动数据库
# Step 1: 创建数据目录 mkdir -p /home/gpadmin/data/master mkdir -p /home/gpadmin/data1/primary mkdir -p /home/gpadmin/data2/primary # Step 2: 加载环境变量 source ~/.bashrc # Step 3: 初始化并启动数据库 gpinitsystem -c gpconfigs/gpinitsystem_config # Step 4: 连接数据库 psql