Perform database operations

If you encounter issues with the Tanium deployment, Tanium Support might direct you to perform database operations.

Note: Database operations are available on the Tanium Server and Tanium Module Server. In an All-In-One deployment, database operations apply only to the Tanium Server.

View the Postgres log file

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3-1 (Tanium Support > Database Operations > Select File).
  3. Enter the line number for the postgres.log file, and use the menu to view the log or copy it to the /outgoing folder.
    CODE
    ------------------------------------------------------
    >>> Tanium Support -> Postgres -> Logs -> postgres.log <<< 
    
            Size: 80   Last Update: 2020-10-25 06:11:39
    
              V: View the file
              F: Follow log file growth
              E: Export to outgoing (sftp)
    
              R: Return to previous menu  RR: Return to top
    
     ------------------------------------------------------

View Postgres configuration files

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3-2 (Tanium Support > Database Operations > Select File).
  3. Use the menu to review or modify the configuration.

View Postgres control data

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3 (Tanium Support > Database Operations).
  3. Enter 3 to view Postgres control data.
    CODE
    pg_control version number:            942
    Catalog version number:               201510051
    Database system identifier:           6813452830717815614
    Database cluster state:               in production
    pg_control last modified:             Thu 09 Apr 2020 02:31:02 PM UTC
    Latest checkpoint location:           0/2384610
    Prior checkpoint location:            0/2381B90
    Latest checkpoint's REDO location:    0/23845D8
    Latest checkpoint's REDO WAL file:    000000010000000000000002
    Latest checkpoint's TimeLineID:       1
    Latest checkpoint's PrevTimeLineID:   1
    Latest checkpoint's full_page_writes: on
    Latest checkpoint's NextXID:          0/3498
    Latest checkpoint's NextOID:          27854
    Latest checkpoint's NextMultiXactId:  1
    Latest checkpoint's NextMultiOffset:  0
    Latest checkpoint's oldestXID:        1825
    Latest checkpoint's oldestXID's DB:   1
    Latest checkpoint's oldestActiveXID:  3498
    Latest checkpoint's oldestMultiXid:   1
    Latest checkpoint's oldestMulti's DB: 1
    Latest checkpoint's oldestCommitTsXid:0
    Latest checkpoint's newestCommitTsXid:0
    Time of latest checkpoint:            Thu 09 Apr 2020 02:31:02 PM UTC
    Fake LSN counter for unlogged rels:   0/1
    Minimum recovery ending location:     0/0
    Min recovery ending loc's timeline:   0
    Backup start location:                0/0
    Backup end location:                  0/0
    End-of-backup record required:        no
    wal_level setting:                    hot_standby
    wal_log_hints setting:                off
    max_connections setting:              256
    max_worker_processes setting:         8
    max_prepared_xacts setting:           0
    max_locks_per_xact setting:           64
    track_commit_timestamp setting:       off
    Maximum data alignment:               8
    Database block size:                  8192
    Blocks per segment of large relation: 131072
    WAL block size:                       8192
    Bytes per WAL segment:                16777216
    Maximum length of identifiers:        64
    Maximum columns in an index:          32
    Maximum size of a TOAST chunk:        1996
    Size of a large-object chunk:         2048
    Date/time type storage:               64-bit integers
    Float4 argument passing:              by value
    Float8 argument passing:              by value
    Data page checksum version:           0
    
     Press enter to continue

Enable full Postgres audit log

Postgres logs are very rarely useful in troubleshooting Appliance or platform issues. Audit logging is disabled by default. When enabled, Postgres logging can consume inordinate disk space. For best results, enable audit logging only when debugging.

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3 (Tanium Support > Database Operations).
  3. Enter 4 and follow the prompts to enable audit logging.
    CODE
    ------------------------------------------------------
     
    >>> Tanium Support menu -> Enable Postgres Full Audit Logging <<< 
    
    
     Do you want to Enable Full Postgres audit logging ? [Yes|No]: yes
    
     Enabling Postgres audit logging
     Reloading Postgres configuration
    
     Press enter to continue

Manage the database memory plan

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3-D (Tanium Support > Database Operations > DB Tuning).
  3. Review the available memory plans and enter the letter for the plan you want to select.
    Tip: For more information about Appliance sizing and specifications, see Reference: Tanium Appliance sizing and specifications.
  4. Enter A to apply the new memory plan.
Note: You must apply the same database memory plan for both Tanium Servers in a cluster, or for both an active and standby Module Server. A Tanium Server and a Module Server are not required to have the same memory plan.

Run the Postgres top command

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3 (Tanium Support > Database Operations).
  3. Enter M to view results of the top command.
    CODE
    last pid: 29609;  load avg:  0.08,  0.03,  0.05;       up 0+03:02:11                  14:45:53
    3 processes: 1 running, 2 sleeping
    CPU states: 34.5% user,  0.0% nice, 15.0% system, 50.5% idle,  0.0% iowait
    Memory: 924M used, 67M free, 46M buffers, 560M cached
    DB activity:  17 tps,  0 rollbs/s,   0 buffer r/s, 100 hit%,     38 row r/s,    0 row w/s
    DB I/O:     0 reads/s,     0 KB/s,    27 writes/s,   210 KB/s
    DB disk: 348.7 GB total, 328.3 GB free (5% used)
    Swap: 10M used, 4086M free, 924K cached
    
      PID USERNAME PRI NICE  SIZE   RES STATE   TIME   WCPU    CPU COMMAND
    23453 postgres  20    0 4426M   50M sleep   0:08  0.20%  0.60% postgres: postgres tanium 10.10.10.55(60908) idle
    29610 postgres  20    0 4421M 6496K run     0:00  0.00%  0.00% postgres: postgres postgres [local] idle
  4. Enter Q to return to the Database Operations menu.

