Install ifupdown2 on Debian

Install ifupdown2 from proxmox no-subscription repository for Debian 64bit

apt install --yes lsb-release wget curl

wget https://enterprise.proxmox.com/debian/proxmox-release-$(lsb_release -sc).gpg --output-document=/etc/apt/trusted.gpg.d/proxmox-release-$(lsb_release -sc).gpg

echo "deb [arch=amd64 signedby=/etc/apt/trusted.gpg.d/proxmox-release-$(lsb_release -sc).gpg] http://download.proxmox.com/debian/pve $(lsb_release -sc) pve-no-subscription" > /etc/apt/sources.list.d/pve.list

echo "Package: *\nPin: origin \"download.proxmox.com\"\nPin-Priority: 50\n\nPackage: ifupdown2\nPin: origin \"download.proxmox.com\"\nPin-Priority: 500" > /etc/apt/preferences.d/pve

apt update

apt list --upgradeable

apt install --yes ethtool bridge-utils python3-mako ifupdown2

Install xmlrpc-c, libtorrent, rtorrent and rutorrent from svn

Set and create the dir we will use for svn checkouts

svnpath="/svn/"
sudo mkdir $svnpath
sudo chown -R $USER:$USER $svnpath

Install everything you will need and remove xmlrpc or else rtorrent will complain because it uses the one from the repos

sudo apt-get remove libxmlrpc-c*
sudo apt-get install subversion gcc apache2 curl libcurl4-openssl-dev automake autoconf texinfo libapache2-mod-scgi build-essential libtool openssl libsigc++-2.0-dev libncurses-dev libcppunit-dev php5 php5-cli screen

Configure, make and make install xmlrpc-c

cd "$svnpath"
svn co http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/advanced xmlrpc-c
cd xmlrpc-c
./configure
make
sudo make install

Configure, make and make install libtorrent and rtorrent

cd "$svnpath"
svn co svn://rakshasa.no/libtorrent/trunk rtorrent
cd rtorrent
cd libtorrent
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
cd ../rtorrent
./autogen.sh
./configure --with-xmlrpc-c
make
sudo make install

Install libxmlrpc-c3-dev

sudo apt-get install libxmlrpc-c3-dev

Get the latest rutorrent

cd $svnpath

svn co rutorrent

To enabel scgi in apache run

sudo a2enmod scgi

To add a scgi mount in apache edit /etc/apache2/httpd.conf

sudo nano /etc/apache2/httpd.conf
and add
SCGIMount /RPC2 127.0.0.1:5000

Then restart apache

sudo service apache2 restart

We also have to add the mount to your rtorrent conf file

In your ~/.rtorrent.rc file
nano ~/.rtorrent.rc
add
scgi_port = localhost:5000

Create a symbolic link to rutorrent in /var/www/

sudo ln -s $svnpath/rutorrent /var/www/

Change ownership of rutorrent/share/torrents/ and rutorrent/share/settings to the one who runs the apache2 server

Set www-data as group of rutorrent/share/torrents/ and rutorrent/share/settings/
sudo chown -R $USER:www-data $svnpath/rutorrent/share/torrents/ $svnpath/rutorrent/share/settings/
And allow the group (www-data) to edit those dirs
chmod g+w $svnpath/rutorrent/share/torrents/ $svnpath/rutorrent/share/settings/

Test

You can test rtorrent and rutorrent by running
cd /tmp/
rtorrent

To download lucid server iso to /tmp

Then check so rutorrent is working by going to

http://server/rutorrent/

ex.

It should not be any errors.

And that is all.

Running in bagground mode

You can get rtorrent to run in bagground mode, by having installed screen, it’s possible to start rtorrent (meaning it’s not running at this point, else this won’t work if rtorrent is already running!) with the command

screen rtorrent

and then detach the rtorrent interface in the terminal/ssh remote window by pressing

shift + a + d

and then close the terminal/ssh remote session window, and rtorrent will continue to run in the bagground…

 

Original article found here

MariaDB Galera Cluster on Ubuntu 18.04

Install required packages

  • dist-upgrade: Optional! Updates the Linux kernel if new minor updates are available.
  • ufw: Tool for easier administration of firewall rules.
  • mariadb-server, mariadb-client, galera-3, rsync: Required for running the Galera Cluster.
sudo apt-get update && \
sudo apt-get upgrade -y && \
sudo apt-get dist-upgrade -y && \
sudo apt-get autoremove && \
sudo apt-get install mariadb-server mariadb-client galera-3 rsync -y && \
sudo apt-get install ufw -y

Optional packages

If you want to be able to tell on your switch/router wich server has wich hostname you can install lldp and snmp to be able to do remote monitoring of the hosts.

sudo apt-get install lldpd snmpd -y

Configuring the Cluster nodes

Stop the MariaDB service on all hosts!

sudo service mysql stop

Open up the following ports between hosts.

