code.vegaprotocol.io/vega@v0.79.0/datanode/README.md (about) 1 # Data node 2 3 A service exposing read only APIs built on top of [Vega](https://github.com/vegaprotocol/vega) platform. 4 5 **Data node** provides the following core features: 6 7 - Consume all events from Vega core 8 - Aggregates received events and stores the aggregated data 9 - Serves stored data via [APIs](https://docs.vega.xyz/mainnet/api/overview) 10 - Allows advanced configuration [Configure a node](#configuration) 11 12 ## Links 13 14 - For **new developers**, see [Getting Started](../GETTING_STARTED.md). 15 - For **updates**, see the [Change log](../CHANGELOG.md) for major updates. 16 - Please [open an issue](https://github.com/vegaprotocol/vega/issues/new) if anything is missing or unclear in this documentation. 17 18 <details> 19 <summary><strong>Table of Contents</strong> (click to expand)</summary> 20 21 <!-- toc --> 22 23 - [Data node](#data-node) 24 - [Links](#links) 25 - [Installation and configuration](#installation-and-configuration) 26 - [Troubleshooting & debugging](#troubleshooting--debugging) 27 28 <!-- tocstop --> 29 30 </details> 31 32 ## Installation and configuration 33 34 To install see [Getting Started](https://docs.vega.xyz/mainnet/node-operators/setup-datanode). 35 36 ## Troubleshooting & debugging 37 38 The application has structured logging capability, the first port of call for a crash is probably the Vega and Tendermint logs which are available on the console if running locally or by journal plus syslog if running on test networks. Default location for log files: 39 40 * `/var/log/vega.log` 41 42 Each internal Go package has a logging level that can be set at runtime by configuration. Setting the logging `Level` to `-1` for a package will enable all debugging messages for the package which can be useful when trying to analyse a crash or issue. 43 44 ## Testing database migrations 45 46 To test database migrations you have added, you can use the goose CLI tool to run the migrations against a local database. 47 48 You can use docker to spin up a local postgres database to test against using the `postgres-docker.sh` under the project's `scripts` folder. 49 50 ```bash 51 ./scripts/postgres-docker.sh 52 ``` 53 54 This will create a local postgres database with the following credentials: 55 56 ```bash 57 user: vega 58 password: vega 59 dbname: vega 60 host: localhost 61 port: 5432 62 ``` 63 64 To test the migrations, you can use the following command to apply all the migrations: 65 66 ```bash 67 goose -dir migrations postgres "user=<your-user-name> password=<your-password> dbname=<your-db-name> host=<your-db-host> port=<your-db-port> sslmode=disable" up 68 ``` 69 70 To unwind all migrations, you can use the following command: 71 72 ```bash 73 goose -dir migrations postgres "user=<your-user-name> password=<your-password> dbname=<your-db-name> host=<your-db-host> port=<your-db-port> sslmode=disable" down-to 0 74 ``` 75 76 To migrate to a specific migration, you can use the following command: 77 78 ```bash 79 goose -dir migrations postgres "user=<your-user-name> password=<your-password> dbname=<your-db-name> host=<your-db-host> port=<your-db-port> sslmode=disable" up-to <migration-number> 80 ``` 81 82 Then you can rollback to a previous migration using the following command: 83 84 ```bash 85 goose -dir migrations postgres "user=<your-user-name> password=<your-password> dbname=<your-db-name> host=<your-db-host> port=<your-db-port> sslmode=disable" down-to <migration-number) 86 ``` 87 88 The migration number is a 0 based integer of the migration scripts in the `migrations` folder. For example, if you want to rollback to the first migration, you would use the following command: 89 90 ```bash 91 goose -dir migrations postgres "user=<your-user-name> password=<your-password> dbname=<your-db-name> host=<your-db-host> port=<your-db-port> sslmode=disable" down-to 1 92 ``` 93 94 To unwind just one migration to the previous one, you can use the following command: 95 96 ```bash 97 goose -dir migrations postgres "user=<your-user-name> password=<your-password> dbname=<your-db-name> host=<your-db-host> port=<your-db-port> sslmode=disable" down 98 ```