Query the tanium database

The Manage Queries menu includes predefined queries that can be useful during troubleshooting.

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3-Q-S (Tanium Support > Database Operations > Manage Queries > Select Query).
  3. Use the menu to select a predefined query and return to the Manage Queries menu.
  4. Enter X to run the query and save the results to the /outgoing folder.
    CODE
    >>> Tanium Support menu -> Database Operations -> Execute Query <<< 
    
    Running Query DBsizes 
    Query results saved to outgoing in DBsizes.results 
    
    Press enter to continue
  5. Enter Q to view query results.
    CODE
    datname  |  size   
    -----------+---------
     template1 | 7145 kB
     template0 | 7145 kB
     postgres  | 7264 kB
     tanium    | 16 MB
    (4 rows)
    
    /tmp/tmp.G2h8V4Iab2 (END)
  6. Enter Q to return to the Manage Queries menu.

View database replication status and history

View the database replication status and history to help troubleshoot replication issues between the primary and secondary Tanium Server or between the active and inactive Module Server. The replication status is captured every 15 minutes at the same time as the automatic health check, and, additionally, when you view the current status. The status is recorded as a new entry in the history if the server role changes or if there is an important change in the replication status; otherwise the status overwrites the previous entry in the history. The Postgres Replication History screen displays the 10 most recent history entries.

  1. Sign in to the TanOS console as a user with the tanadmin role.
  2. Enter 3-3 (Tanium Support > Database Operations).
  3. Enter S to view the Postgres replication history.
  4. ------------------------------------------------------ >>> Postgres Replication History <<<  C: Show Current Status Timestamp Status Role 1: 2024-04-23 20:00:33 Fail Secondary 2: 2024-04-16 07:45:32 Fail Secondary 3: 2024-04-16 07:30:13 Pass Secondary 4: 2024-04-15 22:00:13 Pass Secondary 5: 2024-04-15 21:45:12 Fail Secondary 6: 2024-04-15 20:15:13 Pass Secondary R: Return to previous menu RR: Return to top ------------------------------------------------------
  5. Enter C to view the current replication status, or enter the number of the historical status to view.
  6. Viewing previously captured replication status Status Timestamp: 2024-04-16 07:30:13 Service Type: TS >>> Local Database Replication Status <<<  Cluster Address: 10.10.110.236 Postgres TS service: Pass (Running) Cluster Role: Secondary Last WAL LSN: 0/51806B8 Last Xact Replay: 2024-04-16 07:30:06.291924+00 Streaming Status: Pass (streaming) Written LSN: 0/51806B8 Last Msg Send: 2024-04-16 07:30:06.292087+00 Last Msg Receipt: 2024-04-16 07:30:06.292141+00 Replication Lag: 00:00:07.872822 >>> Remote Database Replication Status <<<  Cluster Address: 10.10.110.205 Network Access: Pass (Responding) Remote DB Net Latency: 1ms Cluster Role: Primary Replication Slot: Pass (Active) Slot Restart LSN: 0/51806B8 Current Log Location: 0/51806B8 Streaming Status: Pass (streaming) In Recovery Mode: Pass (No) Sync State: async Backend Start: 2024-04-15 21:59:44.180481+00 Sent Log Location: 0/51806B8 Write Log Location: 0/51806B8 Replay Log Location: 0/51806B8 Flush Log Location: 0/51806B8 Overall Status: Pass Press enter to continue
Tip: The Tanium Support Gatherer report includes the latest 50 replication history entries, in the postgres-repl-ts.json log file for each Tanium Server, or the postgres-repl-tms.json file for each Module Server. For more information, see Run Tanium Support Gatherer.

Initiate database server failover

  1. Sign in to the TanOS console of the Appliance with the secondary database as a user with the tanadmin role.
  2. Enter 2-B-F (Tanium Operations > Cluster Configuration > Database Server Failover).
  3. Follow the prompts to initiate the failover.

Collect database replication statistics (Module Server only)

When troubleshooting a replication issue on a Module Server, you can temporarily enable replication statistics that indicate the amount of data recorded in the database on the primary Module Server that has not yet been replicated to the secondary Module Server. When you enable this collection, TanOS records statistics once per minute, in the replstats_yyyy-mm-dd.json file in the outgoing folder. TanOS creates one log file for each day while collection is enabled.

Important: Keep database replication statistics disabled when you are not troubleshooting a replication issue. The TMS Database Stats Collection health check indicates that collection of database replication statistics is enabled.
  1. Enter 3-3-C (Tanium Support > Database Operations > Collect Replication Stats).
  2. Follow the prompts to enable or disable collection of database replication statistics.