Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Connect to the Security Server using SSH.

  2. Switch to the postgres user using sudo.

    Code Block
    languagebash
    $ sudo su - postgres
  3. List existing databases.

    Code Block
    languagebash
    $ psql -l
                                          List of databases
        Name    |      Owner      | Encoding |   Collate   |    Ctype    |   Access privileges   
    ------------+-----------------+----------+-------------+-------------+-----------------------
     messagelog | messagelog      | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     op-monitor | opmonitor_admin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     postgres   | postgres        | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     serverconf | serverconf      | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0  | postgres        | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
                |                 |          |             |             | postgres=CTc/postgres
     template1  | postgres        | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
                |                 |          |             |             | postgres=CTc/postgres
  4. Log in to the messagelog database. You can find the database password from the /etc/xroad/db.properties configuration file.

    Code Block
    languagebash
    $ psql "host=127.0.0.1 port=5432 dbname=messagelog user=messagelog password=<PASSWORD>"
    psql (12.16 (Ubuntu 12.16-0ubuntu0.20.04.1))
    SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
    Type "help" for help.
  5. List tables in the messagelog database.

    Code Block
    languagebash
    messagelog=# \dt
                      List of relations
     Schema |         Name          | Type  |   Owner    
    --------+-----------------------+-------+------------
     public | databasechangelog     | table | messagelog
     public | databasechangeloglock | table | messagelog
     public | last_archive_digest   | table | messagelog
     public | logrecord             | table | messagelog
    (4 rows)
  6. Show the structure of the logrecord table.

    Code Block
    languagebash
    messagelog=#> \d logrecord
    
    			
                              TableTable "publicmessagelog.logrecord"
           Column       |          Type          | Collation | Nullable | ModifiersDefault 
    --------------------+------------------------+-----------+------
     id       ----+---------
     id                 | bigint                 |           | not null | 
     discriminator      | character varying(255) | not null  time       | not null | 
     time  | bigint            | bigint    |   archived           | boolean          |      |   queryid | 
     archived        | character varying(255) | boolean   message             |  text         |          | 
     signaturequeryid            | character varying(255) | text          |          | 
     hashchainmessage            | text                   |   hashchainresult    | text   |          | 
     signature   |   signaturehash      | text                   |       timestamprecord    | bigint         | 
     hashchain      |   timestamphashchain | text                   |   response        |   | boolean      | 
     hashchainresult    | text      |   timestamp          | text          |          | 
     memberclasssignaturehash      | text | character varying(255) |   membercode         | character varying(255) |    subsystemcode       | character  varying(255) |  Indexes:    | "logrecordpk"
    PRIMARY KEY,timestamprecord btree (id)  | bigint  "LOGRECORD_TIMESTAMPRECORD_fkey" btree (timestamprecord)               |           |          | 
     timestamphashchain | text                   |           |          | 
     response           | boolean                |           |          | 
     timestamp          | text                   |           |          | 
     memberclass        | character varying(255) |           |          | 
     membercode         | character varying(255) |           |          | 
     subsystemcode      | character varying(255) |           |          | 
     attachment         | oid                    |           |          | 
     xrequestid         | character varying(255) |           |          | 
     keyid              | character varying(255) |           |          | 
     ciphermessage      | bytea                  |           |          | 
    Indexes:
        "logrecordpk" PRIMARY KEY, btree (id)
        "LOGRECORD_TIMESTAMPRECORD_fkey" btree (timestamprecord)
        "ix_logrecord_grouping" btree (memberclass, membercode, subsystemcode, id) WHERE discriminator::text = 'm'::text AND archived = false AND timestamprecord IS NOT NULL
        "ix_not_archived_logrecord" btree (id) WHERE discriminator::text = 't'::text AND archived = false
        "ix_not_timestamped_logrecord" btree (id, discriminator, signaturehash) WHERE discriminator::text = 'm'::text AND signaturehashtimestamprecord IS NOT NULL
    Foreign-key constraints:
        "fk_qo6ack8sad6fqib90xghdaylh" FOREIGN KEY (timestamprecord) REFERENCES logrecord(id)
    Referenced by:
        TABLE "logrecord" CONSTRAINT "fk_qo6ack8sad6fqib90xghdaylh" FOREIGN KEY (timestamprecord) REFERENCES logrecord(id)
    Triggers:
        t_logrecord_attachment BEFORE DELETE ON logrecord FOR EACH ROW WHEN (old.attachment IS NOT NULL) EXECUTE FUNCTION del_logrecord_attachment()
  7. Query the number of rows in the logrecord table.

    Code Block
    languagebash
    messagelog=# select count(*) from logrecord;
     count 
    -------
       250
    (1 row)
  8. Query the last ten rows in the logrecord table.

    Code Block
    languagebash
    messagelog=# select id, time, archived, queryid, memberclass, membercode from logrecord order by id desc limit 10;
     id  |     time      | archived | queryid | memberclass | membercode 
    -----+---------------+----------+---------+-------------+------------
     322 | 1530002774812 | f        | ID10	  | NGO         | 80419486
     321 | 1529998886128 | f        | ID9 	  | NGO         | 80419486
     320 | 1529998886076 | f        | ID8	  | NGO         | 80419486
     319 | 1529998455256 | f        | ID7	  | NGO         | 80419486
     318 | 1529998442346 | f        | ID6	  | NGO         | 80419486
     317 | 1529998442154 | f        | ID5	  | NGO         | 80419486
     316 | 1529995251774 | f        | ID4	  | NGO         | 80419486
     315 | 1529995251701 | f        | ID3	  | NGO         | 80419486
     314 | 1529994233325 | f        | ID2	  | NGO         | 80419486
     313 | 1529994233267 | f        | ID1	  | NGO         | 80419486
    (10 rows)
  9. Query the timestamps of a request / response message pair.

    Code Block
    languagebash
    messagelog=# select id, TO_TIMESTAMP(time::double precision / 1000), response, queryid from logrecord where queryid='ID10';
     id  |        to_timestamp        | response | queryid 
    -----+----------------------------+----------+---------
     313 | 2018-06-26 06:23:53.267+00 | f        | ID1
     314 | 2018-06-26 06:23:53.325+00 | t        | ID1
  10. Exit from Postgres.

    Code Block
    languagebash
    messagelog=# \q
    $

...