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 under the *.tar.gz directory as a /tmp package. mxpacklogs automatically selects the disk with the largest available free space that the user has read and write permissions for storing 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 detailed 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 up to the mxdata_xxxx directory level; mxpacklogs will auto-complete the rest. Example: mxpacklogs --base-data-dirs /data/mxdata_20230324145536
--hosts --host: Collects 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 message
--host Host where supervisor/mxgate service is installed. Default: "127.0.0.1"
--mode Output format: api or cli. Default: "api"
-W / --password Database user password
--path MatrixDB installation path on 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 Show 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 host, ensure:
    • Both the database server and the execution host have installed a new version of YMatrix (4.8.0 or later).
    • Connect to the Master by specifying appropriate parameters.

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

  1. Run mxpacklogs 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>@<hostname> ~]$ 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 their 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 logs, see Log.