准备安装用户及环境

创建完openGauss配置文件后,在执行安装前,为了后续能以最小权限进行安装及openGauss管理操作,保证系统安全性,需要运行安装前置脚本gs_preinstall准备好安装用户及环境。

安装前置脚本gs_preinstall可以协助用户自动完成如下的安装环境准备工作:

  • 自动设置Linux内核参数以达到提高服务器负载能力的目的。这些参数直接影响数据库系统的运行状态,请仅在确认必要时调整。openGauss所设置的Linux内核参数取值请参见配置操作系统参数
  • 自动将openGauss配置文件、安装包拷贝到openGauss主机的相同目录下。
  • openGauss安装用户、用户组不存在时,自动创建安装用户以及用户组。
  • 读取openGauss配置文件中的目录信息并创建,将目录权限授予安装用户。

前提条件

注意事项

  • 用户需要检查上层目录权限,保证安装用户对安装包和配置文件目录读写执行的权限。
  • xml文件中各主机的名称与IP映射配置正确。
  • 只能使用root用户执行gs_preinstall命令。

操作步骤

  1. 以root用户登录待安装openGauss的任意主机,并按规划创建存放安装包的目录。

    1. mkdir -p /opt/software/openGauss
    2. chmod 755 -R /opt/software

    准备安装用户及环境 - 图1 说明:
    - 不建议把安装包的存放目录规划到openGauss用户的家目录或其子目录下,可能导致权限问题。
    - openGauss用户须具有/opt/software/openGauss目录的读写权限。

  2. 以release包为例,将安装包“openGauss_x.x.x_PACKAGES_RELEASE.tar.gz”和配置文件“clusterconfig.xml”都上传至上一步所创建的目录中。

  3. 在安装包所在的目录下,解压安装包。

    1. cd /opt/software/openGauss
    2. tar -zxvf openGauss_x.x.x_PACKAGES_RELEASE.tar.gz

    解压后的安装包说明见表1

    表 1 安装包说明

    包名

    说明

    openGauss-x.x.x-openEULER-64bit-ClientTools.tar.gz

    用于Linux的客户端工具安装包。含gsql、dump restore tool、ODBC驱动、JDBC驱动、Libpq库。

    openGauss-x.x.x-openEULER-64bit-Jdbc.tar.gz

    用于Linux的JDBC驱动安装包。

    openGauss-x.x.x-openEULER-64bit-Libpq.tar.gz

    用于Linux的libpq库。

    openGauss-x.x.x-openEULER-64bit-Odbc.tar.gz

    用于Linux的ODBC驱动安装包。

    openGauss-x.x.x-openEULER-64bit-symbol.tar.gz

    用于调试和定位数据库问题的支持文件。

    openGauss-x.x.x-openEULER-64bit.tar.gz

    数据库管理系统安装包。即本手册使用的安装包。

    openGauss-x.x.x-Sslcert.tar.gz

    用于客户端服务器认证的证书。

    openGauss-x.x.x-Inspection.tar.gz

    用于检查数据库健康状况的巡检工具。

  4. 对openGauss-x.x.x-openEULER-64bit.tar.gz进行解压。

    1. tar -zxvf openGauss-x.x.x-openEULER-64bit.tar.gz

    安装包解压后,会在/opt/software/openGauss路径下自动生成script子目录,并且在script目录下生成gs_preinstall等各种OM工具脚本。

    准备安装用户及环境 - 图2 说明:
    - 在执行前置脚本gs_preinstall时,需要规划好openGauss配置文件路径、安装包存放路径、程序安装目录、实例数据目录,后续普通用户使用过程中不能再更改这些路径。
    - 运行前置脚本gs_preinstall准备安装环境时,脚本内部会自动将openGauss配置文件、解压后的安装包同步拷贝到其余服务器的相同目录下。
    - 在执行前置或者互信前,请检查/etc/profile文件中是否包含错误输出信息,如果存在错误输出,需手动处理。

  5. 进入到工具脚本存放目录下。

    1. cd /opt/software/openGauss/script
  6. 如果是openEuler的操作系统,执行如下命令打开performance.sh文件,用#注释sysctl -w vm.min_free_kbytes=112640 &> /dev/null,键入“ESC”键进入指令模式,执行:wq保存并退出修改。

    1. vi /etc/profile.d/performance.sh
  7. 为确保openssl版本正确,执行预安装前请加载安装包中lib库。执行命令如下,其中_{packagePath}_为用户安装包放置的路径,本示例中为/opt/software/openGauss。

    1. export LD_LIBRARY_PATH={packagePath}/script/gspylib/clib:$LD_LIBRARY_PATH
  8. 为确保成功安装,检查 hostname 与 /etc/hostname 是否一致。预安装过程中,会对hostname进行检查。

  9. 使用gs_preinstall准备好安装环境。若为共用环境需加入–sep-env-file=ENVFILE参数分离环境变量避免与其他用户相互影响,ENVFILE为用户自行指定的环境变量分离文件的路径。

    • 采用交互模式执行前置,并在执行过程中自动创建root用户互信和openGauss用户互信:

      1. ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml

      omm为数据库管理员(也是运行openGauss的操作系统用户),dbgrp为运行openGauss的操作系统用户的群组名称,/opt/software/openGauss/clusterconfig.xml为openGauss配置文件路径。在执行过程中,用户根据提示选择是否创建互信,并输入root用户或openGauss用户的密码。

    • 不允许创建root用户互信时,创建omm用户,在各主机上执行本地模式前置,然后用户手动创建openGauss用户互信:如果预安装指定-L参数,预安装前需手动将所有节点的主机名和ip映射关系,写入各个主机的/etc/hosts,并在每个映射关系后边加入注释内容:#Gauss OM IP Hosts Mapping。

      1. 执行下面命令准备安装环境。

        1. cd /opt/software/openGauss/script
        2. ./gs_preinstall -U omm -G dbgrp -L -X /opt/software/openGauss/clusterconfig.xml

        准备安装用户及环境 - 图3 说明:
        此操作需要在每台主机上执行该命令。

    • 采用非交互模式执行前置:

      1. 参考手工建立互信章节手工建立root用户互信和openGauss用户互信。
      2. 执行下面命令准备安装环境。

        1. cd /opt/software/openGauss/script
        2. ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml --non-interactive

        准备安装用户及环境 - 图4 说明:
        - 此模式要求用户确保在执行前,已经建立了各节点root用户互信和openGauss用户互信。
        - root用户互信可能会存在安全隐患,因此建议用户在执行完安装后,立即删除各主机上root用户的互信。

