安装Greenplum-cc-web监控软件
-----written by jiangshouzhuang
操作系统信息:
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1
软件包(如果需要此包,请联系我):
greenplum-cc-web-1.2.2.1-x86_64.tar.gz
安装节点(所有节点都提前部署好了greenplum-db-4.3.0.0数据库,并且数据库启动正常并可访问):
我安装的环境如下:
10.41.24.101 linux113 --------Greenplum Segment
10.41.24.102 linux116 --------Greenplum Primary Master
10.41.24.103 NOAS252 --------Greenplum Standby Master
执行Greenplum DB数据库的gpperfmon_install工具,完成GP监控软件安装的前期准备工作
gpperfmon_install工具的功能大致是:
创建greenplum监控用数据库(gpperfmon)
创建greenplum监控用数据库角色(gpmon)
配置greenplum数据库接受来自perfmon监控的链接文件(pg_hba.conf和.pgpass)
设置postgresql.conf文件,增加启用监控的参数。(这些参数默认会添加在文件的末尾)
下面在GreenplumMaster节点操作:
1) 使用gpadmin用户登录
linux116:~# su - gpadmin
2) 执行 gpperfmon_install 命令
gpadmin@linux116:~> gpperfmon_install--enable --password huawei123 --port 5432
20140519:16:15:07:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 psql -f/usr/local/greenplum-db/lib/gpperfmon/gpperfmon3.sql template1 >&/dev/null
20140519:16:15:28:026251 gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432psql -f /usr/local/greenplum-db/lib/gpperfmon/gpperfmon4.sql gpperfmon>& /dev/null
20140519:16:15:29:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 psql -f/usr/local/greenplum-db/lib/gpperfmon/gpperfmon41.sql gpperfmon >&/dev/null
20140519:16:15:33:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 psql -f/usr/local/greenplum-db/lib/gpperfmon/gpperfmon42.sql gpperfmon >&/dev/null
20140519:16:15:36:026251 gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432psql -f /usr/local/greenplum-db/lib/gpperfmon/gpperfmonC.sql template1>& /dev/null
20140519:16:15:36:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 psql template1 -c"DROP ROLE IF EXISTS gpmon" >& /dev/null
20140519:16:15:36:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 psql template1 -c"CREATE ROLE gpmon WITH SUPERUSER CREATEDB LOGIN ENCRYPTED PASSWORD'huawei123'" >& /dev/null
20140519:16:15:37:026251 gpperfmon_install:linux116:gpadmin-[INFO]:-echo"local gpperfmon gpmon md5" >>/data/master/gpseg-1/pg_hba.conf
20140519:16:15:37:026251 gpperfmon_install:linux116:gpadmin-[INFO]:-echo"host all gpmon 127.0.0.1/28 md5" >>/data/master/gpseg-1/pg_hba.conf
20140519:16:15:37:026251gpperfmon_install:linux116:gpadmin-[INFO]:-touch /home/gpadmin/.pgpass>& /dev/null
20140519:16:15:37:026251 gpperfmon_install:linux116:gpadmin-[INFO]:-mv-f /home/gpadmin/.pgpass /home/gpadmin/.pgpass.1400487307 >& /dev/null
20140519:16:15:37:026251 gpperfmon_install:linux116:gpadmin-[INFO]:-echo"*:5432:gpperfmon:gpmon:huawei123" >> /home/gpadmin/.pgpass
20140519:16:15:37:026251 gpperfmon_install:linux116:gpadmin-[INFO]:-cat/home/gpadmin/.pgpass.1400487307 >> /home/gpadmin/.pgpass
20140519:16:15:37:026251gpperfmon_install:linux116:gpadmin-[INFO]:-chmod 0600 /home/gpadmin/.pgpass>& /dev/null
20140519:16:15:37:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 gpconfig -cgp_enable_gpperfmon -v on >& /dev/null
20140519:16:15:43:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 gpconfig -cgpperfmon_port -v 8888 >& /dev/null
20140519:16:15:49:026251gpperfmon_install:linux116:gpadmin-[INFO]:-PGPORT=5432 gpconfig -cgp_external_enable_exec -v on --masteronly >& /dev/null
20140519:16:15:55:026251gpperfmon_install:linux116:gpadmin-[INFO]:-gpperfmon will be enabled after afull restart of GPDB
注:可以看到命令执行后,会创建gpmon角色,以及设置了密码,这个用户可以登录到数据库里面,也可用于登录页面。
3) 重启greenplum 数据库
gpadmin@linux116:~> gpstop -r
4) 查看gpmon进程,是否已经启用
gpadmin@linux116:~> ps -ef | grep gpmmon |grep -v grep
gpadmin 27036 27027 0 16:18 ? 00:00:00/usr/local/greenplum-db/bin/gpmmon -D /data/master/gpseg-1/gpperfmon/conf/gpperfmon.conf-p 5432
5) 查看数据收集进程是否正常(需要等大约30s左右才可以查看到)
gpadmin@linux116:~> psql gpperfmon -c 'SELECT* FROM system_now;'
ctime | hostname | mem_total | mem_used | mem_actual_used | mem_actual_free |swap_total | swap_used | swap_page_in |swap_page_out | cpu_user | cpu_sys | cpu
_idle | load0 | load1 | load2 | quantum | disk_ro_rate | disk_wo_rate |disk_rb_rate | disk_wb_rate | net_rp_rate | net_wp_rate | net_rb_rate |net_wb_rate
---------------------+----------+-------------+-------------+-----------------+-----------------+-------------+-----------+--------------+---------------+----------+---------+----
------+-------+-------+-------+---------+--------------+--------------+--------------+--------------+-------------+-------------+-------------+-------------
2014-05-19 16:21:30 | linux113| 25202618368 | 21777362944 | 7865163776 | 17337454592| 2154979328 | 23846912 | 0 | 0 | 1.68 | 1.89 |
96.18 | 0.07 | 0.08 | 0.09 | 15 | 0 | 13 | 0 | 135518 | 13 | 15 | 1776 | 2110
2014-05-19 16:21:30 | linux116| 25202618368 | 17788657664 | 2744700928 | 22457917440| 2154979328 | 22982656 | 0 | 0 | 0.71 | 0.22 |
98.56 | 0.1 | 0.16 | 0.06 | 15 | 0 | 7 | 0 | 84269 | 51 | 54 | 11435 | 32212
2014-05-19 16:21:30 | NOAS252 | 50609725440 | 40639737856 | 9263038464 | 41346686976 | 25777983488 | 0 | 0 | 0 | 1.61 | 1.84 |
96.32 | 0.39 | 0.42 | 0.36 | 15 | 0 | 46 | 0 | 454920 | 80 | 75 | 204981 | 183732
(3 rows)
下面配置GreenplumStandby Master节点:
在primarymaster上面执行:
1) 将primary master上面的$MASTER_DATA_DIRECTORY/pg_hba.conf拷贝到standby master的$MASTER_DATA_DIRECTORY/pg_hba.conf
gpadmin@linux116:~> scp $MASTER_DATA_DIRECTORY/pg_hba.confgpadmin@linux113:$MASTER_DATA_DIRECTORY/pg_hba.conf
2) 将primary master上面的~/.pgpass拷贝到standby master的~/.pgpass,并且文件权限修改为0600
gpadmin@linux116:~> scp ~/.pgpass gpadmin@linux113:~/.pgpass
gpadmin@linux116:~> ssh gpadmin@linux113 -C "chmod 0600~/.pgpass"
以下操作都在primarymaster节点操作:
1)下载适合自己机器的greenplum-cc-web安装程序
greenplum-cc-web-1.2.2.1-build-71-RHEL5-x86_64.zip
由于官网上面只能下载到RedHat操作系统的,但是我们要求在SuSE操作系统上面安装。
现在的解决办法是:先在RedHat上面安装好之后,将安装目录打包后,再安装到SuSE上,但是配置文件需要根据需要修改(下面会介绍)。
2) 将获取的GPCC包(greenplum-cc-web-1.2.2.1-x86_64.tar.gz)上传到primarymaster节点的gpadmin用户家目录下面并完成解压操作
linux116:~ # cd /home/gpadmin/
linux116:/home/gpadmin # tar -zxvfgreenplum-cc-web-1.2.2.1-x86_64.tar.gz
linux116:~ # chown -R gpadmin:gpadmingreenplum-cc-web-1.2.2.1-build-71
linux116:~ # chmod -R 755greenplum-cc-web-1.2.2.1-build-71
3) 切换到gpadmin用户并建立软链接
linux116:/home/gpadmin # su - gpadmin
gpadmin@linux116:~> ln -s greenplum-cc-web-1.2.2.1-build-71greenplum-cc-web
4) 修改/home/gpadmin/greenplum-cc-web/gpcc_path.sh文件,将GPPERFMONHOME配置为GP监控的实际家目录,如下:
GPPERFMONHOME=/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71
5) 将"source/home/gpadmin/greenplum-cc-web/gpcc_path.sh"加入到~/.bashrc文件并source使环境变量生效:
gpadmin@linux116:~> echo "source/home/gpadmin/greenplum-cc-web/gpcc_path.sh" >> ~/.bashrc
gpadmin@linux116:~> source .bashrc
6) 将primary master的GP监控软件同时安装到到其他GP节点(如standbymaster和segments):
a. 准备一个文件hostfilename里面包含其他未安装GP监控软件的GPDB数据库的主机名,如下(我的环境只有一个standbymaster和一个segment节点):
gpadmin@linux116:~>cat hostfilename
linux113
NOAS252
b.开始执行gpccinstall工具安装到其他节点
gpadmin@linux116:~> gpccinstall -fhostfilename
20140519:17:06:41:030995gpccinstall:linux116:gpadmin-[INFO]:-Installation Info:
link_name greenplum-cc-web
binary_path /home/gpadmin/greenplum-cc-web-1.2.2.1-build-71
binary_dir_location /home/gpadmin
binary_dir_name greenplum-cc-web-1.2.2.1-build-71
rm -f /home/gpadmin/greenplum-cc-web-1.2.2.1-build-71.tar; rm -f/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71.tar.gz
cd /home/gpadmin; tar cf greenplum-cc-web-1.2.2.1-build-71.targreenplum-cc-web-1.2.2.1-build-71
gzip /home/gpadmin/greenplum-cc-web-1.2.2.1-build-71.tar
20140519:17:06:43:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (linux113): mkdir -p/home/gpadmin
20140519:17:06:43:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (NOAS252): mkdir -p/home/gpadmin
20140519:17:06:44:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (linux113): rm -rf/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71
20140519:17:06:44:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (NOAS252): rm -rf/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71
20140519:17:06:44:030995 gpccinstall:linux116:gpadmin-[INFO]:-scpsoftware to remote location
20140519:17:06:45:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (linux113): gzip -f -d/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71.tar.gz
20140519:17:06:45:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (NOAS252): gzip -f -d/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71.tar.gz
20140519:17:06:45:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (linux113): cd/home/gpadmin; tar xf greenplum-cc-web-1.2.2.1-build-71.tar
20140519:17:06:45:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (NOAS252): cd/home/gpadmin; tar xf greenplum-cc-web-1.2.2.1-build-71.tar
20140519:17:06:46:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (linux113): rm -f/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71.tar
20140519:17:06:46:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (NOAS252): rm -f/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71.tar
20140519:17:06:46:030995 gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommandon (linux113): cd /home/gpadmin; rm -f greenplum-cc-web; ln -fsgreenplum-cc-web-1.2.2.1-build-71 greenplum-cc-web
20140519:17:06:46:030995gpccinstall:linux116:gpadmin-[INFO]:-runPoolCommand on (NOAS252): cd /home/gpadmin;rm -f greenplum-cc-web; ln -fs greenplum-cc-web-1.2.2.1-build-71greenplum-cc-web
20140519:17:06:46:030995 gpccinstall:linux116:gpadmin-[INFO]:-Verifyinginstalled software versions
20140519:17:06:46:030995 gpccinstall:linux116:gpadmin-[INFO]:-remotecommand: . /home/gpadmin/greenplum-cc-web/./gpcc_path.sh;/home/gpadmin/greenplum-cc-web/./bin/gpcmdr --version
20140519:17:06:47:030995 gpccinstall:linux116:gpadmin-[INFO]:-remotecommand: . /home/gpadmin/greenplum-cc-web-1.2.2.1-build-71/gpcc_path.sh;/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71/bin/gpcmdr --version
20140519:17:06:52:030995 gpccinstall:linux116:gpadmin-[INFO]:-SUCCESS --Requested commands completed
以下操作在primarymaster节点执行:
1) 登录到gpadmin用户,停止GP数据库
gpadmin@linux116:~> gpstop
2) 确保gpadmin家目录下面的.bashrc文件中含有如下类似的配置:
source /home/gpadmin/greenplum-cc-web/gpcc_path.sh
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
source /usr/local/greenplum-db/greenplum_path.sh
确保要保存.bashrc文件并source.bashrc 使环境变量生效
3) 启动GP数据库
gpadmin@linux116:~> gpstart
4) GP数据库实例起来后,就可以开始执行gpcmdr--setup命令,开始设置Command Center Console:
gpadmin@linux116:~> gpcmdr --setup
An instance name is used by the GreenplumCommand Center as
a way to uniquely identify a GreenplumDatabase that has the monitoring
components installed and configured. This name is also used to control
specific instances of the Greenplum CommandCenter web UI. Instance names
can contain letters, digits and underscoresand are not case sensitive.
Please enter a new instance name:
> gpmon_82 #gp监控实例名,用于启停监控时指定
The web component of the Greenplum CommandCenter can connect to a
monitor database on a remote GreenplumDatabase.
Is the master host for the GreenplumDatabase remote? Yy|Nn (default=N):
> N #监控是否和GP master同节点,N指同节点
The display name is shown in the webinterface and does not need to be
a hostname.
What would you like to use for the displayname for this instance:
> linux116 #登录GP监控页面展示的名字
What port does the Greenplum Database use?(default=5432):
>
Creating instance schema in GPDB. Please wait ...
The Greenplum Command Center runs a smallweb server for the UI and web API.
This web server by default runs on port28080, but you may specify any available port.
What port would you like the web server touse for this instance? (default=28080):
>
Users logging in to the Command Center mustprovide database user
credentials. In order to protect user names and passwords,it is recommended
that SSL be enabled.
Do you want to enable SSL for the Web APIYy|Nn (default=N):
> Y #是否使用SSL加密方式登录GP监控页面
Generating a 2048 bit RSA private key
............................................................+++
...............................................................................................................................+++
writing new private key to'/home/gpadmin/greenplum-cc-web/./instances/gpmon_82/conf/cert.pem'
-----
You are about to be asked to enterinformation that will be incorporated
into your certificate request.
What you are about to enter is what iscalled a Distinguished Name or a DN.
There are quite a few fields but you canleave some blank
For some fields there will be a default value,
If you enter '.', the field will be leftblank.
-----
#下面都是选填的,自己决定是否填写
Country Name (2 letter code) [AU]:US
State or Province Name (full name)[Some-State]:California
Locality Name (eg, city) []:San Mateo
Organization Name (eg, company) [InternetWidgits Pty Ltd]:Greenplum
Organizational Unit Name (eg, section)[]:Engineering
Common Name (e.g. server FQDN or YOUR name)[]:linux116
Email Address []:[email protected]
Do you want to enable ipV6 for the Web APIYy|Nn (default=N):
>
Do you want to enable Cross Site RequestForgery Protection for the Web API Yy|Nn (default=N):
>
#是否将GP监控实例拷贝到standby master节点(冗余备份的目的)
Do you want to copy the instance to astandby master host Yy|Nn (default=Y):
>
What is the hostname of the standby masterhost? [smdw]: linux113
Done writing lighttpd configuration to/home/gpadmin/greenplum-cc-web/./instances/gpmon_82/conf/lighttpd.conf
Done writing web UI configuration to/home/gpadmin/greenplum-cc-web/./instances/gpmon_82/conf/gpperfmonui.conf
Copying instance 'gpmon_82' to host'linux113'...
Greenplum Command Center UI configurationis now complete. If
at a later date you want to change certainparameters, you can
either re-run 'gpcmdr --setup' or edit theconfiguration file
located at /home/gpadmin/greenplum-cc-web/./instances/gpmon_82/conf/gpperfmonui.conf.
#打印登录网址
The web UI for this instance is availableathttps://linux116:28080/
#打印出启动GP监控命令
You can now start the web UI for thisinstance by running: gpcmdr --start gpmon_82
5) 启动GP监控
gpadmin@linux116:~> gpcmdr --start gpmon_82
Starting instance gpmon_82...
Greenplum Command Center UI for instance 'gpmon_82' - [RUNNING onPORT: 28080]
查看端口号状态:
gpadmin@linux116:~> lsof -i :28080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
lighttpd 353 gpadmin 4u IPv4 145927203 0t0 TCP *:28080 (LISTEN)
6) 使用浏览器访问https://10.41.24.102:28080
输入用户名和密码登录就OK了(gpmon/huawei123)
1) 问题描述,如图所示:
提示用户名或密码不正确,但是我使用psql登录数据库是OK的
gpadmin@linux116:~> psql -dgpperfmon -U gpmon -W
Password for user gpmon: #输入密码huawei123
psql (8.2.15)
Type "help" for help.
gpperfmon=#
通过查看日志/home/gpadmin/greenplum-cc-web/instances/gpmon_82/logs/gpmonws.log
如下:
2014-05-2011:22:37,584 - Checking trust login for gpmon on db gpperfmon, host localhost,port :5432
2014-05-2011:22:37,592 - Trust login not allowed. User gpmon has trust login enabled
2014-05-2011:22:37,592 - Authentication failed user(gpmon)allow_trust_logon(False): Incorrect username/password
我们从日志“Trust login not allowed. User gpmon has trust login enabled”可以看出,gpmon是不容许Trust方式登录的,因为GP监控实例配置文件gpperfmonui.conf中默认配置allow_trust_logon=False,指不容许Trust方式登录。
这时我们就应该想到肯定是GP数据库的权限配置文件pg_hba.conf有问题,查看如下:
gpadmin@linux116:~>cat /data/master/gpseg-1/pg_hba.conf
host all gpadmin 10.41.24.101/32 trust
host replication gpadmin 10.41.24.101/32 trust
host all gpadmin 10.41.28.250/32 trust
host replication gpadmin 10.41.28.250/32 trust
local all gpadmin ident
local all noas md5
host all noas 0.0.0.0/0 trust
host all gpadmin 0.0.0.0/0 trust
host all gpadmin 127.0.0.1/28 trust
host all gpadmin 10.41.24.102/32 trust
host all gpadmin 192.168.100.116/32 trust
host all gpadmin 10.41.28.250/32 trust
host all gpadmin ::1/128 trust
host all gpadmin fe80::225:9eff:feb0:d64a/128 trust
local replication gpadmin ident
host replication gpadmin samenet trust
host all all 0.0.0.0/0 trust
local gpperfmon gpmon md5
host all gpmon 127.0.0.1/28 md5
host all gpmon 0.0.0.0/0 trust
可以看到竟然配置了“host all all 0.0.0.0/0 trust”,容许所有的客户端Trust方式登录,注释掉这一行,然后执行如下命令重新加载pg_hba.conf配置文件:
gpadmin@linux116:~>gpstop –u
然后再重新登录GP监控页面,正确输入用户名和密码就可以登录进去了。
注:如果是希望gpmon可以Trust方式登录页面(指密码可以随便输入就可以登录进去),那么你就可以修改GP监控实例配置文件gpperfmonui.conf中配置项
allow_trust_logon = True,指容许Trust方式登录,然后重启GP监控实例:
gpcmdr --restart gpmon_82
这样就可以Trust方式登录进GP监控页面了(输入正确用户名,密码随便输入)。
1) 登录Master节点,停止CommandCenter Console 服务
$ gpcmdr --stop
2) 登录GP数据库所有节点,删除GP监控安装的目录
先删除软链接,再删除实际GP实际安装目录(Greenplum DB所有节点都执行)
gpadmin@linux116:~> rm -rf/home/gpadmin/greenplum-cc-web
gpadmin@linux116:~> rm -rf/home/gpadmin/greenplum-cc-web-1.2.2.1-build-71
3) 登录Master节点gpadmin用户,禁用掉数据收集代理:
修改 $MASTER_DATA_DIRECTORY/postgresql.conf 文件,将下面的值修改为off:
gp_enable_gpperfmon=off
4) 登录Master节点gpadmin用户,注释掉文件pg_hba.conf下面的内容:
#local gpperfmon gpmon md5
#host gpperfmon gpmon 0.0.0.0/0 md5
5) 删除gpmon角色和gpperfmon数据库
gpadmin@linux116:~> psql template1 -c'DROP ROLE gpmon;'
ERROR: role "gpmon" cannot be dropped because some objects depend onit
DETAIL: 21 objects in database gpperfmon
如果按照官方文档描述,先删除gpmon角色,会报错,建立可以先删除gpperfmon数据库再删除gpmon角色。
gpadmin@linux116:~> dropdb gpperfmon
gpadmin@linux116:~> psql template1 -c'DROP ROLE gpmon;'
6) 重启GP数据库实例:
gpadmin@linux116:~> gpstop -r
7) 登录到master节点上面清理掉下面的内容:(MASTER_DATA_DIRECTORY=/data/master/gpseg-1)
gpadmin@linux116:~> rm -rf$MASTER_DATA_DIRECTORY/gpperfmon/data/*
gpadmin@linux116:~> rm -rf$MASTER_DATA_DIRECTORY/gpperfmon/logs/*