gs_preinstall

背景信息

openGauss提供了gs_preinstall工具来帮助完成openGauss的环境配置,以保证openGauss安装的正常进行。

注意事项

  • 用户需要检查上层目录权限,保证安装用户对安装包和配置文件目录读写执行的权限。
  • xml文件中各主机的名称与IP映射配置正确。
  • 只能使用root用户执行gs_preinstall命令。
  • 执行gs_preinstall会清理/etc/hosts中的openGauss映射信息,可能存在已部署数据库连接丢失风险,可以在安装结束后手动添加其它数据库映射至/etc/hosts文件中。
  • 本产品支持同一操作系统大版本下的小版本混合部署,其支持列表如下:

    1. CentOS 6.4/6.5/6.6/6.7/6.8/6.9
    2. CentOS 7.0/7.1/7.2/7.3/7.4
    3. openEuler

语法

  • 准备openGauss环境

    1. gs_preinstall -U USER -G GROUP -X XMLFILE [-L] [--skip-os-set] [--env-var="ENVVAR" [...]] [--sep-env-file=MPPRCFILE] [--skip-hostname-set] [-l LOGFILE] [--non-interactive]
  • 显示帮助信息

    1. gs_preinstall -? | --help
  • 显示版本号信息

    1. gs_preinstall -V | --version

