Getting started with Databases on ServerPrism
This guide helps you set up and configure your database server on ServerPrism, covering initial setup, connection, and common issues.
This guide helps you deploy and configure your chosen database server on ServerPrism. It covers ordering, initial setup, connecting to your database, and troubleshooting common issues.
Before you start
Ensure you have a clear understanding of which database technology best suits your application's needs. Each database has unique characteristics and use cases.
Ordering on ServerPrism
- Select a plan: Choose a plan with at least 2 GB RAM. For production environments or heavier workloads, 4 GB RAM is recommended.
- Pick a region: Select the data center region closest to your application or users for optimal performance.
- Choose your database: From the available runtimes, select your desired database (e.g., MariaDB, MongoDB, PostgreSQL, Redis, Elasticsearch, Meilisearch, NATS, RabbitMQ).
- Deploy: Complete your order to deploy your database server.
First boot
After deployment, your database server will automatically start. The first boot involves setting up the database environment and any necessary configurations for your chosen runtime. You can monitor the startup progress through the web console in your ServerPrism panel (https://serverprism.com/dashboard).
Your database is ready when you see log entries indicating that the database service has started successfully and is listening for connections. For example, PostgreSQL will show database system is ready to accept connections.
Connecting to your database
To connect to your database, you will typically need the server's IP address, the database port, a username, and a password.
-
Find your connection details: Your server's IP address is displayed prominently in the ServerPrism panel. Default ports vary by database:
- MariaDB/MySQL:
3306 - MongoDB:
27017 - PostgreSQL:
5432 - Redis:
6379 - Elasticsearch:
9200 - Meilisearch:
7700 - NATS:
4222 - RabbitMQ:
5672(AMQP),15672(Management UI)
- MariaDB/MySQL:
-
Retrieve credentials: Default usernames and passwords (if applicable) are often set as environment variables on the Startup tab in your ServerPrism panel or generated during the initial setup. Consult the specific database's documentation or the runtime details in the panel for default credentials.
-
Use a client or ORM: Connect from your application or a database client tool using the retrieved details. For example:
-
PostgreSQL (psql command-line client):
psql -h your_server_ip -p 5432 -U your_username -d your_database_name -
MongoDB (mongo shell):
mongo --host your_server_ip --port 27017 -u your_username -p --authenticationDatabase admin -
Redis (redis-cli):
redis-cli -h your_server_ip -p 6379 -a your_password
-
Configuration basics
Most database configurations are managed through configuration files or startup variables. You can access and modify these files via the File Manager or SFTP in your ServerPrism panel.
-
Startup Variables: Check the Startup tab in your panel for environment variables that control key settings like database passwords, memory limits, or specific features. These variables override default settings and are the easiest way to make initial changes.
-
Configuration Files: For more advanced tuning, you will edit the database's primary configuration file. Common examples include:
- MariaDB/MySQL:
my.cnformysqld.cnf - MongoDB:
mongod.conf - PostgreSQL:
postgresql.confandpg_hba.conf - Redis:
redis.conf
After modifying a configuration file, restart your server from the panel to apply the changes.
- MariaDB/MySQL:
Common issues
-
Cannot connect to database:
- Incorrect IP/Port: Double-check the server IP and the correct default port for your database. Ensure no firewalls are blocking the connection on your client side.
- Incorrect Credentials: Verify the username and password. If using environment variables, ensure they are correctly set on the Startup tab.
- Database not running: Check the web console for errors during startup. If the database failed to start, the port might not be open.
- Firewall on ServerPrism: ServerPrism's infrastructure typically handles port exposure for the primary database port. If you're trying to use a non-standard port or a management interface, ensure it's correctly configured in the database settings.
-
Database out of memory:
- Monitor your database's memory usage. If it consistently exceeds your plan's allocated RAM, you may need to upgrade your plan from your ServerPrism customer dashboard.
- Adjust database configuration parameters related to memory (e.g.,
shared_buffersfor PostgreSQL,maxmemoryfor Redis) to optimize usage.
-
Slow queries/performance issues:
- Review your database logs for slow query reports.
- Consider indexing frequently queried columns.
- Optimize your application's queries.
- If resources are consistently maxed out, an upgrade to a higher RAM plan might be necessary.
Next steps
- Backup Strategy: Implement a robust backup strategy for your database. Most databases offer command-line tools for creating dumps (e.g.,
pg_dump,mysqldump,mongodump). You can schedule these via cron jobs or integrate with external backup services. - Monitoring: Set up monitoring for your database health, performance, and resource usage. Many databases have built-in monitoring tools or integrations with third-party services.
- Advanced Configuration: Explore the specific documentation for your chosen database to delve into advanced tuning, replication, and security features.
- Switching Runtimes: If your needs change, you can switch your database runtime (e.g., from MariaDB to PostgreSQL) from the Startup tab in your ServerPrism panel without reordering your server. Be aware that switching runtimes will deploy a fresh database instance, and you will need to migrate your data if you are not starting from scratch.
- Support: If you encounter persistent issues, open a support ticket at https://serverprism.com/tickets. Provide your server ID and relevant log snippets for faster assistance.