示例

执行前置脚本:

  1. plat1:/opt/software/openGauss/script # ./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. Checking network information.
  11. All nodes in the network are Normal.
  12. Successfully checked network information.
  13. Creating SSH trust.
  14. Creating the local key file.
  15. Successfully created the local key files.
  16. Appending local ID to authorized_keys.
  17. Successfully appended local ID to authorized_keys.
  18. Updating the known_hosts file.
  19. Successfully updated the known_hosts file.
  20. Appending authorized_key on the remote node.
  21. Successfully appended authorized_key on all remote node.
  22. Checking common authentication file content.
  23. Successfully checked common authentication content.
  24. Distributing SSH trust file to all node.
  25. Successfully distributed SSH trust file to all node.
  26. Verifying SSH trust on all hosts.
  27. Successfully verified SSH trust on all hosts.
  28. Successfully created SSH trust.
  29. Successfully created SSH trust for the root permission user.
  30. Setting pssh path
  31. Successfully set core path.
  32. Distributing package.
  33. Begin to distribute package to tool path.
  34. Successfully distribute package to tool path.
  35. Begin to distribute package to package path.
  36. Successfully distribute package to package path.
  37. Successfully distributed package.
  38. Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
  39. Please enter password for cluster user.
  40. Password:
  41. Please enter password for cluster user again.
  42. Password:
  43. Successfully created [omm] user on all nodes.
  44. Preparing SSH service.
  45. Successfully prepared SSH service.
  46. Installing the tools in the cluster.
  47. Successfully installed the tools in the cluster.
  48. Checking hostname mapping.
  49. Successfully checked hostname mapping.
  50. Creating SSH trust for [omm] user.
  51. Checking network information.
  52. All nodes in the network are Normal.
  53. Successfully checked network information.
  54. Creating SSH trust.
  55. Creating the local key file.
  56. Successfully created the local key files.
  57. Appending local ID to authorized_keys.
  58. Successfully appended local ID to authorized_keys.
  59. Updating the known_hosts file.
  60. Successfully updated the known_hosts file.
  61. Appending authorized_key on the remote node.
  62. Successfully appended authorized_key on all remote node.
  63. Checking common authentication file content.
  64. Successfully checked common authentication content.
  65. Distributing SSH trust file to all node.
  66. Successfully distributed SSH trust file to all node.
  67. Verifying SSH trust on all hosts.
  68. Successfully verified SSH trust on all hosts.
  69. Successfully created SSH trust.
  70. Successfully created SSH trust for [omm] user.
  71. Checking OS software.
  72. Successfully check os software.
  73. Checking OS version.
  74. Successfully checked OS version.
  75. Creating cluster's path.
  76. Successfully created cluster's path.
  77. Setting SCTP service.
  78. Successfully set SCTP service.
  79. Set and check OS parameter.
  80. Setting OS parameters.
  81. Successfully set OS parameters.
  82. Preparing CRON service.
  83. Successfully prepared CRON service.
  84. Setting user environmental variables.
  85. Successfully set user environmental variables.
  86. Setting the dynamic link library.
  87. Successfully set the dynamic link library.
  88. Setting Core file
  89. Successfully set core path.
  90. Setting pssh path
  91. Successfully set pssh path.
  92. Set ARM Optimization.
  93. No need to set ARM Optimization.
  94. Fixing server package owner.
  95. Setting finish flag.
  96. Successfully set finish flag.
  97. Preinstallation succeeded.
  98. S

