mxpacklogs

This document describes the log collection and packaging tool mxpacklogs.

1 Description

  • Features

    • The mxpacklogs tool supports one-click collection and packaging of logs from all nodes in a distributed cluster.
    • It collects log data from the current moment back to the previous three days.
  • Limitations

    • Logs from all specified hosts are aggregated on the host where the mxpacklogs command is executed. These logs are temporarily stored as a *.tar.gz package under /tmp. The tool automatically selects the disk with the largest available space that the user can read and write to store these packages.
    • In extreme cases where all cluster nodes are down, use the --hosts and --base-data-dirs options to retrieve log information.

2 Command-Line Options

The following table lists the supported command-line options:

Option Description
--base-data-dirs Optional. By default, the tool reads data directories from database metadata. Only specify this when the database is inaccessible. Provide the path up to the mxdata_xxxx directory; mxpacklogs will complete the rest. Example: mxpacklogs --base-data-dirs /data/mxdata_20230324145536
--hosts --host indicates collecting logs from all hosts in the cluster by default. Use -- hosts to collect logs only from specific Segment hosts, reducing disk and time overhead. Examples: mxpacklogs --hosts sdw1,sdw2 or mxpacklogs --hosts sdw1 --hosts sdw2
-h / --dbhost Database server host. Default: "127.0.0.1"
-p / --dbport Database server port. Default: "5432"
--debug Enable debug-level log output
--help Print help information
--host Host where supervisor/mxgate service is running. Default: "127.0.0.1"
--mode Output format: api or cli. Default: "api"
-W / --password Database user password
--path MatrixDB installation path on the supervisor host. Default: "/opt/ymatrix/matrixdb5"
--port Supervisor server port. Default: "4617"
-U / --username Database username. Default: "mxadmin"
--validate Validation mode – dry run
--verbose Enable verbose log output
-v / --version Display tool version

3 Examples

mxpacklogs can be executed on either the Master node or a non-Master node. Details:

  • When running on the Master, it is recommended to use the mxadmin user. If another user is used, configure pg_hba trust accordingly.
  • When running remotely on a non-Master node, the following conditions must be met:
    • Both the database server and the execution server must have YMatrix version 4.8.0 or later installed.
    • Connect to the Master by specifying the appropriate parameters.

Based on the above, we recommend the following three usage methods. In the examples below, mdw is the Master and sdw is a non-Master host:

  1. Run the mxpacklogs command directly. This assumes the current host is the Master and connects to the database to collect logs from all Segments.

    [mxadmin@mdw ~]$ mxpacklogs
    [INFO]:-Preparing temp directory...
    [INFO]:-Starting transport server...
    [INFO]:-Gathering logs from 4 hosts...
    [INFO]:-Creating the tarball...
    [INFO]:-All logs packed to: /tmp/gather_logs_2143246856.tar.gz
    ``
  2. Run the following command on any host, specifying connection details to the Master, to collect logs from all Segments (same result as example 1).

    [<user>@<host> ~]$ mxpacklogs --dbhost 172.31.33.128 --dbport 5432 --username mxadmin --password 123
    [INFO]:-Preparing temp directory...
    [INFO]:-Starting transport server...
    [INFO]:-Gathering logs from 4 hosts...
    [INFO]:-Creating the tarball...
    [INFO]:-All logs packed to: /tmp/gather_logs_340918649.tar.gz
    ``

Note!
Examples 1 and 2 both require connecting to the Master. Therefore, the cluster's Master must be in a healthy state.

  1. Run the following command on any host to collect logs only from specified hosts (required) and optionally specified data directories.
    [<user>@sdw ~]$ mxpacklogs --hosts sdw1,sdw2 --base-data-dirs /mxdata_20221229075012
    ``

    This command collects logs from sdw1 and sdw2, assuming both hosts have the same base-data-dirs set to /mxdata_20221229075012.

    [<user>@sdw ~]$ mxpacklogs --hosts sdw1,sdw2 --base-data-dirs /mxdata_20221229075012,/data1/mxdata_20221229075012
    ``

    This command collects logs from sdw1 and sdw2, but their base-data-dirs differ: one is /mxdata_20221229075012, the other is /data1/mxdata_20221229075012.

Note!
For more information about log content, see Logs.