集团做网站方案制作包含哪些方面,企业品牌网站建设的关键事项,企业建设网站找网站公司吗,wordpress 主题 不显示图片文章目录 第二章 GreenPlum安装1.Docker创建centos容器1.1 拉取centos7镜像1.2 创建容器1.3 进入容器1.4 容器和服务器免密操作1.4.1 生成密钥1.4.2 拷贝密钥 1.5 安装ssh服务和网络必须应用1.6 容器设置root密码1.6.1 安装passwd应用1.6.2 容器本机root设置密码 1.7 容器本机免… 文章目录 第二章 GreenPlum安装1.Docker创建centos容器1.1 拉取centos7镜像1.2 创建容器1.3 进入容器1.4 容器和服务器免密操作1.4.1 生成密钥1.4.2 拷贝密钥 1.5 安装ssh服务和网络必须应用1.6 容器设置root密码1.6.1 安装passwd应用1.6.2 容器本机root设置密码 1.7 容器本机免密 2.安装GreenPlum2.1 准备安装包2.2 创建用户及用户组2.3 离线安装2.3.1 检查安装包并yum安装2.3.2 查看安装路径2.3.3 将greenplum目录权限授予gpadmin用户2.3.4 创建数据目录和配置目录2.3.5 切换gpadmin用户2.3.6 查看gpadmin用户环境变量2.3.7 SSH互信设置2.3.8 配置初始化文件2.3.8.1 拷贝文件到配置目录2.3.8.2 创建host文件2.3.8.3 修改初始化文件 2.3.9 初始化数据库2.3.10 连接数据库2.3.11 修改密码 3.远程连接3.1 开放端口3.2 修改pg_hba.conf3.3 重启greenplum3.3.1 gpstop关闭失败3.3.2 设置MASTER_DATA_DIRECTORY3.4 关闭gp3.5 启动gp 3.6 远程连接 第二章 GreenPlum安装 如果有充分的资源可以做分布式安装GreenPlum。如果资源不足可以做单节点安装同样可以用来熟悉GreenPlum语法。本章计划使用Docker创建一个Centos7的镜像并在Centos7中安装GreenPlum。如果不打算使用Docker的话可以直接从第二步安装GreenPlum开始。
《Docker系列》Docker安装、运维教程
1.Docker创建centos容器
1.1 拉取centos7镜像
docker pull centos:7
[rootzxy ~]# docker pull centos:7
[rootzxy ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 7 eeb6ee3f44bd 18 months ago 204MB1.2 创建容器
外部端口6002映射容器内部ssh端口22
外部端口5432映射内部端口5432
外部端口6000映射内部端口6000
外部端口6001映射内部端口6001
[rootzxy ~]# docker run -itd --name gp-docker01 \-p 6002:22 \-p 5432:5432 \-p 6000:6000 \-p 6001:6001 \--privileged eeb6ee3f44bd \/usr/sbin/init
b0c0fe56c04889c3d22aed9f422e16647030517b97f787095b70a8bf84f757a41.3 进入容器
[rootzxy ~]# docker exec -it b0c0fe56c048 /bin/bash
[rootb0c0fe56c048 /]#1.4 容器和服务器免密操作
1.4.1 生成密钥
如果在执行ssh-keygen的时候找不到该命令那么使用yum安装openssh即可
bash: ssh-keygen: command not found
# 1.ssh-keygen失败
[rootb0c0fe56c048 /]# ssh-keygen
bash: ssh-keygen: command not found
# 2.安装openssh
[rootb0c0fe56c048 /]# yum install openssh
# 3.再次进行生成密钥操作不用输入直接点击enter键即可
[rootb0c0fe56c048 /]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory /root/.ssh.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
......1.4.2 拷贝密钥
如果在执行ssh-copy-id失败的话使用yum手动安装openssh-clients即可
bash: ssh-copy-id: command not found
# 1.拷贝失败
[rootb0c0fe56c048 /]# ssh-copy-id 125.22.95.188
bash: ssh-copy-id: command not found
# 2.安装openssh-clients
[rootb0c0fe56c048 /]# yum install openssh-clients
# 3.再次拷贝进行免密
[rootb0c0fe56c048 /]# ssh-copy-id 125.22.95.188
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: /root/.ssh/id_rsa.pub
The authenticity of host 125.22.95.188 (125.22.95.188) cant be established.
ECDSA key fingerprint is SHA256:uvxqg9O/HlNw5Y3FNToE/llF8GeZQy/pGXlIS3N6cY.
ECDSA key fingerprint is MD5:d4:15:a9:ea:f9:26:8f:2f:b4:dd:8a:42:3b:58:29:3b.
Are you sure you want to continue connecting (yes/no)? yes
.....1.5 安装ssh服务和网络必须应用
[rootb0c0fe56c048 /]# yum -y install net-tools.x86_64
[rootb0c0fe56c048 /]# yum -y install openssh-server
[rootb0c0fe56c048 /]# systemctl restart sshd1.6 容器设置root密码
1.6.1 安装passwd应用
安装passwd应用可以给容器的用户设置密码方便对本机进行免密操作
[rootb0c0fe56c048 /]# yum -y install passwd
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile* base: ftp.sjtu.edu.cn* extras: ftp.sjtu.edu.cn* updates: ftp.sjtu.edu.cn
Package passwd-0.79-6.el7.x86_64 already installed and latest version
Nothing to do1.6.2 容器本机root设置密码
[rootb0c0fe56c048 /]# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.1.7 容器本机免密
[rootb0c0fe56c048 /]# ssh-copy-id localhost
...
Are you sure you want to continue connecting (yes/no)? yes
...
rootlocalhosts password:Number of key(s) added: 1Now try logging into the machine, with: ssh localhost
and check to make sure that only the key(s) you wanted were added.2.安装GreenPlum
2.1 准备安装包
[rootzxy ~]# docker cp /zxy/software/greenplum-db-6.4.0-rhel6-x86_64.rpm b0c0fe56c048:/2.2 创建用户及用户组
[rootb0c0fe56c048 /]# groupadd gpadmin
[rootb0c0fe56c048 /]# useradd gpadmin -g gpadmin
[rootb0c0fe56c048 /]# passwd gpadmin2.3 离线安装
2.3.1 检查安装包并yum安装
安装包
官网 官方推荐使用yum的方式安装yum安装的饿好处是会自动帮我们下载安装依赖包。默认将greenplum软件安装到/usr/local目录下并创建软连接。但是如果不能自动联网下载就会比较麻烦。
[rootb0c0fe56c048 /]# ls | grep greenplum
greenplum-db-6.4.0-rhel6-x86_64.rpm
[rootb0c0fe56c048 /]# yum install localhost greenplum-db-6.4.0-rhel6-x86_64.rpm2.3.2 查看安装路径
[rootb0c0fe56c048 /]# ll /usr/local/ | grep greenplum
lrwxrwxrwx 1 root root 29 Mar 22 02:29 greenplum-db - /usr/local/greenplum-db-6.4.0
drwxr-xr-x 12 root root 4096 Mar 22 02:29 greenplum-db-6.4.02.3.3 将greenplum目录权限授予gpadmin用户
[rootb0c0fe56c048 /]# chown -Rf gpadmin:gpadmin /usr/local/greenplum*
[rootb0c0fe56c048 /]# ll /usr/local/ | grep greenplum
lrwxrwxrwx 1 gpadmin gpadmin 29 Mar 22 02:29 greenplum-db - /usr/local/greenplum-db-6.4.0
drwxr-xr-x 12 gpadmin gpadmin 4096 Mar 22 02:29 greenplum-db-6.4.02.3.4 创建数据目录和配置目录
创建数据目录gpdata有master和primary等节点
创建配置目录gpconfigs
[rootb0c0fe56c048 /]# mkdir -p /data/gpdata/master
[rootb0c0fe56c048 /]# mkdir -p /data/gpdata/primary
[rootb0c0fe56c048 /]# mkdir -p /data/gpconfigs[rootb0c0fe56c048 /]# chown -Rf gpadmin:gpadmin /data/2.3.5 切换gpadmin用户
[rootb0c0fe56c048 /]# su gpadmin2.3.6 查看gpadmin用户环境变量
在~/.bashrc文件中添加source /usr/local/greenplum-db/greenplum_path.sh
这样在root用户下修改了环境后一旦切换到gpadmin用户会自动加载。
后续还有其他变量需要添加时也添加在该文件中
[gpadminb0c0fe56c048 /]$ cat ~/.bashrc# .bashrc# Source global definitions
if [ -f /etc/bashrc ]; then. /etc/bashrc
fi# Uncomment the following line if you dont like systemctls auto-paging feature:
# export SYSTEMD_PAGER# User specific aliases and functions
source /usr/local/greenplum-db/greenplum_path.sh刚修改好可以手动source一下。source ~/.bashrc
2.3.7 SSH互信设置
[gpadminb0c0fe56c048 /]$ gpssh-exkeys -h b0c0fe56c048
[STEP 1 of 5] create local ID and authorize on local host[STEP 2 of 5] keyscan all hosts and update known_hosts file[STEP 3 of 5] retrieving credentials from remote hosts[STEP 4 of 5] determine common authentication file content[STEP 5 of 5] copy authentication files to all remote hosts[INFO] completed successfully2.3.8 配置初始化文件
2.3.8.1 拷贝文件到配置目录
cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /data/gpconfigs/
[gpadminb0c0fe56c048 /]$ cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /data/gpconfigs/2.3.8.2 创建host文件
[gpadminb0c0fe56c048 /]$ touch /data/gpconfigs/hostfile
[gpadminb0c0fe56c048 /]$ echo b0c0fe56c048 /data/gpconfigs/hostfile2.3.8.3 修改初始化文件
主要关注master和segment的目录主机名和数据库端口
[gpadminb0c0fe56c048 /]$ vi /data/gpconfigs/gpinitsystem_config[gpadminb0c0fe56c048 /]$ cat /data/gpconfigs/gpinitsystem_config# FILE NAME: gpinitsystem_config# Configuration file needed by the gpinitsystem################################################
#### REQUIRED PARAMETERS
#################################################### Name of this Greenplum system enclosed in quotes.
ARRAY_NAMEGreenplum Data Platform#### Naming convention for utility-generated data directories.
SEG_PREFIXgpseg#### Base number by which primary segment port numbers
#### are calculated.
PORT_BASE6000#### File system location(s) where primary segment data directories
#### will be created. The number of locations in the list dictate
#### the number of primary segments that will get created per
#### physical host (if multiple addresses for a host are listed in
#### the hostfile, the number of segments will be spread evenly across
#### the specified interface addresses).
declare -a DATA_DIRECTORY(/data/gpdata/primary /data/gpdata/primary)#### OS-configured hostname or IP address of the master host.
MASTER_HOSTNAMEb0c0fe56c048#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY/data/gpdata/master#### Port number for the master instance.
MASTER_PORT5432#### Shell utility used to connect to remote hosts.
TRUSTED_SHELLssh#### Maximum log file segments between automatic WAL checkpoints.
CHECK_POINT_SEGMENTS8#### Default server-side character set encoding.
ENCODINGUNICODE2.3.9 初始化数据库
gpinitsystem -c /data/gpconfigs/gpinitsystem_config -h /data/gpconfigs/hostfile
[gpadminb0c0fe56c048 /]$ gpinitsystem -c /data/gpconfigs/gpinitsystem_config -h /data/gpconfigs/hostfile2.3.10 连接数据库
[gpadminb0c0fe56c048 /]$ psql -p 5432 -d postgres
psql (9.4.24)
Type help for help.2.3.11 修改密码
[gpadminb0c0fe56c048 /]$ psql -p 5432 -d postgres
psql (9.4.24)
Type help for help.postgres# \password gpadmin
Enter new password:
Enter it again:3.远程连接
3.1 开放端口
通过指令查询任务进程以及端口。
容器的6000,6001,5432分别对应服务器的6000,6001,5432端口主要开放5432端口允许外部访问即可
[gpadminb0c0fe56c048 /]$ ps -ef | grep greenplum
gpadmin 3560 1 0 02:39 ? 00:00:00 /usr/local/greenplum-db-6.4.0/bin/postgres -D /data/gpdata/primary/gpseg0 -p 6000
gpadmin 3561 1 0 02:39 ? 00:00:00 /usr/local/greenplum-db-6.4.0/bin/postgres -D /data/gpdata/primary/gpseg1 -p 6001
gpadmin 3582 0 0 02:39 ? 00:00:00 /usr/local/greenplum-db-6.4.0/bin/postgres -D /data/gpdata/master/gpseg-1 -p 5432 -E
gpadmin 3725 405 0 02:43 pts/1 00:00:00 grep --colorauto greenplum3.2 修改pg_hba.conf
#添加如下一行即可所有用户所有IP均可访问
#生产环境中可自行选择配置
[gpadminb0c0fe56c048 /]$ vi /data/gpdata/master/gpseg-1/pg_hba.confhost all all all trust3.3 重启greenplum
3.3.1 gpstop关闭失败
20230322:02:45:30:003728 gpstop:b0c0fe56c048:gpadmin-[CRITICAL]:-gpstop failed. (ReasonEnvironment Variable MASTER_DATA_DIRECTORY not set!) exiting...
在使用gpstop的时候提示关闭失败提示你设置MASTER_DATA_DIRECTORY
[gpadminb0c0fe56c048 /]$ gpstop
20230322:02:45:30:003728 gpstop:b0c0fe56c048:gpadmin-[INFO]:-Starting gpstop with args:
20230322:02:45:30:003728 gpstop:b0c0fe56c048:gpadmin-[INFO]:-Gathering information and validating the environment...
20230322:02:45:30:003728 gpstop:b0c0fe56c048:gpadmin-[CRITICAL]:-gpstop failed. (ReasonEnvironment Variable MASTER_DATA_DIRECTORY not set!) exiting...3.3.2 设置MASTER_DATA_DIRECTORY
在~/.bashrc文件中添加如下两行记录即可
[gpadminb0c0fe56c048 /]$ vi ~/.bashrc
MASTER_DATA_DIRECTORY/data/gpdata/master/gpseg-1
export MASTER_DATA_DIRECTORY[gpadminb0c0fe56c048 /]$ source ~/.bashrc
3.4 关闭gp
[gpadminb0c0fe56c048 /]$ gpstop
.....
20230322:02:46:57:003750 gpstop:b0c0fe56c048:gpadmin-[INFO]:-Cleaning up leftover shared memory
3.5 启动gp
[gpadminb0c0fe56c048 /]$ gpstart
......
20230322:02:47:21:003933 gpstart:b0c0fe56c048:gpadmin-[INFO]:-Database successfully started3.6 远程连接
Dbeaver使用GreenPlum驱动连接数据库