gs_preinstall
GaussDB 100提供了gs_preinstall工具来帮助完成集群的环境配置,以保证集群安装的正常进行。
注意事项
- 检查上层目录权限,保证安装用户对安装包和配置文件目录读写执行的权限。
- 安装包放置的目录中没有其他用户的文件。
- 配置文件中各主机的名称与IP映射配置正确。
- 使用root用户执行gs_preinstall命令。
语法
- 准备集群环境
gs_preinstall -U USER -G GROUP -X XMLFILE [--alarm-type=ALARMTYPE] [--alarm-server-addr=HOSTADDR] [-L] [--skip-os-set] [--env-var="ENVVAR" [...]] [--sep-env-file=MPPRCFILE] [--skip-hostname-set] [-l LOGFILE] [--non-interactive] [--operation=OPERATION]
- 显示帮助信息
gs_preinstall -? | --help
- 显示版本号信息
gs_preinstall -V | --version
参数说明
- -U
运行集群的操作系统用户名,同时也是数据库管理员用户名。
取值范围:字符串,要符合标识符的命名规范。
- -G
运行集群的操作系统用户的群组名。
取值范围:字符串,要符合标识符的命名规范。
- -X
集群配置文件路径。
取值范围:clusterconfig.xml的路径。
- --alarm-type=ALARMTYPE
告警类型。
取值范围:1、3。默认值为1。- 当--alarm-type=1
表示使用第三方工具FusionInsight获取告警信息。
- 当--alarm-type=3
表示alarm是经过了处理的syslog信息。
取值为3时,需要添加--alarm-server-addr参数,参数值为syslog服务端IP地址。
syslog服务端支持主备配置。当有主备服务器时,--alarm-server-addr的值为两个服务器的IP值,两IP之间用逗号隔开,逗号之前为主服务器IP,之后为备服务器IP。如"--alarm-server-addr=10.10.0.11,10.10.0.12",表示10.10.0.11为主服务器IP地址,10.10.0.12为备服务器IP地址。
如果需要配置的服务器不在集群内,需要手动配置服务器syslog环境,主备服务器每台机器上的配置都要修改。设置“/etc/rsyslog.conf”文件,在文件中添加如下内容。
$ModLoad imudp $UDPServerRun 514 $imjournalRatelimitInterval 1 $imjournalRatelimitBurst 50000 local3.* /var/log/syslog_zenith
说明:当告警类型为3时,要产生告警,需要确保以下条件:- 确保防火墙开启514端口。
- 确保SELinux服务处于关闭状态。
- --alarm-server-addr=HOSTADDR
系统日志服务器端IP。
当告警类型为3,则必须指定该参数。参数值为syslog服务端IP地址。服务端可支持主备,当有主备服务器时,--alarm-server-addr的值为两个服务器的IP值,两IP之间用逗号隔开,逗号之前为主服务器IP,之后为备服务器IP。如"--alarm-server-addr=10.10.0.11,10.10.0.12",表示10.10.0.11为主服务器IP地址,10.10.0.12为备服务器IP地址。如果需要配置的服务器不在集群内,需要手动配置服务器syslog环境,设置“/etc/rsyslog.conf”文件,在文件中添加如下内容。
$ModLoad imudp $UDPServerRun 514 $imjournalRatelimitInterval 1 $imjournalRatelimitBurst 50000 local3.* /var/log/syslog_zenith
- -L
指定该参数则仅给当前节点准备好集群安装环境。适用于不允许使用root互信的场景。需要满足如下前提条件:
- 安装包和集群配置文件已提前上传到所有主机。
- 集群安装用户已提前创建好并建立好互信关系。
- 用户需要自己保证各台主机上所执行命令的一致性。
- --skip-os-set
是否设置操作系统参数。默认设置系统参数(不包括配置NTP服务)。如果指定该参数则不设置。
- --env-var="ENVVAR"
配置普通用户环境变量。可以指定多个。
取值范围:字符串。
说明:不能指定集群默认创建的环境变量。默认创建的环境变量见表1。
- --sep-env-file=MPPRCFILE
MPPRCFILE是环境变量分离文件,用户保存环境变量的文件。如果指定该参数,表示集群中生成的所有环境变量军保存在该文件中,而不再保存在/etc/profile和用户的~/.bashrc文件中。
说明:- 使用环境变量分离文件时,可以使用不同操作系统用户和不同环境变量分离文件在一组服务器上安装多组集群。
- 环境变量文件名不能和集群相关目录以及集群用户目录同名。
- 必须保证集群用户对目录有读、写权限。
- --skip-hostname-set
是否将xml配置文件中主机名与IP的映射关系写入“/etc/hosts”文件中。默认写入,如果指定该参数则不写入。
- -l
指定日志文件名及路径。在内部会自动给日志名添加一个时间戳。
默认值:$GAUSSLOG/om/gs_preinstall.log
- 当既不明确指定-l,又不在XML文件中配置gaussdbLogPath时,默认值为“/var/log/gaussdb/用户名/om/gs_preinstall-YYYY-MM-DD_hhmmss.log”。
- 当不明确指定-l,但在XML文件中配置了gaussdbLogPath时,默认值为gaussdbLogPath的值、用户名和om/gs_preinstall-YYYY-MM-DD_hhmmss.log的组合。
- --non-interactive
指定前置执行模式。
当各个节点的root互信和集群用户互信已经创建,且集群用户已创建好的情况下,才可以在执行前置时使用此参数。
- --operation
指定是哪种操作类型的预安装。
不指定该参数,默认是正常的预安装。
取值范围:upgrade。在升级的时候,指定该参数,可执行简化的预安装操作,只实现和升级有关的操作,不做全量的预安装准备工作。
- --lvm-enable
是否执行LVM管理。
此参数实现在前置时自动对磁盘进行LVM分区和挂载目录。
当各个节点上的数据盘已经配置好RAID,且还未挂载时,才能在执行前置时使用此参数。
- -?,--help
显示帮助信息。
- -V,--version
显示版本号信息。
表1 GaussDB 100默认创建的环境变量 环境变量名称
说明
SEPARATE_ENV_FILE
集群环境变量分离文件路径
GPHOME
集群工具目录
PATH
集群工具脚本目录
LD_LIBRARY_PATH
集群引用第三方动态库路径
PYTHONPATH
python软件路径
GAUSS_WARNING_TYPE
告警类型
CM_HOME
cm安装目录
GAUSS_HOME
数据库安装目录
GAUSSHOME
数据库安装目录
ETCD_HOME
etcd安装目录
ETCD_CERT_SERVER_FILE
etcd的证书互信文件
ETCD_KEY_SERVER_FILE
etcd的证书互信文件
ETCD_CA_SERVER_FILE
etcd的证书互信文件
ETCD_CA_MEMBER_FILE
etcd的证书互信文件
ETCD_CERT_MEMBER_FILE
etcd的证书互信文件
ETCD_KEY_MEMBER_FILE
etcd的证书互信文件
ETCD_CA_CLIENT_FILE
etcd的证书互信文件
ETCD_KEY_CLIENT_FILE
etcd的证书互信文件
ETCD_CERT_CLIENT_FILE
etcd的证书互信文件
ETCDCTL_API
ETCDCTL支持的版本
GAUSSTMP
集群临时文件路径
GS_CLUSTER_NAME
集群名称
GAUSSLOG
集群日志路径
ETCD_ADDRESS
集群访问etcd地址
GAUSS_ENV
集群安装标识
ROACH_HOME
roach安装目录
手动设置服务端SYSLOG配置
- 当机器的syslog类型为rsyslog时,服务器端的配置方法为:
设置“/etc/rsyslog.conf”文件,在文件中添加如下内容:
$ModLoad imudp $UDPServerRun 514 $imjournalRatelimitInterval 1 $imjournalRatelimitBurst 50000 local3.* /var/log/syslog_zenith
- 当机器的syslog类型为syslog-ng时,服务器端的配置方法为:
设置“/etc/syslog-ng/syslog-ng.conf”文件,在文件中添加如下内容:
source s_gaussdb{ udp(ip("0.0.0.0") port(514)); }; filter f_gaussdb { level(debug..emerg) and facility(local3); }; destination d_gaussdb { file("/var/log/syslog_zenith"); }; log { source(src); source(s_gaussdb); filter(f_gaussdb); destination(d_gaussdb); };
设置“/etc/sysconfig/syslog”文件,在文件中添加如下内容:
SYSLOGD_OPTIONS="-r -m 0" KLOGD_OPTIONS="-x"
说明:该配置需要在集群每台机器上都要修改。
示例
- 使用gs_preinstall准备数据库集群安装环境的过程中,输入root用户的密码有3次机会,输入安装集群的操作系统用户密码只有1次机会,输错密码超过规定次数则会报相应错误并退出gs_preinstall的执行过程。
- 使用gs_preinstall准备数据库集群的安装环境时,如果返回如下所示告警信息(其中/opt/software/gaussdb/script为工具存放目录),请执行“/opt/software/gaussdb/script/gs_checkos -i A -h plat1,plat2,plat3 -X /opt/software/gaussdb/clusterconfig.xml”(/opt/software/gaussdb为配置文件clusterconfig.xml的存放目录)命令排查告警原因,并对告警项进行修复,避免对数据库集群的安装或安装后的正常使用产生影响。
Warning: Installation environment contains some warning messages. Please get more details by "/opt/software/gaussdb/script/gs_checkos -i A -h plat1,plat2,plat3".
- 使用安全交互模式进行集群环境准备:
- 如果数据库集群安装用户omm在当前集群各节点上不存在,那么使用gs_preinstall准备安装环境时会自动创建安装用户:
plat1:/opt/software/gaussdb/script #./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig.xml Parsing the configuration file. Successfully parsed the configuration file. Installing the tools on the local node. Successfully installed the tools on the local node. Are you sure you want to create trust for root (yes/no)? yes Please enter password for root. Password: Creating SSH trust for the root permission user. Checking network information. All nodes in the network are Normal. Successfully checked network information. Creating SSH trust. Creating the local key file. Successfully created the local key files. Appending local ID to authorized_keys. Successfully appended local ID to authorized_keys. Updating the known_hosts file. Successfully updated the known_hosts file. Appending authorized_key on the remote node. Successfully appended authorized_key on all remote node. Checking common authentication file content. Successfully checked common authentication content. Distributing SSH trust file to all node. Successfully distributed SSH trust file to all node. Verifying SSH trust on all hosts. Successfully verified SSH trust on all hosts. Successfully created SSH trust. Successfully created SSH trust for the root permission user. Pass over configuring LVM Distributing package. Successfully distributed package. Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes Please enter password for cluster user. Password: Please enter password for cluster user again. Password: Creating [omm] user on all nodes. Successfully created [omm] user on all nodes. Installing the tools in the cluster. Successfully installed the tools in the cluster. Checking hostname mapping. Successfully checked hostname mapping. Creating SSH trust for [omm] user. Please enter password for current user[omm]. Password: Checking network information. All nodes in the network are Normal. Successfully checked network information. Creating SSH trust. Creating the local key file. Successfully created the local key files. Appending local ID to authorized_keys. Successfully appended local ID to authorized_keys. Updating the known_hosts file. Successfully updated the known_hosts file. Appending authorized_key on the remote node. Successfully appended authorized_key on all remote node. Checking common authentication file content. Successfully checked common authentication content. Distributing SSH trust file to all node. Successfully distributed SSH trust file to all node. Verifying SSH trust on all hosts. Successfully verified SSH trust on all hosts. Successfully created SSH trust. Successfully created SSH trust for [omm] user. Checking OS version. Successfully checked OS version. Creating cluster's path. Successfully created cluster's path. Setting SCTP service. Successfully set SCTP service. Set and check OS parameter. Setting OS parameters. Successfully set OS parameters. Set and check OS parameter completed. Preparing CRON service. Successfully prepared CRON service. Preparing SSH service. Successfully prepared SSH service. Setting user environmental variables. Successfully set user environmental variables. Configuring alarms on the cluster nodes. Successfully configured alarms on the cluster nodes. Setting the dynamic link library. Successfully set the dynamic link library. Fixing server package owner. Successfully fixed server package owner. Create logrotate service. Successfully create logrotate service. Setting finish flag. Successfully set finish flag. Preinstallation succeeded.
- 如果数据库集群安装用户omm在当前集群各节点上已存在,那么使用gs_preinstall准备安装环境时不再创建安装用户:
plat1:/opt/software/gaussdb/script #./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig.xml Parsing the configuration file. Successfully parsed the configuration file. Installing the tools on the local node. Successfully installed the tools on the local node. Are you sure you want to create trust for root (yes/no)? yes Please enter password for root. Password: Creating SSH trust for the root permission user. Checking network information. All nodes in the network are Normal. Successfully checked network information. Creating SSH trust. Creating the local key file. Successfully created the local key files. Appending local ID to authorized_keys. Successfully appended local ID to authorized_keys. Updating the known_hosts file. Successfully updated the known_hosts file. Appending authorized_key on the remote node. Successfully appended authorized_key on all remote node. Checking common authentication file content. Successfully checked common authentication content. Distributing SSH trust file to all node. Successfully distributed SSH trust file to all node. Verifying SSH trust on all hosts. Successfully verified SSH trust on all hosts. Successfully created SSH trust. Successfully created SSH trust for the root permission user. Distributing package. Successfully distributed package. Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes Installing the tools in the cluster. Successfully installed the tools in the cluster. Checking hostname mapping. Successfully checked hostname mapping. Creating SSH trust for [omm] user. Please enter password for current user[omm]. Password: Checking network information. All nodes in the network are Normal. Successfully checked network information. Creating SSH trust. Creating the local key file. Successfully created the local key files. Appending local ID to authorized_keys. Successfully appended local ID to authorized_keys. Updating the known_hosts file. Successfully updated the known_hosts file. Appending authorized_key on the remote node. Successfully appended authorized_key on all remote node. Checking common authentication file content. Successfully checked common authentication content. Distributing SSH trust file to all node. Successfully distributed SSH trust file to all node. Verifying SSH trust on all hosts. Successfully verified SSH trust on all hosts. Successfully created SSH trust. Successfully created SSH trust for [omm] user. Checking OS version. Successfully checked OS version. Creating cluster's path. Successfully created cluster's path. Setting SCTP service. Successfully set SCTP service. Set and check OS parameter. Setting OS parameters. Successfully set OS parameters. Set and check OS parameter completed. Preparing CRON service. Successfully prepared CRON service. Preparing SSH service. Successfully prepared SSH service. Setting user environmental variables. Successfully set user environmental variables. Configuring alarms on the cluster nodes. Successfully configured alarms on the cluster nodes. Setting the dynamic link library. Successfully set the dynamic link library. Fixing server package owner. Successfully fixed server package owner. Create logrotate service. Successfully create logrotate service. Setting finish flag. Successfully set finish flag. Preinstallation succeeded.
- 仅给当前主机准备好集群安装环境:
plat1:/opt/software/gaussdb/script #./gs_preinstall -U omm -G dbgrp -L -X /opt/software/gaussdb/clusterconfig.xml Parsing the configuration file. Successfully parsed the configuration file. Installing the tools on the local node. Successfully installed the tools on the local node. Checking OS version. Successfully checked OS version. Creating cluster's path. Successfully created cluster's path. Setting SCTP service. Successfully set SCTP service. Set and check OS parameter. Setting OS parameters. Successfully set OS parameters. Set and check OS parameter completed. Preparing CRON service. Successfully prepared CRON service. Preparing SSH service. Successfully prepared SSH service. Setting user environmental variables. Successfully set user environmental variables. Configuring alarms on the cluster nodes. Successfully configured alarms on the cluster nodes. Setting the dynamic link library. Successfully set the dynamic link library. Fixing server package owner. Successfully fixed server package owner. Create logrotate service. Successfully create logrotate service. Setting finish flag. Successfully set finish flag. Preinstallation succeeded.
- 执行升级时,需要先执行预安装,可执行简化的预安装。
plat1:/opt/software/gaussdb/script #./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig.xml --operation=upgrade Parsing the configuration file. Successfully parsed the configuration file. Do preinstall for upgrade. Check environment for upgrade preinstall. Successfully check environment for upgrade preinstall. Installing the tools on the local node. Successfully installed the tools on the local node. Distributing package. Successfully distributed package. Check old environment on all nodes. Successfully check old environment on all nodes. Installing the tools in the cluster. Successfully installed the tools in the cluster. Fixing server package owner. Successfully fixed server package owner. Preinstallation succeeded.
相关命令
gs_install,gs_postuninstall
- 执行升级时,需要先执行预安装,可执行简化的预安装。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」关注作者【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。评论
- 如果数据库集群安装用户omm在当前集群各节点上已存在,那么使用gs_preinstall准备安装环境时不再创建安装用户:
- 如果数据库集群安装用户omm在当前集群各节点上不存在,那么使用gs_preinstall准备安装环境时会自动创建安装用户:
- -L
- 当--alarm-type=1
- 显示帮助信息