Adding Multiple Database Servers in Plesk Using Docker
Adding Multiple Database Servers in Plesk Using Docker
By default, you can only install a single version of MySQL/MariaDB on your server. However, if some of your customer require a different MySQL version, you can use docker. Plesk allows you to add multiple database servers using its Docker extension. This is particularly useful when hosting multiple applications requiring different database versions. In this guide, we will walk through installing and configuring a MariaDB 10.11 Docker container, mapping its ports, and adding it to Plesk as an external database server.
Step 1: Prepare the Server
Log into your server via SSH.
Create a directory for the Docker container’s data storage to ensure persistence:
mkdir -p /var/docker/mysql/
Step 2: Install and Configure Docker in Plesk
Log in to Plesk.
Navigate to Extensions and ensure the Docker extension is installed. If not, install it.
Go to Docker in Plesk.
In the search box, type mariadb and press Enter.
Select the MariaDB image and choose version 10.11.
Click Next.
Configure the container:
Check Automatic start after system reboot.
Uncheck Automatic port mapping and manually map:
Internal port 3306 to external port 3307.
Ensure firewall rules allow traffic on ports 3307 and 33070.
Set Volume mapping:
Container: /var/lib/mysql
Host: /var/docker/mysql
Warning: Not mapping this can result in data loss when the container is recreated.
Add an environment variable MYSQL_ROOT_PASSWORD and specify a secure root password.
Click Run to start the container.
Step 3: Add the MySQL Docker Container as an External Database in Plesk
Once the container is running, we need to add it to Plesk as an external database server:
Set as Default (Optional): Check Use this server as default for MySQL if you want clients to use this server by default.
Credentials: Enter the root user and password specified during container setup.
Click OK to save the configuration.
Step 4: Using the New Database Server
Now that the new database server is added, clients can choose it when creating a new database in Plesk:
Go to Databases in Plesk.
Click Add Database.
Under Database server, select the newly added MariaDB 10.11 instance.
This setup allows clients to choose different database servers for their applications while ensuring database persistence and security.
Conclusion
By leveraging Docker, you can efficiently manage multiple database versions on a Plesk server. This method ensures better isolation, easier upgrades, and avoids conflicts between database versions, providing a flexible and robust hosting environment.
Introduction Redmine is a powerful and versatile project management tool that can help teams stay organized, collaborate effectively, and track progress towards their goals. Originally developed for the Ruby on Rails community, Redmine is now used by thousands of organizations worldwide, from small startups to large enterprises.
With Redmine, you can create projects and sub-projects, define tasks and issues, assign them to team members, set due dates and priorities, and track time spent on each task. You can also add comments and attachments to issues, create custom fields and workflows, and generate reports and graphs to visualize project status and progress.
It is open-source software written in Ruby on Rails and is available under the GNU General Public License.
Whether you’re a software development team, a marketing agency, a non-profit organization, or any other type of group that needs to manage projects and tasks, Redmine can be a valuable tool to help you stay on track, collaborate effectively, and achieve your goals. In this blog, we’ll explore some of the key features and use cases of Redmine, and provide tips and best practices for getting the most out of this powerful project management tool.
In this tutorial, we will go through the steps of installing Redmine on an Ubuntu 22.04 server and secure it Let’s Encrypt SSL.
Prerequisites:
Ubuntu 22.04 Server Root or sudo user access A domain name pointed to the server is required for accessing Redmine via a web browser.
Step 1: Update Ubuntu System The first step is to update the Ubuntu system to ensure that all the packages are up-to-date. You can do this by running the following command: sudo apt update Step 2: Install Dependencies Redmine requires several dependencies to be installed before it can be installed. To install them, run the following command:
Also, install Apache and Apache mod Passenger module sudo apt install -y apache2 libapache2-mod-passenger
Note: libapache2-mod-passenger is a module for the Apache web server that enables the deployment of Ruby on Rails web applications. It provides an easy way to configure and manage Ruby on Rails applications within an Apache web server environment.
Step 3: Create a Redmine User Create a dedicated Linux user for running Redmine: useradd -r -m -d /opt/redmine -s /usr/bin/bash redmine
Add the user to the www-data group to enable Apache to access Redmine files: usermod -aG redmine www-data
Step 4: Install and Secure MariaDB MariaDB is a popular open-source database management system and is used as the backend for Redmine. To install and secure MariaDB, run the following commands: sudo apt install -y mariadb-server
Since the configuration file is an yaml, you need to use proper Indentation.
Save and close the file.
Step 7: Install Bundler and Redmine Dependencies Install Bundler for managing gem dependencies and run the following commands:
sudo gem install bundler
Login as redmine user and execute below commands:
su - redmine
bundle config set --local without 'development test'
bundle install
bundle update
exit
Step 8: Configure File System Permissions Ensure that the following directories are available in the Redmine directory (/opt/redmine):
tmp and tmp/pdf public and public/plugin_assets log files
Create them if they don’t exist and ensure that they are owned by the user used to run Redmine:
for i in tmp tmp/pdf public/plugin_assets; do [ -d $i ] || mkdir -p $i; done
chown -R redmine:redmine files log tmp public/plugin_assets
chmod -R 755 /opt/redmine
Step 9: Configure Apache Create a new Apache virtual host file for Redmine: sudo nano /etc/apache2/sites-available/redmine.conf
Paste the following configuration into the file:
<VirtualHost *:80>
ServerName redmine.linuxwebhostingsupport.in
DocumentRoot /opt/redmine/public
ErrorLog ${APACHE_LOG_DIR}/redmine-error.log
CustomLog ${APACHE_LOG_DIR}/redmine-access.log combined
<Directory /opt/redmine/public>
Require all granted
Options -MultiViews
PassengerEnabled on
PassengerAppEnv production
PassengerRuby /usr/bin/ruby
</Directory>
</VirtualHost>
Save the file and exit the text editor. Replace redmine.linuxwebhostingsupport.in with your domain name.
Enable the Redmine site by running the following command:
sudo a2ensite redmine.conf
Restart Apache to apply the changes:
sudo systemctl restart apache2
Allow Apache through the Ubuntu UFW firewall:
sudo ufw allow 'Apache Full'
Install Certbot and the Apache plugin for Let’s Encrypt:
sudo apt install certbot python3-certbot-apache
Adding Lets Encrypt SSL certificate
You need to make sure your domain is properly pointed to the server IP, otherwise, Let’s encrypt will fail.
Obtain an SSL certificate for your domain by running the following command:
sudo certbot --apache
Follow the on-screen instructions to complete the process.
Restart Apache to apply the SSL configuration:
sudo systemctl restart apache2
Open your web browser and go to https://redmine.linuxwebhostingsupport.in/. You should see the Redmine home screen.
Login to the admin area using your Redmine admin username and password. If this is your first login, you will need to reset your admin password.
https://redmine.linuxwebhostingsupport.in/login
Congratulations! You have successfully installed and configured Redmine on your Ubuntu server. In the previous steps, we have covered the installation and configuration of Redmine, including setting up the database, configuring Apache, and securing Redmine with Let’s Encrypt SSL.
However, one critical aspect of Redmine that you might want to configure is email delivery for notifications. This feature is essential for keeping team members informed about project updates, new issues, and changes to existing issues. In this section, we will show you how to configure email delivery in Redmine.
Configuring SMTP for Email Delivery in Redmine
Redmine supports email delivery for notifications, which you can set up using the following steps:
Step 1 – Open Configuration File
First, you need to open the configuration.yml file in a text editor:
sudo nano /opt/redmine/config/configuration.yml
Step 2 – Configure Email Settings
Next, scroll down to the production section of the file, uncomment the following lines by removing the # symbol at the beginning of each line, and replace the values with your SMTP server’s settings:
# specific configuration options for production environment# that overrides the default ones
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "your.smtp.server.com"
port: 587
domain: "your.domain.com"
authentication: :login
user_name: "your_email@example.com"
password: "your_email_password"
enable_starttls_auto: true
# specific configuration options for development environment# that overrides the default ones
Replace the values for address, port, domain, user_name, and password with your SMTP server’s settings:
address: The address of your SMTP server. port: The port number to use for SMTP server (usually 587). domain: The domain name of your organization or server. user_name: The email address of the user account to use for sending emails. password: The password for the user account to use for sending emails. Save the configuration.yml file.
Since the configuration file is an yaml, you need to use proper Indentation.
Step 3 – Restart Apache
Finally, restart Apache to apply the changes:
sudo systemctl restart apache2 And that’s it! Redmine is now configured to deliver email notifications to your team members.
Conclusion
Redmine is a powerful project management tool that can help you manage your software development projects effectively. In this blog post, we have covered the installation and configuration of Redmine on Ubuntu, including setting up the database, configuring Apache, securing Redmine with Let’s Encrypt SSL, and configuring email delivery.
With these steps, you should now have a working Redmine installation that can help you track your projects, collaborate with your team, and stay on top of your development process. Good luck!
How to remove or compress huge MySQL general and query log table
If you have enabled MySQL general or slow logging, it can create quite big log, depending upon your MySQL usage/queries. So we may have to periodically clear them to save space.
Please note that MySQL can save logs to either table or files. This document assumes you are using table as log output.
Files: slow_log.CSV and general_log.CSV (The location and the name of the file can be different)
By default, logging is to CSF file.
MYSQL supports run time clearing of these logs. So no need to restart the MySQL service. Never delete the CSV file directly. It can crash MySQL.
Slow query log
SET GLOBAL slow_query_log='OFF';
DROP TABLE IF EXISTS slow_log2;
CREATE TABLE slow_log2 LIKE slow_log;
RENAME TABLE slow_log TO slow_log_backup, slow_log2 TO slow_log;
gzip /var/db/mysql/mysql/slow_log_backup.CSV
DROP TABLE slow_log_backup;
SET GLOBAL slow_query_log = 'ON';
General log
USE mysql;
SET GLOBAL general_log = 'OFF';
DROP TABLE IF EXISTS general_log2;
CREATE TABLE general_log2 LIKE general_log;
RENAME TABLE general_log TO general_log_backup, general_log2 TO general_log;
gzip /var/db/mysql/mysql/general_log_backup.CSV
DROP TABLE general_log_backup;
What we did is create new log table, move current log file to a backup copy and compress the backup and remove it.