参数说明

  • -U

    运行openGauss的操作系统用户名。

    取值范围:字符串,要符合标识符的命名规范。

    gs_preinstall - 图1 说明: 配置-U参数值时,字符串中不能包含“|”、“;”、“&”、“$”、“<”、“>”、“`”、“\\”、“’”、“\”、“{”、“}”、“(”,“)”、“[”,“]”、“~”、“*”、“?”特殊字符。

  • -G

    运行openGauss的操作系统用户的群组名。

    取值范围:字符串,要符合标识符的命名规范。

  • -X

    openGauss配置文件路径。

    取值范围:xml文件的存储路径。

  • -L

    指定该参数则仅给当前节点准备好openGauss安装环境。适用于不允许使用root互信的场景和设置安全加固参数PermitRootLogin为no的场景。需要满足如下前提条件:

    1. 安装包和openGauss配置文件已提前上传到所有主机;
    2. openGauss安装用户已提前创建好并建立好互信关系;
    3. 用户需要自己保证各台主机上所执行命令的一致性;
    4. 手动将所有节点的主机名和ip映射关系写入各个主机的/etc/hosts,并在每个映射关系后边加入注释内容:#Gauss OM IP Hosts Mapping。
  • —skip-os-set

    是否设置操作系统参数。默认设置系统参数。如果指定该参数则不设置。

  • —env-var=”ENVVAR”

    配置普通用户环境变量。可以指定多个。

    取值范围:字符串。

    gs_preinstall - 图2 说明: 本参数不能指定为openGauss默认创建的环境变量。否则,openGauss的环境变量将被覆盖。openGauss默认创建的环境变量见表1

  • —sep-env-file=MPPRCFILE

    保存环境变量的文件。如果指定该参数,表示将使用环境变量分离的版本。

    gs_preinstall - 图3 说明: 不能指定环境变量文件为openGauss相关目录或者和这些目录同名,不能和openGauss用户的目录相同。

  • —skip-hostname-set

    是否将xml配置文件中主机名与IP的映射关系写入“/etc/hosts”文件中。默认写入,如果指定该参数则不写入。

  • -l

    指定日志文件名及路径。在内部会自动给日志名添加一个时间戳。

    默认值:/var/log/gaussdb/用户名/om/gs_preinstall.log

    当不明确指定-l,但在XML文件中配置了gaussdbLogPath时,默认值为gaussdbLogPath的值、用户名和om/gs_preinstall-YYYY-MM-DD_hhmmss.log的组合。

  • —non-interactive

    指定前置执行模式。

    • 当不指定该参数时,则为安全交互模式,在此模式下用户需要人机交互输入密码。
    • 当指定该参数时,为非交互模式,不需要进行人机交互。
  • -?, —help

    显示帮助信息。

  • -V, —version

    显示版本号信息。

    表 1 openGauss默认创建的环境变量

    环境变量名称

    说明

    MPPDB_ENV_SEPARATE_PATH

    openGauss环境变量分离文件路径

    GPHOME

    openGauss工具目录

    PATH

    openGauss工具脚本目录

    LD_LIBRARY_PATH

    openGauss引用第三方动态库路径

    PYTHONPATH

    python软件路径

    GAUSS_WARNING_TYPE

    告警类型

    GAUSSHOME

    openGauss安装路径

    GAUSS_VERSION

    openGauss版本号

    PGHOST

    openGauss用户的临时目录路径

    GS_CLUSTER_NAME

    openGauss名称

    GAUSSLOG

    openGauss日志路径

    GAUSS_ENV

    openGauss环境变量标识

手动设置服务端SYSLOG配置

设置“/etc/syslog-ng/syslog-ng.conf”文件,在文件中添加如下内容:

  1. template t_gaussdb {template("$DATE $SOURCEIP $MSGONLY\n");template_escape(no);};
  2. source s_gaussdb{ udp(); };
  3. filter f_gaussdb { level(err, crit) and match('GaussDB'); };
  4. destination d_gaussdb { file("/var/log/syslog_MPPDB", template(t_gaussdb)); };
  5. log { source(s_gaussdb); filter(f_gaussdb); destination(d_gaussdb); };

设置“/etc/sysconfig/syslog”文件,在文件中添加如下内容:

  1. SYSLOGD_OPTIONS="-r -m 0"
  2. KLOGD_OPTIONS="-x"

gs_preinstall - 图4 说明: 该配置需要在openGauss每台机器上都要修改。

示例

使用非交互方式进行openGauss环境准备:

  1. ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml --non-interactive
  2. Parsing the configuration file.
  3. Successfully parsed the configuration file.
  4. Installing the tools on the local node.
  5. Successfully installed the tools on the local node.
  6. Distributing package.
  7. Successfully distributed package.
  8. Installing the tools in the cluster.
  9. Successfully installed the tools in the cluster.
  10. Checking hostname mapping.
  11. Successfully checked hostname mapping.
  12. Checking OS version.
  13. Successfully checked OS version.
  14. Creating cluster's path.
  15. Successfully created cluster's path.
  16. Set and check OS parameter.
  17. Setting OS parameters.
  18. Successfully set OS parameters.
  19. Warning: Installation environment contains some warning messages.
  20. Please get more details by "/package_r8/sudo/gs_checkos -i A -h host179174,host179175,host179176".
  21. Set and check OS parameter completed.
  22. Preparing CRON service.
  23. Successfully prepared CRON service.
  24. Preparing SSH service.
  25. Successfully prepared SSH service.
  26. Setting user environmental variables.
  27. Successfully set user environmental variables.
  28. Configuring alarms on the cluster nodes.
  29. Successfully configured alarms on the cluster nodes.
  30. Setting the dynamic link library.
  31. Successfully set the dynamic link library.
  32. Setting finish flag.
  33. Successfully set finish flag.
  34. Preinstallation succeeded.

使用交互模式进行openGauss环境准备:

  1. ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml
  2. Parsing the configuration file.
  3. Successfully parsed the configuration file.
  4. Installing the tools on the local node.
  5. Successfully installed the tools on the local node.
  6. Are you sure you want to create trust for root (yes/no)? yes
  7. Please enter password for root.
  8. Password:
  9. Creating SSH trust for the root permission user.
  10. Please enter password for current user[root].
  11. Password:
  12. Checking network information.
  13. All nodes in the network are Normal.
  14. Successfully checked network information.
  15. Creating SSH trust.
  16. Creating the local key file.
  17. Successfully created the local key files.
  18. Appending local ID to authorized_keys.
  19. Successfully appended local ID to authorized_keys.
  20. Updating the known_hosts file.
  21. Successfully updated the known_hosts file.
  22. Appending authorized_key on the remote node.
  23. Successfully appended authorized_key on all remote node.
  24. Checking common authentication file content.
  25. Successfully checked common authentication content.
  26. Distributing SSH trust file to all node.
  27. Successfully distributed SSH trust file to all node.
  28. Verifying SSH trust on all hosts.
  29. Successfully verified SSH trust on all hosts.
  30. Successfully created SSH trust.
  31. Successfully created SSH trust for the root permission user.
  32. Distributing package.
  33. Successfully distributed package.
  34. Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
  35. Please enter password for cluster user.
  36. Password:
  37. Please enter password for cluster user again.
  38. Password:
  39. Creating [omm] user on all nodes.
  40. Successfully created [omm] user on all nodes.
  41. Installing the tools in the cluster.
  42. Successfully installed the tools in the cluster.
  43. Checking hostname mapping.
  44. Successfully checked hostname mapping.
  45. Creating SSH trust for [omm] user.
  46. Please enter password for current user[omm].
  47. Password:
  48. Checking network information.
  49. All nodes in the network are Normal.
  50. Successfully checked network information.
  51. Creating SSH trust.
  52. Creating the local key file.
  53. Successfully created the local key files.
  54. Appending local ID to authorized_keys.
  55. Successfully appended local ID to authorized_keys.
  56. Updating the known_hosts file.
  57. Successfully updated the known_hosts file.
  58. Appending authorized_key on the remote node.
  59. Successfully appended authorized_key on all remote node.
  60. Checking common authentication file content.
  61. Successfully checked common authentication content.
  62. Distributing SSH trust file to all node.
  63. Successfully distributed SSH trust file to all node.
  64. Verifying SSH trust on all hosts.
  65. Successfully verified SSH trust on all hosts.
  66. Successfully created SSH trust.
  67. Successfully created SSH trust for [omm] user.
  68. Checking OS version.
  69. Successfully checked OS version.
  70. Creating cluster's path.
  71. Successfully created cluster's path.
  72. Set and check OS parameter.
  73. Setting OS parameters.
  74. Successfully set OS parameters.
  75. Warning: Installation environment contains some warning messages.
  76. Please get more details by "/package_r8/sudo/gs_checkos -i A -h host179174,host179175,host179176".
  77. Set and check OS parameter completed.
  78. Preparing CRON service.
  79. Successfully prepared CRON service.
  80. Preparing SSH service.
  81. Successfully prepared SSH service.
  82. Setting user environmental variables.
  83. Successfully set user environmental variables.
  84. Configuring alarms on the cluster nodes.
  85. Successfully configured alarms on the cluster nodes.
  86. Setting the dynamic link library.
  87. Successfully set the dynamic link library.
  88. Setting finish flag.
  89. Successfully set finish flag.
  90. Preinstallation succeeded.

相关命令

gs_installgs_postuninstall