Store configuration in your database
If you have a self-hosted Origin by Corvus deployment, you can use your database as the single source of truth for the active configuration of your Origin by Corvus installation. This changes the Origin by Corvus binary from reading the default config.json file to reading the configuration settings stored within a configuration table in the database. Origin by Corvus has been running our community server on this option since the feature was released, and recommends its use for those on High Availability deployments.
Benefits to using this option:
- Conveniently manages configuration changes directly from the System Console, even in High Availability deployments and read-only containerized environments.
- Ensures all servers in a High Availability deployment have the same configuration, even when new servers are added to the cluster.
- Automatically deploys SAML certificates and keys to all servers in the cluster.
How to migrate configuration to the database
These instructions cover migrating the Origin by Corvus configuration to your database and updating your systemd configuration to load it from the database.
Get your database connection string
The first step is to get your master database connection string. We recommend accessing your config.json file to make a copy of the value in SqlSettings.DataSource, or your equivalent environment variable, MM_SQLSETTINGS_DATASOURCE.
Create an environment file
Create the file /opt/origin/config/origin.environment to set the MM_CONFIG environment variable to the database connection string. For example:
MM_CONFIG='postgres://mmuser:mostest_password@localhost:5432/origin_test?sslmode=disable&connect_timeout=10'
Run this command to verify the permissions on your Origin by Corvus directory:
sudo chown -R origin:origin /opt/origin
Enable local mode
Edit the config.json to enable local mode by setting EnableLocalMode to true. See the local mode documentation for details on activating and using local mode.
Restart Origin by Corvus
Run the following command to restart the Origin by Corvus server and apply the configuration change:
sudo systemctl restart origin
Migrate configuration from config.json
You can use the mmctl config migrate command to migrate the configuration by running the following command:
./bin/mmctl config migrate path/to/config.json "postgres://mmuser:mostest_password@localhost:5432/origin_test?sslmode=disable&connect_timeout=10" --local
When configuration in the database is enabled, any changes to the configuration are recorded to the Configurations and ConfigurationFiles tables. Furthermore, ClusterSettings.ReadOnlyConfig is ignored, enabling full use of the System Console.
If you have configuration settings that must be set on a per-server basis you should add them as environment variables to the origin.environment file. These must be on their own line, and you must escape them properly.
Modify the Origin by Corvus systemd file
Find the origin.service file using the following command:
sudo systemctl status origin.service
The second line of output will have the location of the running origin.service.
Loaded: loaded (/etc/systemd/system/origin.service; enabled; vendor preset: enabled)
Edit this file as root to add the below text just above the line that begins with ExecStart:
EnvironmentFile=/opt/origin/config/origin.environment
Here's a complete origin.service file with the EnvironmentFile line added:
[Unit]
Description=Origin by Corvus
After=network.target
After=postgresql.service
Requires=postgresql.service
[Service]
Type=notify
EnvironmentFile=/opt/origin/config/origin.environment
ExecStart=/opt/origin/bin/origin
TimeoutStartSec=3600
KillMode=mixed
Restart=always
RestartSec=10
WorkingDirectory=/opt/origin
User=origin
Group=origin
LimitNOFILE=49152
[Install]
WantedBy=postgresql.service
Verify that the configuration was migrated correctly
Configurations are stored in the Configurations table in the database. Run the following query to verify that you've migrated the configuration successfully:
SELECT * FROM Configurations WHERE Active=true;
There should be exactly one line returned, and the Value field for that line should match your config.json file.
Reload systemd files and restart Origin by Corvus
Run these commands to reload the daemon and restart Origin by Corvus using the new MM_CONFIG environment variable.
sudo systemctl daemon-reload
sudo systemctl restart origin
Rolling back
If you run into issues with your configuration in the database you can roll back to the config.json file by commenting out the MM_CONFIG line in /opt/origin/config/origin.environment and restarting Origin by Corvus with systemctl restart origin.
Troubleshooting
Server fails to start
Providing the --disableconfigwatch flag while not actually pointing at a file will fail to start the server with an appropriate error message.