root密码不一致也不能修改为一致,执行前置脚本本地安装模式:

  1. plat1:/opt/software/openGauss/script # ./gs_preinstall -U omm -G dbgrp -L -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. Checking OS version.
  7. Successfully checked OS version.
  8. Creating cluster's path.
  9. Successfully created cluster's path.
  10. Setting SCTP service.
  11. Successfully set SCTP service.
  12. Set and check OS parameter.
  13. Setting OS parameters.
  14. Successfully set OS parameters.
  15. Warning: Installation environment contains some warning messages.
  16. Please get more details by "/home/package/r8c00/script/gs_checkos -i A -h SIA1000068990".
  17. Set and check OS parameter completed.
  18. Preparing CRON service.
  19. Successfully prepared CRON service.
  20. Preparing SSH service.
  21. Successfully prepared SSH service.
  22. Setting user environmental variables.
  23. Successfully set user environmental variables.
  24. Configuring alarms on the cluster nodes.
  25. Successfully configured alarms on the cluster nodes.
  26. Setting the dynamic link library.
  27. Successfully set the dynamic link library.
  28. Setting Cgroup.
  29. Successfully set Cgroup.
  30. Setting finish flag.
  31. Successfully set finish flag.
  32. Preinstallation succeeded.

以非交互模式执行前置:

  1. plat1:/opt/software/openGauss/script # ./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. Begin to distribute package to tool path.
  8. Successfully distribute package to tool path.
  9. Begin to distribute package to package path.
  10. Successfully distribute package to package path.
  11. Successfully distributed package.
  12. Installing the tools in the cluster.
  13. Successfully installed the tools in the cluster.
  14. Checking hostname mapping.
  15. Successfully checked hostname mapping.
  16. Checking OS version.
  17. Successfully checked OS version.
  18. Creating cluster's path.
  19. Successfully created cluster's path.
  20. Setting SCTP service.
  21. Successfully set SCTP service.
  22. Set and check OS parameter.
  23. Setting OS parameters.
  24. Successfully set OS parameters.
  25. Set and check OS parameter completed.
  26. Preparing CRON service.
  27. Successfully prepared CRON service.
  28. Preparing SSH service.
  29. Successfully prepared SSH service.
  30. Setting user environmental variables.
  31. Successfully set user environmental variables.
  32. Configuring alarms on the cluster nodes.
  33. Successfully configured alarms on the cluster nodes.
  34. Setting the dynamic link library.
  35. Successfully set the dynamic link library.
  36. Setting Cgroup.
  37. Successfully set Cgroup.
  38. Set ARM Optimization.
  39. Successfully set ARM Optimization.
  40. Setting finish flag.
  41. Successfully set finish flag.
  42. Preinstallation succeeded.

错误排查

如果准备安装环境失败请根据openGauss日志目录“$GAUSSLOG/om”下的“gs_preinstall-YYYY-MM-DD_HHMMSS.log”和“gs_local-YYYY-MM-DD_HHMMSS.log”中的日志信息排查错误。例如配置文件中“gaussdbLogPath”参数指定的路径为“/var/log/gaussdb”,则“$GAUSSLOG/om”路径为“/var/log/gaussdb/omm/om”,omm用户为运行openGauss的用户。

准备安装用户及环境 - 图5 须知:
准备安装用户及环境的过程中会使用root添加定时任务用于定时巡检和上报。