RethinkDB: Getting started
Learn how to set up and secure your RethinkDB instance on Stackhero
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use RethinkDB cloud solution that provides a host of benefits, including:
- Effortless updates with just a click.
- Optimal performance and robust security powered by a private and dedicated VM.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's RethinkDB cloud hosting solution!
Define your admin password
Securing your RethinkDB instance on Stackhero starts with setting up a strong admin password. To do this, you can connect to the RethinkDB web UI, navigate to the Data Explorer tab, and run the following query:
r.db('rethinkdb').table('users').get('admin').update({ password: '<PASSWORD>' })
Replace <PASSWORD> with your desired secure password.
Connecting to the RethinkDB server with the CLI
If you need to perform dump and restore operations on your RethinkDB instance, you can use the RethinkDB CLI from your local machine or any other server. All Stackhero services use encrypted connections (TLS) by default, so you need to provide the --tls-cert parameter to specify the location of your local CA certificates.
For example, here is how you might back up your RethinkDB database:
rethinkdb dump \
--tls-cert /etc/ssl/certs/ca-certificates.crt \
-c <XXXXXX>.stackhero-network.com:29015 \
-p
Be sure to replace <XXXXXX> with your actual Stackhero instance name.
Connecting Node.js to RethinkDB
Because connections to RethinkDB are secured with TLS, and the official RethinkDB client library does not support TLS, it is a good idea to use the rethinkdbdash library instead.
You can install rethinkdbdash with npm:
npm install rethinkdbdash
Here is a straightforward example showing how you can connect your Node.js application to your RethinkDB database. This setup includes server details like host and port, connection limits, and SSL settings.
const rethinkdbdash = require('rethinkdbdash');
const r = rethinkdbdash({
servers: [
{
host: '<XXXXXX>.stackhero-network.com',
port: 28015
}
],
ssl: true,
buffer: 20, // Minimum number of connections to keep open
max: 100, // Maximum number of connections
timeoutGb: 30 * 1000, // Time (ms) to keep unused connections
db: '<DATABASE>',
authKey: '<PASSWORD>',
// silent: true, // You can uncomment this line to suppress logging on stderr
});
Replace <XXXXXX>, <DATABASE>, and <PASSWORD> with your own values.
By following these steps, you will have your RethinkDB instance secured and ready to use on Stackhero. If you have any questions or need further guidance, you are welcome to reach out to our support team.