超詳細な Docker インストール GreenPlum スタンドアロン ノード チュートリアル
1. Centosコンテナを作成する
1.1 centos7 イメージをプルする
docker pull centos:7
[root@zxy ~]# docker pull centos:7
[root@zxy ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 7 eeb6ee3f44bd 18 months ago 204MB
1.2 コンテナの作成
外部ポート 6002 はコンテナの内部 SSH ポート 22 をマップします
外部ポート 5432 は内部ポート 5432 をマップします
外部ポート 6000 は内部ポート 6000 をマップします
外部ポート 6001 は内部ポート 6001 をマッピングします
[root@zxy ~]# docker run -itd --name gp-docker01 \
> -p 6002:22 \
> -p 5432:5432 \
> -p 6000:6000 \
> -p 6001:6001 \
> --privileged eeb6ee3f44bd \
> /usr/sbin/init
b0c0fe56c04889c3d22aed9f422e16647030517b97f787095b70a8bf84f757a4
1.3 コンテナに入る
[root@zxy ~]# docker exec -it b0c0fe56c048 /bin/bash
[root@b0c0fe56c048 /]#
1.4 コンテナとサーバーの秘密のない運用
1.4.1 キーの生成
ssh-keygen
実行中にコマンドが見つからない場合は、yum
インストールをopenssh
使用してください。
bash: ssh-keygen: コマンドが見つかりません
# 1.ssh-keygen失败
[root@b0c0fe56c048 /]# ssh-keygen
bash: ssh-keygen: command not found
# 2.安装openssh
[root@b0c0fe56c048 /]# yum install openssh
# 3.再次进行生成密钥操作,不用输入,直接点击enter键即可
[root@b0c0fe56c048 /]# 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: コマンドが見つかりません
# 1.拷贝失败
[root@b0c0fe56c048 /]# ssh-copy-id 125.22.95.188
bash: ssh-copy-id: command not found
# 2.安装openssh-clients
[root@b0c0fe56c048 /]# yum install openssh-clients
# 3.再次拷贝,进行免密
[root@b0c0fe56c048 /]# 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)' can't be established.
ECDSA key fingerprint is SHA256:uvxqg9O/HlNw5Y3FNToE/llF8GeZQy/p+GXlIS3N6cY.
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 サービスをインストールし、ネットワークを適用する必要がある
[root@b0c0fe56c048 /]# yum -y install net-tools.x86_64
[root@b0c0fe56c048 /]# yum -y install openssh-server
[root@b0c0fe56c048 /]# systemctl restart sshd
1.6 コンテナの root パスワードを設定する
1.6.1 passwdアプリケーションのインストール
passwd アプリケーションをインストールすると、コンテナのユーザーにパスワードを設定でき、機密性のないマシンの操作に便利です。
[root@b0c0fe56c048 /]# 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 do
1.6.2 コンテナのルートのパスワードを設定する
[root@b0c0fe56c048 /]# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
1.7 コンテナ自体には秘密はありません
[root@b0c0fe56c048 /]# ssh-copy-id localhost
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:9iOpCm67LKlvIZyEUNwxF4BnGlvORfRAbZX79nYkW1M.
ECDSA key fingerprint is MD5:fa:38:d7:e3:40:ad:12:68:94:5b:35:8c:77:8b:f0:bb.
Are you sure you want to continue connecting (yes/no)? ys
Please type 'yes' or 'no': yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@localhost's password:
Number of key(s) added: 1
Now 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 インストールパッケージの準備
[root@zxy ~]# docker cp /zxy/software/greenplum-db-6.4.0-rhel6-x86_64.rpm b0c0fe56c048:/
2.2 ユーザーとユーザーグループの作成
[root@b0c0fe56c048 /]# groupadd gpadmin
[root@b0c0fe56c048 /]# useradd gpadmin -g gpadmin
[root@b0c0fe56c048 /]# passwd gpadmin
2.3 オフラインインストール
2.3.1 インストールパッケージを確認し、yumでインストールする
公式の推奨事項は、yum を使用してインストールすることです。yum インストールの利点は、依存関係パッケージを自動的にダウンロードしてインストールしてくれることです。デフォルトでは、greenplum ソフトウェアは /usr/local ディレクトリにインストールされ、ソフト リンクが作成されます。しかし、インターネットから自動的にダウンロードできないとさらに面倒になります。
[root@b0c0fe56c048 /]# ls | grep greenplum
greenplum-db-6.4.0-rhel6-x86_64.rpm
[root@b0c0fe56c048 /]# yum install localhost greenplum-db-6.4.0-rhel6-x86_64.rpm
2.3.2 インストールパスの確認
[root@b0c0fe56c048 /]# 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.0
2.3.3 gpadmin ユーザーに greenplum ディレクトリ権限を付与する
[root@b0c0fe56c048 /]# chown -Rf gpadmin:gpadmin /usr/local/greenplum*
[root@b0c0fe56c048 /]# 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.0
2.3.4 データディレクトリと設定ディレクトリの作成
および他のノードgpdata
を使用してデータ ディレクトリを作成するmaster
primary
構成ディレクトリを作成するgpconfigs
[root@b0c0fe56c048 /]# mkdir -p /data/gpdata/master
[root@b0c0fe56c048 /]# mkdir -p /data/gpdata/primary
[root@b0c0fe56c048 /]# mkdir -p /data/gpconfigs
[root@b0c0fe56c048 /]# chown -Rf gpadmin:gpadmin /data/
2.3.5 gpadmin ユーザーの切り替え
[root@b0c0fe56c048 /]# su gpadmin
2.3.6 gpadmin ユーザー環境変数の表示
~/.bashrc ファイルに追加source /usr/local/greenplum-db/greenplum_path.sh
このように、root ユーザーで環境を変更した後、gpadmin ユーザーに切り替えると、自動的にロードされます。
後で追加する必要がある他の変数がある場合、それらもこのファイルに追加されます
[gpadmin@b0c0fe56c048 /]$ cat ~/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
source /usr/local/greenplum-db/greenplum_path.sh
変更したばかりなので、手動でソースできます。source ~/.bashrc
2.3.7 SSH相互信頼設定
[gpadmin@b0c0fe56c048 /]$ 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 successfully
2.3.8 設定初期化ファイル
2.3.8.1 ファイルを構成ディレクトリにコピーする
[gpadmin@b0c0fe56c048 /]$ cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /data/gpconfigs/
2.3.8.2 ホストファイルの作成
[gpadmin@b0c0fe56c048 /]$ touch /data/gpconfigs/hostfile
[gpadmin@b0c0fe56c048 /]$ echo "b0c0fe56c048" > /data/gpconfigs/hostfile
2.3.8.3 初期化ファイルの変更
主にマスターとセグメントのディレクトリ、ホスト名、データベース ポートに焦点を当てます。
[gpadmin@b0c0fe56c048 /]$ vi /data/gpconfigs/gpinitsystem_config
[gpadmin@b0c0fe56c048 /]$ 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_NAME="Greenplum Data Platform"
#### Naming convention for utility-generated data directories.
SEG_PREFIX=gpseg
#### Base number by which primary segment port numbers
#### are calculated.
PORT_BASE=6000
#### 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_HOSTNAME=b0c0fe56c048
#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY=/data/gpdata/master
#### Port number for the master instance.
MASTER_PORT=5432
#### Shell utility used to connect to remote hosts.
TRUSTED_SHELL=ssh
#### Maximum log file segments between automatic WAL checkpoints.
CHECK_POINT_SEGMENTS=8
#### Default server-side character set encoding.
ENCODING=UNICODE
################################################
#### OPTIONAL MIRROR PARAMETERS
################################################
#### Base number by which mirror segment port numbers
#### are calculated.
#MIRROR_PORT_BASE=7000
#### File system location(s) where mirror segment data directories
#### will be created. The number of mirror locations must equal the
#### number of primary locations as specified in the
#### DATA_DIRECTORY parameter.
#declare -a MIRROR_DATA_DIRECTORY=(/data1/mirror /data1/mirror /data1/mirror /data2/mirror /data2/mirror /data2/mirror)
################################################
#### OTHER OPTIONAL PARAMETERS
################################################
#### Create a database of this name after initialization.
#DATABASE_NAME=name_of_database
#### Specify the location of the host address file here instead of
#### with the the -h option of gpinitsystem.
#MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem
2.3.9 データベースの初期化
[gpadmin@b0c0fe56c048 /]$ gpinitsystem -c /data/gpconfigs/gpinitsystem_config -h /data/gpconfigs/hostfile
2.3.10 データベースへの接続
[gpadmin@b0c0fe56c048 /]$ psql -p 5432 -d postgres
psql (9.4.24)
Type "help" for help.
2.3.11 パスワードの変更
[gpadmin@b0c0fe56c048 /]$ 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 は外部アクセスを許可するために開かれます。
[gpadmin@b0c0fe56c048 /]$ 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 --color=auto greenplum
3.2 pg_hba.confの変更
#添加如下一行即可,所有用户,所有IP均可访问
#生产环境中可自行选择配置
[gpadmin@b0c0fe56c048 /]$ vi /data/gpdata/master/gpseg-1/pg_hba.conf
host all all all trust
3.3 greenplumを再起動する
3.3.1 gpstop のシャットダウンに失敗しました
20230322:02:45:30:003728 gpstop:b0c0fe56c048:gpadmin-[CRITICAL]:-gpstop failed. (Reason='Environment Variable MASTER_DATA_DIRECTORY not set!') exiting...
gpstop を使用すると、シャットダウンが失敗したことを示すメッセージが表示され、設定を求めるプロンプトが表示されます。MASTER_DATA_DIRECTORY
[gpadmin@b0c0fe56c048 /]$ 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. (Reason='Environment Variable MASTER_DATA_DIRECTORY not set!') exiting...
3.3.2 MASTER_DATA_DIRECTORY の設定
~/.bashrc
次の 2 行のレコードをファイルに追加します。
[gpadmin@b0c0fe56c048 /]$ vi ~/.bashrc
MASTER_DATA_DIRECTORY=/data/gpdata/master/gpseg-1
export MASTER_DATA_DIRECTORY
[gpadmin@b0c0fe56c048 /]$ source ~/.bashrc
3.4 GP をオフにする
[gpadmin@b0c0fe56c048 /]$ gpstop
.....
20230322:02:46:57:003750 gpstop:b0c0fe56c048:gpadmin-[INFO]:-Cleaning up leftover shared memory
3.5スタートGP
[gpadmin@b0c0fe56c048 /]$ gpstart
......
20230322:02:47:21:003933 gpstart:b0c0fe56c048:gpadmin-[INFO]:-Database successfully started
3.6 リモート接続
Dbeaver は GreenPlum ドライバーを使用してデータベースに接続します