• 基于RedHat6.5的Greenplum环境配置


    安装Greenplum的时候遇到了很多坑,在此记录下
    欢迎园友补充问题,共同研究解决!

    安装说明 

    1.环境说明

    操作系统:Red hat 6.5 64

    2.配置规范

    2.1基本说明

    greenplum安装介质:greenplum-db-4.3.12.0-rhel5-x86_64.zip

    安装目录规划:/opt/gp

    3.主机配置规范

     3.1 系统设置(以下操作在root用户下进行)

    关闭防火墙:

    永久性生效

    关闭:chkconfig  iptables  off

    开启:chkconfig iptables on

    即时生效,重启后失效

    开启:service iptables start

    关闭:service iptables stop

    修改主机名:

    永久生效vi /etc/sysconfig/network

                 hostname=gp1

                vi /etc/hosts

               192.168.230.130 gp1

               reboot

    临时生效hostname  gp1

     

    (1)  sysctl.conf的设置(所有节点)

    master主机与segment主机上分别设置参数执行如下命令

    # vi /etc/sysctl.conf

    kernel.shmmax = 500000000

    kernel.shmmni = 4096

    kernel.shmall = 4000000000

    kernel.sem = 250 512000 100 2048

    kernel.sysrq = 1

    kernel.core_uses_pid = 1

    kernel.msgmnb = 65536

    kernel.msgmax = 65536

    kernel.msgmni = 2048

    net.ipv4.tcp_syncookies = 1

    net.ipv4.conf.default.accept_source_route = 0

    net.ipv4.tcp_tw_recycle = 1

    net.ipv4.tcp_max_syn_backlog = 4096

    net.ipv4.conf.all.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

     

    上面的配置文件保存后,可以执行 sysctl -p 。以此可以避免重启电脑操作。

     

    (2)  limits.conf的设置(所有节点)

    master主机与segment主机上分别设置参数执行如下命令

    # vi /etc/security/limits.conf

    * soft nofile 65536

    * hard nofile 65536

    * soft nproc 131072

    * hard nproc 131072

    对于RedHat 6.xCentos6.x的机子,在/etc/security/limits.d/90-nproc.conf的参数会覆盖上述文件参数。1024修改为131072

     

    (3)  配置磁盘访问I/O调度策略(所有节点)

    cat /sys/block/sda/queue/scheduler

    echo deadline > /sys/block/sda/queue/scheduler

    echo deadline > /sys/block/sr0/queue/scheduler

     

    (4)配置/etc/hosts(所有节点)

    # vi /etc/hosts

    172.16.3.147    gpmaster

    172.16.3.148    gpseg1

    172.16.3.149      gpseg2

     

    (5)设置磁盘预读块值(所有节点)

    # /sbin/blockdev --getra /dev/sda

          默认256每个磁盘设备文件应具有预读(blockdev)值16384

    # fdisk –l  查看分区

    # /sbin/blockdev --setra 16384 /dev/sda

    # /sbin/blockdev --setra 16384 /dev/sda1

    # /sbin/blockdev --setra 16384 /dev/sda2

    (6)永久关闭SELINUX

          # vi /etc/selinux/config

          SELINUX=disabled

    chkconfig iptables off

    (7)禁用THPTHP会降低Greenplum数据库的性能(选)

    RHEL 6.0或更高版本默认启用THPTHP会降低Greenplum数据库的性能。在RHEL 6.x上禁用THP的一种方法是添加参数transparent_hugepage = never 

    # Vi /boot/grub/grub.conf

    kernel /vmlinuz-2.6.18-274.3.1.el5 ro root=LABEL=/

    elevator=deadline crashkernel=128M@16M  quiet console=tty1

    console=ttyS1,115200 panic=30 transparent_hugepage=never

    initrd /initrd-2.6.18-274.3.1.el5.img

     

    (8)重启,命令:reboot(重启虚拟机)

      验证
    [root@localhost ~]# getenforce

    Disabled

     

    [root@localhost ~]# cat /sys/kernel/mm/*transparent_hugepage/enabled
    禁用成功显示
    always madvise [never]

     

     

    4   安装

    4.1 Master(Only)上安装Greenplum(root用户下)

    (1)    解压介质

    # unzip greenplum-db-4.3.12.0-sles11-x86_64.zip

     

    (2)    安装GP  /home/fm/opt

    ./greenplum-db-4.3.xx-PLATFORM.bin

    确认license,输入yes

    输入安装目录:/opt/gp

    确认安装路径,yes

     

    (3)    获取gp的环境变量

    source /opt/gp/greenplum_path.sh

    vi /opt/gpssh_all存放所有节点

    vi /opt/gpssh_segonly存放子节点

     

    在从机上更改用户权限

    chown gpadmin:gpadmin  /opt

    运行gpseginstall工具:既能产生公信,又能创建用户和用户入组,也能分发

     

    gpseginstall -f/opt/gpssh_all -u gpadmin -p gpadmin

     

    /usr/local/greenplum-db-4.3.6.2/greenplum_path.sh

     

    更改文件权限

    chown gpadmin:gpadmin  /opt/gpssh_*

     

    (4)    创建安装目录

    切换gpadmin用户,并获得环境变量

      su -gpadmin

    source /opt/gp/greenplum_path.sh

     

     

     

    添加环境变量(所有主机)

    vi .bashrc

    添加 source /opt/gp/greenplum_path.sh

    export MASTER_DATA_DIRECTORY= /data/master/gpseg-1

    source .bashrc

    gpssh -f /opt/gpssh_all -e ls -l $GPHOME

    gpssh实用程序来查看是否可以在没有密码提示的情况下登录到所有主机,并确认所有主机上都安装了Greenplum软件,如果系统提示您输入密码,请运行以下命令以重新执行ssh密钥交换

    gpssh-exkeys -f gpssh_all

     

    主节点 (root用户)

    创建master数据存储区域:

    mkdir -p /data/master                                ——主机节点的master文件夹,

    chown -R gpadmin:gpadmin /data

     

    Standby

    # mkdir -p /data/master                                 ——standby节点

    # chown -R gpadmin:gpadmin /data

     

    子节点(fm用户创建目录)

    # gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data1/primary’

    # gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data1/mirror’

    # gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data2/primary’

    # gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data2/mirror’

     

    (5)    时间同步(root用户)

    主机

    # vi /etc/ntp.conf

    server 127.0.0.1(意思是主机与本地电脑时间同步)

    从机

    # vi /etc/ntp.conf

    server mdw prefer

    server seg2

    # gpssh  -u root -f gpssh_all -v -e 'ntpd'

    root用户

    查看ntp服务

    # /sbin/service ntpd status

    开启ntp服务

    # /sbin/service ntpd start

     

    (6)    验证操作(普通用户)

    # gpcheck -f /opt/gpssh_all –m mdw

     

    (7)    初始化用gpadmin用户下

    # cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/gpinitsystem_config

     

    # chmod 775 gpinitsystem_config

     

    # vi /home/gpadmin/gpinitsystem_config

     

    ARRAY_NAME="EMC Greenplum DW"

    SEG_PREFIX=gpseg       (前缀)

    PORT_BASE=40000

    declare -a DATA_DIRECTORY=(/data1/primary /data1/primary

    /data1/primary /data2/primary /data2/primary /data2/primary)

    MASTER_HOSTNAME=mdw     (主机名)

    MASTER_DIRECTORY=/data/master  (主机目录)

    MASTER_PORT=5432

    TRUSTED SHELL=ssh

    CHECK_POINT_SEGMENTS=8

    ENCODING=UNICODE

     

    MIRROR_PORT_BASE=50000

    REPLICATION_PORT_BASE=41000

    MIRROR_REPLICATION_PORT_BASE=51000

    declare -a MIRROR_DATA_DIRECTORY=(/data1/mirror /data2/mirror )

     

    (8)    初始化数据库

    # gpinitsystem -c gpinitsystem_config -h /opt/gpssh_segonly

     

    (9)    创建启用standby

    # gpstate -s(查询gp是否启动)

     

    # gpinitstandby -s seg(主机名称)

     

           

     

     

        PS此版本的GP添加standby不需要关闭gp,可在线操作

     

    # gpinitstandby -r (删除Standby

     

    (10)  使用命令

    gpstart

     

    常用的启动参数有以下几个参数:

    -a,该模式不需要在启动过程中输入Y进行确认,将直接启动数据库。

    -m,只启动Master节点,不启动Segment节点,通常在维护的时候使用。

    -y,只启动Masterprimary节点,不启动standby节点

     

    gpstop

    常用的参数如下:

    -a,不需要输入Y确认是否关闭,将直接关闭数据库。

     

    -m,只关闭Master节点,一般用于维护模式

     

    -r,重启数据库。

     

    -u,加载参数文件,使修改的参数生效。pg_hba.conf配置文件和Masterpostgresql.confpg_hba.conf文件中运行时参数的更改,活动会话将会在它们重新连接到数据库时使用这些更新。很多服务器配置参数需要完全重启系统(gpstop -r)才能激活

     

    -M,设置关闭数据库的级别,有三种级别,fastimmediatesmart

    Immediate smart 这是默认的关闭级别,所有连接的会话会收到关闭警告,不允许新链接访问数据库。

    gpstop –M immediate,强制关闭数据库,这种方式是不一致的关闭模式,不建议使用。

    gpstop –M fast 快速模式,停止所有连接将中断并且回滚

     

    gpstate

     

    -s,详细信息。

     

    -mMirror信息。

     

    -fMasterStandby信息。

     

    -eSegmentMirror信息。

     

    -i,版本信息。

     

    5   Greenplum监控安装

    参考文件:http://blog.csdn.net/sunziyue/article/details/50787250

    5.1基本说明

    greenplum安装介质:greenplum-cc-web-3.3.3-LINUX-x86_64.zip

    安装目录规划:/opt/greenplum-cc-web

    5.2安装GPCC(仅master用户)

    (1) 运行gpperfmon_install命令(gpadmin用户)

    # gpperfmon_install --enable --password gpadmin --port 5432

    PS:此处的passwordgpadmin

     

    可以看到命令执行后,会创建gpmon角色,以及设置了密码(这里的密码将会和gpadmin一样),这个用户可以登录到数据库里面,也可用于登录页面。

    # gpstop -r

     

    (2) 安装监控

    # ./greenplum-cc-web-3.3.3-LINUX-x86_64.bin

     

    (3) 执行分发到其他节点

    # source  /opt/greenplum-cc-web-3.3.3/gpcc_path.sh

     

    # gpccinstall -f gpssh_segonly

     

     

    (4) 添加信任ip

    # gpstop

    # vi /data/master/gpseg-1/pg_hba.conf

    添加

    host     gpperfmon   gpmon         ::1/128         md5

    # gpstart

     

    (5) 配置参数

    # gpcmdr --setup

     

    # gpcmdr --start gpcc

     

    (6) 使用浏览器访问http://192.168.229.151:28080

    用户名:gpmon

    密码:gpadmin

     

     

    如果节点挂掉了,使用下面的命令重启:

    #gprecoverseg (–r)

    新添加mirror:

    https://yq.aliyun.com/articles/186

    新添加mirror(新增主机):

    https://yq.aliyun.com/articles/177

    最详尽的安装教程(包括镜像、standbygpcc):

    http://blog.csdn.net/mchdba/article/details/71036925

     

     

    问题收集:

     

    问题1:

     

    输入 gpseginstall -f all_hosts -u gpadmin -p gpadmin命令后报错

     

    20181029:01:47:30:002106 gpseginstall:mdw:cjy513203427-[ERROR]:---user option 'gpadmin' does not equal non-root user running this utility 'cjy513203427'

     

    解决:

    su root
    source /etc/profile
    source greenplum_path.sh
    

     

     

    问题2:

    认证失败1

     

    The authenticity of host 'sdw1 (192.168.94.133)' can't be established.
    ECDSA key fingerprint is SHA256:Q7g1fcB462x1yr+xDwwSTIL0oNskMi6D3tVvtpnyxbM.
    ECDSA key fingerprint is MD5:4a:7f:43:0e:a2:c7:23:cb:e8:75:08:7d:e5:cb:0c:a8.
    Are you sure you want to continue connecting (yes/no)? The authenticity of host 'sdw2 (192.168.94.134)' can't be established.
    ECDSA key fingerprint is SHA256:Hr7Ff9oBRf0avLL/ykGG8Szc+jVbIT1S4x5Rktz+Leo.
    ECDSA key fingerprint is MD5:c6:c0:7d:e0:90:22:dc:d9:7c:37:86:76:d5:aa:f3:e6.
    Are you sure you want to continue connecting (yes/no)? ^[[Cye^H^H^H^H^H^H^H^He^H^H^H^H^Hyes
    Please type 'yes' or 'no': yes
    yes
    20181029:03:15:31:005134 gpseginstall:mdw:root-[ERROR]:-command failed: 'scp /usr/local/greenplum-db-4.3.6.2.tar.gz sdw1:/usr/local': Warning: Permanently added 'sdw1,192.168.94.133' (ECDSA) to the list of known hosts.
    Authentication failed.
    lost connection
    20181029:03:15:31:005134 gpseginstall:mdw:root-[ERROR]:-command failed: 'scp /usr/local/greenplum-db-4.3.6.2.tar.gz sdw2:/usr/local': Could not create directory '/root/.ssh'.
    Warning: Permanently added 'sdw2,192.168.94.134' (ECDSA) to the list of known hosts.
    Authentication failed.
    lost connection

     

    解决:

    解决方法和问题3一样

    问题3:

    认证失败2(root用户下)

    [ERROR] unable to login to sdw1
    hint: use gpssh-exkeys to setup public-key authentication between hosts
    [ERROR] unable to login to sdw2
    hint: use gpssh-exkeys to setup public-key authentication between hosts
    [ERROR] unable to login to mdw
    hint: use gpssh-exkeys to setup public-key authentication between hosts 

     解决:

    参考:https://blog.csdn.net/qq_16018407/article/details/52982228

    生成key

    ssh-keygen -t rsa

     生成过程按回车,默认

    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:+NPchElOC4Fd/IM5nCBNwNc+GuHQ5olEYJazNT99N/Q root@mdw
    The key's randomart image is:
    +---[RSA 2048]----+
    |    +=oBo+.      |
    |   oo O O.o   .  |
    |     = @.Bo= . . |
    |    . ..B=X++ o E|
    |      . S+=+.o . |
    |       ..o o     |
    |        o o .    |
    |         .       |
    |                 |
    +----[SHA256]-----+

    ssh各个服务器测试

    ssh mdw
    ssh sdw1
    ssh sdw2

    此时再交换key,再次强调,root用户下

    gpssh-exkeys -f  /usr/local/greenplum-db/all_hosts

    运行结果

    [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] authorize current user on remote hosts
      ... send to mdw
      ***
      *** Enter password for mdw: 
      ... send to sdw1
    
    [STEP 4 of 5] determine common authentication file content
    
    [STEP 5 of 5] copy authentication files to all remote hosts
      ... finished key exchange with mdw
      ... finished key exchange with sdw1
    
    [INFO] completed successfully

    验证是否可以免密

    gpssh -f /usr/local/greenplum-db/all_hosts -e ls -l $GPHOME
    

     成功

    [ mdw] ls -l /usr/local/greenplum-db/.
    [ mdw] total 268
    [ mdw] -rw-r--r--. 1 gpadmin gpadmin     14 Oct 29 03:06 all_hosts
    [ mdw] drwxr-xr-x. 3 gpadmin gpadmin   4096 Nov 13  2015 bin
    [ mdw] drwxr-xr-x. 2 gpadmin gpadmin     64 Nov 12  2015 demo
    [ mdw] drwxr-xr-x. 5 gpadmin gpadmin     52 Nov 12  2015 docs
    [ mdw] drwxr-xr-x. 2 gpadmin gpadmin     44 Nov 12  2015 etc
    [ mdw] drwxr-xr-x. 3 gpadmin gpadmin     20 Nov 12  2015 ext
    [ mdw] -rw-r--r--. 1 gpadmin gpadmin  43025 Nov 13  2015 GPDB-LICENSE.txt
    [ mdw] -rw-r--r--. 1 gpadmin gpadmin    676 Oct 29 02:22 greenplum_path.sh
    [ mdw] drwxr-xr-x. 6 gpadmin gpadmin   4096 Nov 12  2015 include
    [ mdw] drwxr-xr-x. 9 gpadmin gpadmin   8192 Nov 12  2015 lib
    [ mdw] -rw-r--r--. 1 gpadmin gpadmin 192912 Nov 13  2015 LICENSE.thirdparty
    [ mdw] drwxr-xr-x. 2 gpadmin gpadmin   4096 Nov 13  2015 sbin
    [ mdw] drwxr-xr-x. 4 gpadmin gpadmin     35 Nov 12  2015 share
    [sdw1] ls -l /usr/local/greenplum-db/.
    [sdw1] total 268
    [sdw1] -rw-r--r--. 1 gpadmin gpadmin     14 Oct 29 03:06 all_hosts
    [sdw1] drwxr-xr-x. 3 gpadmin gpadmin   4096 Nov 13  2015 bin
    [sdw1] drwxr-xr-x. 2 gpadmin gpadmin     64 Nov 12  2015 demo
    [sdw1] drwxr-xr-x. 5 gpadmin gpadmin     52 Nov 12  2015 docs
    [sdw1] drwxr-xr-x. 2 gpadmin gpadmin     44 Nov 12  2015 etc
    [sdw1] drwxr-xr-x. 3 gpadmin gpadmin     20 Nov 12  2015 ext
    [sdw1] -rw-r--r--. 1 gpadmin gpadmin  43025 Nov 13  2015 GPDB-LICENSE.txt
    [sdw1] -rw-r--r--. 1 gpadmin gpadmin    676 Oct 29 02:22 greenplum_path.sh
    [sdw1] drwxr-xr-x. 6 gpadmin gpadmin   4096 Nov 12  2015 include
    [sdw1] drwxr-xr-x. 9 gpadmin gpadmin   8192 Nov 12  2015 lib
    [sdw1] -rw-r--r--. 1 gpadmin gpadmin 192912 Nov 13  2015 LICENSE.thirdparty
    [sdw1] drwxr-xr-x. 2 gpadmin gpadmin   4096 Nov 13  2015 sbin
    [sdw1] drwxr-xr-x. 4 gpadmin gpadmin     35 Nov 12  2015 share
    [sdw2] ls -l /usr/local/greenplum-db/.
    [sdw2] total 268
    [sdw2] -rw-r--r--. 1 gpadmin gpadmin     14 Oct 29 03:06 all_hosts
    [sdw2] drwxr-xr-x. 3 gpadmin gpadmin   4096 Nov 13  2015 bin
    [sdw2] drwxr-xr-x. 2 gpadmin gpadmin     64 Nov 12  2015 demo
    [sdw2] drwxr-xr-x. 5 gpadmin gpadmin     52 Nov 12  2015 docs
    [sdw2] drwxr-xr-x. 2 gpadmin gpadmin     44 Nov 12  2015 etc
    [sdw2] drwxr-xr-x. 3 gpadmin gpadmin     20 Nov 12  2015 ext
    [sdw2] -rw-r--r--. 1 gpadmin gpadmin  43025 Nov 13  2015 GPDB-LICENSE.txt
    [sdw2] -rw-r--r--. 1 gpadmin gpadmin    676 Oct 29 02:22 greenplum_path.sh
    [sdw2] drwxr-xr-x. 6 gpadmin gpadmin   4096 Nov 12  2015 include
    [sdw2] drwxr-xr-x. 9 gpadmin gpadmin   8192 Nov 12  2015 lib
    [sdw2] -rw-r--r--. 1 gpadmin gpadmin 192912 Nov 13  2015 LICENSE.thirdparty
    [sdw2] drwxr-xr-x. 2 gpadmin gpadmin   4096 Nov 13  2015 sbin
    [sdw2] drwxr-xr-x. 4 gpadmin gpadmin     35 Nov 12  2015 share

    问题4:

    重启服务器之后报错

     

    解决:

    转到根目录下,(root目录下)

     

    vi .bashrc,添加

     

    source /opt/gp/greenplum_path.sh
    export MASTER_DATA_DIRECTORY= /data/master/gpseg-1
    

     

     在source .bashrc

     

    如果还报错,在root和gpadmin用户下都进行

     

    source /usr/local/greenplum-db/greenplum_path.sh
    

     

     问题5:

    如何进入数据库

    解决:

    进入默认数据库template1

    psql -d template1

    退出:q

    问题6:

    psql -d template1 -U dylan ,切换用户进入数据库的时候报错

    no pg_hba.conf entry for host "[local]", user "dylan", database "template1", SSL off
    Previous connection kept

    解决:

    vi /data/primary/gpseg-1/pg_hba.conf

    追加

    host     all         dylan         192.168.94.132/32       trust

    重启服务:gpstop后再gpstart

    c template1 dylan

    如若不行,则退出psql,用dylan用户进入数据库template1,并指定host

    psql -d template1 -U dylan -h 192.168.94.132

    问题7:

    交换key失败

    gpssh-exkeys -f /usr/local/greenplum-db/all_hosts

    [STEP 1 of 5] create local ID and authorize on local host
      ... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped
    [ERROR mdw] authentication check failed:
         Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
    [ERROR] cannot establish ssh access into the local host

    解决:

    一定要在root下交换key。否则日后连接子服务器没有权限rwx文件

    gpssh-exkeys -f /usr/local/greenplum-db/all_hosts

     结果如下

    [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] authorize current user on remote hosts
      ... send to sdw1
      ***
      *** Enter password for sdw1: 
    [ERROR sdw1] bad password
      ***
      *** Enter password for sdw1: 
      ... send to sdw2
    
    [STEP 4 of 5] determine common authentication file content
    
    [STEP 5 of 5] copy authentication files to all remote hosts
      ... finished key exchange with sdw1
      ... finished key exchange with sdw2
    
    [INFO] completed successfully
    

    问题8:

    使用gpssh创建文件总是在当前用户目录下(root)

    解决:

    gpssh中mkdir和rm命令的路径是绝对路径,指明路径就可以,用"/"

    问题9:

    20181114:10:56:50:gpinitsystem:mdw:gpadmin-[FATAL]:-Cannot write to /data1/primary on sdw1  Script Exiting!

    解决:

    安装edit rpm包

    [root@mdw edit]# rpm -ivh ed-1.9-4.el7.x86_64.rpm 
    warning: ed-1.9-4.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:ed-1.9-4.el7                     ################################# [100%]
  • 相关阅读:
    深入理解泛型之JAVA泛型的继承和实现、泛型擦除
    hadoop过程中遇到的错误与解决方法
    微服务拆分到什么粒度合适——康威定律
    墨菲定律(设计系统)和康威定律(系统划分)
    Hadoop-Impala学习笔记之SQL参考
    Hadoop-Impala学习笔记之管理
    Hadoop2-HDFS学习笔记之入门(不含YARN及MR的调度功能)
    Hadoop-Impala学习笔记之入门
    解决 Invalid character found in method name. HTTP method names must be tokens 异常信息
    从康威定律和技术债看研发之痛
  • 原文地址:https://www.cnblogs.com/Java-Starter/p/9870382.html
Copyright © 2020-2023  润新知