Following the instructions on CKAN DataStore with a little information.
Enable the plugin
In your CKAN config file (/etc/ckan/default/ckan.ini), update the datastore plugin
ckan.plugins = datastore
Set-up the database
The DataStore requires a separate PostgreSQL database to save the DataStore resources. List the existing databases:
sudo -u postgres psql -l
Response
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------------+--------------+----------+---------+---------+-----------------------
ckan_default | ckan_default | UTF8 | C.UTF-8 | C.UTF-8 |
datastore_default | ckan_default | UTF8 | C.UTF-8 | C.UTF-8 |
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
Create the database and user
Create a database_user called datastore_default. This user will be given read-only access to your DataStore database in the Set Permissions step below:
sudo -u postgres createuser -S -D -R -P -l datastore_default
Create the database (owned by ckan_default), in tis instance call the database datastore_default:
sudo -u postgres createdb -O ckan_default datastore_default -E utf-8
Set URLs in CKAN config file
Uncomment the ckan.datastore.write_url and ckan.datastore.read_url lines in your CKAN config file and edit them if necessary, for example:
ckan.datastore.write_url = postgresql://ckan_default:{pass}@localhost/datastore_default
ckan.datastore.read_url = postgresql://datastore_default:{pass}@localhost/datastore_default
Remember to replace {pass} with the passwords you created for your ckan_default and datastore_default database users.
Set permissions
If you can connect to your database server as the postgres superuser using:
sudo -u postgres psql
Then you can use this connection to set the permissions. But do this step outside of being in the database. If you have run the above command, enter exit to leave the database CLI. Now you can run:
ckan -c /etc/ckan/default/ckan.ini datastore set-permissions | sudo -u postgres psql --set ON_ERROR_STOP=1
Check the permissions have been updated, by
sudo -u postgres psql -l
Response
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------------+--------------+----------+---------+---------+----------------------------------
ckan_default | ckan_default | UTF8 | C.UTF-8 | C.UTF-8 | =Tc/ckan_default +
| | | | | ckan_default=CTc/ckan_default
datastore_default | ckan_default | UTF8 | C.UTF-8 | C.UTF-8 | =Tc/ckan_default +
| | | | | ckan_default=CTc/ckan_default +
| | | | | datastore_default=c/ckan_default
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)