sudo ufw allow proto tcp from 192.168.56.0/29 to 192.168.56.0/29 port 3306,4567-4568,4444
sudo ufw allow proto udp from 192.168.56.0/29 to 192.168.56.0/29 port 4567

Note: Subsitute the subnet above (192.168.56.0/29) with the subnet your MariaDB galera hosts are located in!

On the FIRST host

It is required all hosts have the same config for the galera cluster to work.

MariaDB looks up config in the /etc/mysql/ dir. We can add additional config files in the /etc/mysql/conf.d/ dir ending in .cnf and it will be loaded in addition to the MariaDB main configuration files.

sudo nano /etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0

# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so

# Galera Cluster Configuration
# Name of the cluster. MUST be identical on all hosts.
wsrep_cluster_name="random_cluster_name"
# wsrep_cluster_address: both IP and DNS names
# of the cluster hosts can be used.
wsrep_cluster_address="gcomm://node1,node2,node3"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
# Local hosts IP address
wsrep_node_address="192.168.56.[2|3|4]"
# Local host hostname.
wsrep_node_name="node[1|2|3]"

Additional hosts

Do the same as above, but rememember to edit wsrep_node_address and wsrep_node_name!

Setting up Galera

On the FIRST host do:

sudo galera_new_cluster

This HAS TO BE DONE to ensure when the additional hosts mariadb server is started. They have an exisiting already configured and running Cluster node to connect to.

You can verify the number of cluster members by running

mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"

each time to startup a new cluster node.

Output
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 1     |
+--------------------+-------+

Next

Bring up host no.2 and verify the number of cluster members.

mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"
Output
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 2     |
+--------------------+-------+

Next

Bring up host no.3 and verify the number of cluster members.

mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"
Output
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 3     |
+--------------------+-------+

Debian maintenance user

If your system uses the Debian maintenance user (see in /etc/mysql/debian.cnf). You will need to make sure all host members in the cluster is configured with the same credentials. As the credentials from the 1st cluster host will be synced to additional hosts joining the galera cluster.

[client]
host     = localhost
user     = debian-sys-maint
password = 03P8rdlknkXr1upf
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = 03P8rdlknkXr1upf
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

Verifying replication works

First node

Create a test database and insert some data.

mysql -u root -p -e 'CREATE DATABASE playground;
CREATE TABLE playground.equipment ( id INT NOT NULL AUTO_INCREMENT, type VARCHAR(50), quant INT, color VARCHAR(25), PRIMARY KEY(id));
INSERT INTO playground.equipment (type, quant, color) VALUES ("slide", 2, "blue");'

Second node

mysql -u root -p -e 'SELECT * FROM playground.equipment;'
Output
+----+-------+-------+-------+
| id | type  | quant | color |
+----+-------+-------+-------+
|  1 | slide |     2 | blue  |
+----+-------+-------+-------+

Insert some more data.

mysql -u root -p -e 'INSERT INTO playground.equipment (type, quant, color) VALUES ("swing", 10, "yellow");'

Third node

Verify data created on node2 exists on db in node3.

mysql -u root -p -e 'SELECT * FROM playground.equipment;'
Output
+----+-------+-------+--------+
| id | type  | quant | color  |
+----+-------+-------+--------+
|  1 | slide |     2 | blue   |
|  2 | swing |    10 | yellow |
+----+-------+-------+--------+

Add an additional data string to the databas.

mysql -u root -p -e 'INSERT INTO playground.equipment (type, quant, color) VALUES ("seesaw", 3, "green");'

First node

Verfiy the data created on node3 exists on node 1.

mysql -u root -p -e 'SELECT * FROM playground.equipment;'
Output
+----+--------+-------+--------+
| id | type   | quant | color  |
+----+--------+-------+--------+
|  1 | slide  |     2 | blue   |
|  2 | swing  |    10 | yellow |
|  3 | seesaw |     3 | green  |
+----+--------+-------+--------+

Conclusion

If all is well. You should now have a three hosts running and working MariaDB Galera Cluster.

Notes to remember

  1. Traffic between the cluster hosts is not encrypted. So either remember to put them in a private subnet or enable encryption for cluster member traffic.
  2. There are other available state snapshot transfer agents available apart from rsync. Fx. xtrabackup. Remember to always look at your options.

 

Crashed ISPConfig3 hosted wordpress blog by ERROR 40

Had a blog hosted on an ISPConfig3, Nginx, MySQL, PHP platform on Debian mini and by ERROR 40 deleted my blog… bad mistake… Honest mistake and I’m a real man, so no offsite backup was to be found, no joke.

The guide followed when the VPS was set-up can be seen here.

The error was plausible to happen a some point, but frustrating to have my blog site gone, after the time invested. Everything for the learning experience, I guess. Sigh.

Next. Install ISPConfig3 with Apache, MySQL/MariaDB, dovecut and PHP and see how that goes.