<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>System admin &#8211; G1FEF</title>
	<atom:link href="https://g1fef.co.uk/category/sysadmin/feed/" rel="self" type="application/rss+xml" />
	<link>https://g1fef.co.uk</link>
	<description></description>
	<lastBuildDate>Tue, 13 Aug 2019 09:32:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Asterisk systemd startup script</title>
		<link>https://g1fef.co.uk/asterisk-systemd-startup-script/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sat, 08 Sep 2018 07:50:29 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=190</guid>

					<description><![CDATA[The systemd startup script &#8220;out of the box&#8221; (at least up to version 15.5) for Asterisk does not work properly: on rebooting the server the ownership of /run/asterisk (symlink /var/run/asterisk) reverts to root.root instead of asterisk.asterisk The reason for this is that the o/s removes and re-creates the /run/asterisk directory on reboot. The solution is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The systemd startup script &#8220;out of the box&#8221; (at least up to version 15.5) for Asterisk does not work properly: on rebooting the server the ownership of /run/asterisk (symlink /var/run/asterisk) reverts to root.root instead of asterisk.asterisk</p>
<p>The reason for this is that the o/s removes and re-creates the /run/asterisk directory on reboot. The solution is to place a &#8220;RuntimeDirectory=&#8221; entry in the systemd service script:</p>
<p>/usr/lib/systemd/system/asterisk.service</p>
<p>The &#8220;RuntimeDirectory=&#8221; needs a directory name relative to /run so you can&#8217;t do this:</p>
<p>RuntimeDirectory=/run/asterisk</p>
<p>nor this:</p>
<p>RuntimeDirectory=/var/run/asterisk</p>
<p>You need to do this:</p>
<p>RuntimeDirectory=asterisk</p>
<p>Here is my fully working script (/usr/lib/systemd/system/asterisk.service):</p>
<pre class="text">
[Unit]
Description=Asterisk PBX and telephony daemon.
Wants=network.target
After=network.target

[Service]
Type=simple
User=asterisk
Group=asterisk
RuntimeDirectory=asterisk
Environment=HOME=/var/lib/asterisk
WorkingDirectory=/var/lib/asterisk

ExecStart=/usr/sbin/asterisk -f -C /etc/asterisk/asterisk.conf
ExecStop=/usr/sbin/asterisk -rx 'core stop now'
ExecReload=/usr/sbin/asterisk -rx 'core reload'

# safe_asterisk emulation
Restart=always
RestartSec=10

#Nice=0
#UMask=0002
LimitCORE=infinity
#LimitNOFILE=

# Prevent duplication of logs with color codes to /var/log/messages
#StandardOutput=null

PrivateTmp=true

[Install]
WantedBy=multi-user.target
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setup MySQL / MariaDB master slave replication</title>
		<link>https://g1fef.co.uk/setup-mysql-mariadb-master-slave-replication/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sun, 02 Jul 2017 08:21:15 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=176</guid>

					<description><![CDATA[mysql -u root -p &#60; dump.sql How to setup a single master with one or more readonly slaves First configure the master by editing the mysql configuration file, this could be /etc/my.cnf or on Centos 7 it is /etc/my.cnf.d/server.cnf Find the [server] section and add the following lines: bind-address = 12.34.56.78 # replace 12.34.56.78 with [&#8230;]]]></description>
										<content:encoded><![CDATA[<pre class="lang:default decode:true ">mysql -u root -p &lt; dump.sql</pre>
<h4>How to setup a single master with one or more readonly slaves</h4>
<p><span id="more-176"></span></p>
<p>First configure the master by editing the mysql configuration file, this could be /etc/my.cnf or on Centos 7 it is /etc/my.cnf.d/server.cnf</p>
<p>Find the [server] section and add the following lines:</p>
<pre class="text">bind-address = 12.34.56.78 # replace 12.34.56.78 with the IP of your server
log_bin
server_id = 1
log_basename = master1
datadir = /var/lib/mysql
binlog-ignore-db = mysql
</pre>
<p>The binlog-ignore-db line tells the master not to replicate the &#8216;mysql&#8217; database, you can add additional entries to not replicate other databases if you wish, e.g.</p>
<pre class="text">binlog-ignore-db = information_schema
binlog-ignore-db = performance_schema
</pre>
<p>Adding the following additional entries allows you to tweak the performance of your server:</p>
<pre class="text">max_allowed_packet=64M
max_heap_table_size = 64M
tmp_table_size = 128M
join_buffer_size = 128M
innodb_buffer_pool_size = 256M
innodb_doublewrite = OFF
innodb_additional_mem_pool_size = 128M
innodb_flush_log_at_timeout = 4
innodb_read_io_threads = 48
innodb_write_io_threads = 32
max_connections = 128
</pre>
<p>Following any changes to the config files you will need to restart MySQL (or MariaDB if you use that instead), so you would do one of the following:</p>
<pre class="text">systemctl restart mysqld
systemctl restart mariadb
</pre>
<p>Now login to your local MySQL server, e.g.</p>
<pre class="text">mysql -u root -p
</pre>
<p>Once logged into the MySQL CLI add a user that the slaves will use to replicate:</p>
<pre class="text">GRANT REPLICATION SLAVE ON *.* TO 'replication'@'1.2.3.4' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
</pre>
<p>Replace 1.2.3.4 with the IP of your slave server. You can run the above command multiple times, once for each slave server. Remember to change &#8216;password&#8217; to an actual password, a good choice would be 12 (or more) characters consisting of a random mix of upper/lowercase letters, numbers and punctuation characters.</p>
<p>Now we&#8217;re ready to take a backup of the master, for this you will need to open a second session on your master server. In the first session, still logged into the MySQL CLI issue the following commands:</p>
<pre class="text">FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
</pre>
<p>You should see something along these lines:</p>
<pre class="text">+--------------------+----------+--------------+------------------+
| File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| master1-bin.000001 |   456    |              | mysql            |
+--------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
</pre>
<p>Leave this session in place whilst you move to the second session to backup the databases you want to replicate by using your preferred method, e.g.</p>
<pre class="text">mysqldump -u root -p --all-databases &gt; dump.sql
</pre>
<p>Now you can go back to the first window and release the lock:</p>
<pre class="text">UNLOCK TABLES;
QUIT;
</pre>
<p>Now copy this backup to your slave server(s). I use scp for this, e.g.</p>
<pre class="text">scp dump.sql username@12.34.56.78:.
</pre>
<p>Now login to the slave server and import the dumped databases:</p>
<p>mysql -u root -p &lt; dump.sql</p>
<p>Now configure MySQL (or mariadb) to be a slave by editing it&#8217;s configuration file, e.g. /etc/my.cnf.d/server.cnf and add the following to the [server] section:</p>
<pre class="text">server-id = 2
datadir = /var/lib/mysql
relay-log = /var/lib/mysql/mysql-relay-bin.log
log_bin = /var/lib/mysql/mysql-bin.log
</pre>
<p>As per the master server, following any changes to the config files you will need to restart MySQL (or MariaDB if you use that instead), so you would do one of the following:</p>
<pre class="text">systemctl restart mysqld
systemctl restart mariadb
</pre>
<p>The next step is to login to the MySQL CLI and tell it where to find the master along with the login details and the starting position in the log:</p>
<pre class="text">CHANGE MASTER TO MASTER_HOST='12.34.56.78',MASTER_USER='replication', MASTER_PASSWORD='password', MASTER_LOG_FILE='master1-bin.000001', MASTER_LOG_POS=456;
</pre>
<p>The last thing we need to do is start the slave process, and check it is running. Do this by issuing the following commands on the slave MySQL CLI:</p>
<pre class="text">START SLAVE;
SHOW SLAVE STATUS\G
</pre>
<p>You can repeat the slave part on each server you want to setup replication, just remember to give each slave a different server_id</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting up and using your own SSL CA</title>
		<link>https://g1fef.co.uk/setting-using-ssl-ca/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Wed, 31 May 2017 18:09:02 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=146</guid>

					<description><![CDATA[This guide shows how to setup a Certificate Authority on Centos 7 Setup the file structure: mkdir /root/ca cd /root/ca mkdir certs crl newcerts private chmod 700 private touch index.txt echo 1000 &#62; serial Create a config file /root/ca/openssl.cnf # OpenSSL root CA configuration file. # Copy to `/root/ca/openssl.cnf`. [ ca ] # `man ca` [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>This guide shows how to setup a Certificate Authority on Centos 7</h4>
<p><span id="more-146"></span></p>
<p>Setup the file structure:</p>
<pre class="SCREEN">mkdir /root/ca
cd /root/ca
mkdir certs crl newcerts private
chmod 700 private
touch index.txt
echo 1000 &gt; serial
</pre>
<p>Create a config file /root/ca/openssl.cnf</p>
<pre class="SCREEN"># OpenSSL root CA configuration file.
# Copy to `/root/ca/openssl.cnf`.

[ ca ]
# `man ca`
default_ca = CA_default

[ CA_default ]
# Directory and file locations.
dir               = /root/ca
certs             = $dir/certs
crl_dir           = $dir/crl
new_certs_dir     = $dir/newcerts
database          = $dir/index.txt
serial            = $dir/serial
RANDFILE          = $dir/private/.rand

# The root key and root certificate.
private_key       = $dir/private/ca.key.pem
certificate       = $dir/certs/ca.cert.pem

# For certificate revocation lists.
crlnumber         = $dir/crlnumber
crl               = $dir/crl/ca.crl.pem
crl_extensions    = crl_ext
default_crl_days  = 30

# SHA-1 is deprecated, so use SHA-2 instead.
default_md        = sha256

name_opt          = ca_default
cert_opt          = ca_default
default_days      = 375
preserve          = no
policy            = policy_strict

[ policy_strict ]
# The root CA should only sign intermediate certificates that match.
# See the POLICY FORMAT section of `man ca`.
countryName             = match
stateOrProvinceName     = match
organizationName        = match
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

[ policy_loose ]
# Allow the intermediate CA to sign a more diverse range of certificates.
# See the POLICY FORMAT section of the `ca` man page.
countryName             = optional
stateOrProvinceName     = optional
localityName            = optional
organizationName        = optional
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

[ req ]
# Options for the `req` tool (`man req`).
default_bits        = 2048
distinguished_name  = req_distinguished_name
string_mask         = utf8only

# SHA-1 is deprecated, so use SHA-2 instead.
default_md          = sha256

# Extension to add when the -x509 option is used.
x509_extensions     = v3_ca

[ req_distinguished_name ]
# See &lt;https://en.wikipedia.org/wiki/Certificate_signing_request&gt;.
countryName                     = Country Name (2 letter code)
stateOrProvinceName             = State or Province Name
localityName                    = Locality Name
0.organizationName              = Organization Name
organizationalUnitName          = Organizational Unit Name
commonName                      = Common Name
emailAddress                    = Email Address

# Optionally, specify some defaults.
countryName_default             = GB
stateOrProvinceName_default     = Buckinghamshire
localityName_default            = High Wycombe
0.organizationName_default      = The Communication Gateway Ltd
organizationalUnitName_default  = Main Office
emailAddress_default            = postmaster@comgw.co.uk

[ v3_ca ]
# Extensions for a typical CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

[ v3_intermediate_ca ]
# Extensions for a typical intermediate CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true, pathlen:0
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

[ usr_cert ]
# Extensions for client certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = client, email
nsComment = "OpenSSL Generated Client Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth, emailProtection

[ server_cert ]
# Extensions for server certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = server
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth

[ crl_ext ]
# Extension for CRLs (`man x509v3_config`).
authorityKeyIdentifier=keyid:always

[ ocsp ]
# Extension for OCSP signing certificates (`man ocsp`).
basicConstraints = CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, digitalSignature
extendedKeyUsage = critical, OCSPSigning
</pre>
<p>Now we can generate the root key:</p>
<pre class="SCREEN">openssl genrsa -aes256 -out private/ca.key.pem 4096
chmod 400 private/ca.key.pem
</pre>
<p>Create the root certificate:</p>
<pre class="SCREEN">openssl req -config openssl.cnf \
      -key private/ca.key.pem \
      -new -x509 -days 7300 -sha256 -extensions v3_ca \
      -out certs/ca.cert.pem
chmod 444 certs/ca.cert.pem
</pre>
<p>Verify the root certificate:</p>
<pre class="SCREEN">openssl x509 -noout -text -in certs/ca.cert.pem
</pre>
<p>Create the intermediate certificate:</p>
<pre class="SCREEN">mkdir /root/ca/intermediate
cd /root/ca/intermediate
mkdir certs crl csr newcerts private
chmod 700 private
touch index.txt
echo 1000 &gt; serial
</pre>
<p>Add a crlnumber file to the intermediate CA directory tree. crlnumber is used to keep track of certificate revocation lists:</p>
<pre class="SCREEN">echo 1000 &gt; /root/ca/intermediate/crlnumber
</pre>
<p>Copy the intermediate CA configuration file: /root/ca/intermediate/openssl.cnf from the main one we created above and alter the following settings:</p>
<pre class="SCREEN">[ CA_default ]
dir             = /root/ca/intermediate
private_key     = $dir/private/intermediate.key.pem
certificate     = $dir/certs/intermediate.cert.pem
crl             = $dir/crl/intermediate.crl.pem
policy          = policy_loose
</pre>
<p>Create the intermediate key:</p>
<pre class="SCREEN">cd /root/ca
openssl genrsa -aes256 \
      -out intermediate/private/intermediate.key.pem 4096
chmod 400 intermediate/private/intermediate.key.pem
</pre>
<p>Create the intermediate certificate:<br />
Use the intermediate key to create a certificate signing request (CSR). The details should generally match the root CA. The Common Name, however, must be different.</p>
<pre class="SCREEN">cd /root/ca
openssl req -config intermediate/openssl.cnf -new -sha256 \
      -key intermediate/private/intermediate.key.pem \
      -out intermediate/csr/intermediate.csr.pem
</pre>
<p>To create an intermediate certificate, use the root CA with the v3_intermediate_ca extension to sign the intermediate CSR. The intermediate certificate should be valid for a shorter period than the root certificate.</p>
<pre class="SCREEN">cd /root/ca
openssl ca -config openssl.cnf -extensions v3_intermediate_ca \
      -days 3650 -notext -md sha256 \
      -in intermediate/csr/intermediate.csr.pem \
      -out intermediate/certs/intermediate.cert.pem
chmod 444 intermediate/certs/intermediate.cert.pem
</pre>
<p>The index.txt file is where the OpenSSL ca tool stores the certificate database. Do not delete or edit this file by hand. It should now contain a line that refers to the intermediate certificate.</p>
<p>Verify the intermediate certificate:</p>
<pre class="SCREEN">openssl x509 -noout -text \
      -in intermediate/certs/intermediate.cert.pem
</pre>
<p>Verify the intermediate certificate against the root certificate. An OK indicates that the chain of trust is intact.</p>
<pre class="SCREEN">openssl verify -CAfile certs/ca.cert.pem \
      intermediate/certs/intermediate.cert.pem
</pre>
<p>Create the certificate chain file:</p>
<pre class="SCREEN">cat intermediate/certs/intermediate.cert.pem \
      certs/ca.cert.pem &gt; intermediate/certs/ca-chain.cert.pem
chmod 444 intermediate/certs/ca-chain.cert.pem
</pre>
<p>NOTE: Our certificate chain file must include the root certificate because no client application knows about it yet. A better option, particularly if you’re administrating an intranet, is to install your root certificate on every client that needs to connect. In that case, the chain file need only contain your intermediate certificate.</p>
<p>We can now sign client and server certificates!</p>
<p>Create a key:</p>
<pre class="SCREEN">cd /root/ca
openssl genrsa -aes256 \
      -out intermediate/private/www.example.com.key.pem 2048
chmod 400 intermediate/private/www.example.com.key.pem
</pre>
<p>If you don&#8217;t want a prompt for a password each time the certificate is used leave out the -aes256 parameter.</p>
<p>Create a certificate Signing Request:</p>
<pre class="SCREEN">cd /root/ca
openssl req -config intermediate/openssl.cnf \
      -key intermediate/private/www.example.com.key.pem \
      -new -sha256 -out intermediate/csr/www.example.com.csr.pem
</pre>
<p>Sign the CSR:</p>
<pre class="SCREEN">cd /root/ca
openssl ca -config intermediate/openssl.cnf \
      -extensions server_cert -days 375 -notext -md sha256 \
      -in intermediate/csr/www.example.com.csr.pem \
      -out intermediate/certs/www.example.com.cert.pem
chmod 444 intermediate/certs/www.example.com.cert.pem
</pre>
<p>Verify the certificate:</p>
<pre class="SCREEN">openssl x509 -noout -text \
      -in intermediate/certs/www.example.com.cert.pem
</pre>
<p>Verify the chain of trust:</p>
<pre class="SCREEN">openssl verify -CAfile intermediate/certs/ca-chain.cert.pem \
      intermediate/certs/www.example.com.cert.pem
</pre>
<p>Deploy the certificate:<br />
ca-chain.cert.pem<br />
www.example.com.key.pem<br />
www.example.com.cert.pem</p>
<p>Reference:<br />
https://jamielinux.com/docs/openssl-certificate-authority/introduction.html</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Centos 7 + Postfix + Amavisd-new + Clamav + OpenDKIM + OpenDMARC</title>
		<link>https://g1fef.co.uk/centos-7-postfix-amavisd-new-clamav/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sun, 28 May 2017 16:55:39 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=96</guid>

					<description><![CDATA[How to setup Postfix, Amavisd-new, Clamav, OpenDKIM &#038; OpenDMARC on Centos 7 Just in case, remove sendmail and install postfix: yum remove sendmail yum install postfix Make sure it starts on reboot: systemctl enable postfix Install amavis and clamav and make sure it starts on reboot: yum install amvisd-new clamav clamav-scanner-systemd systemctl enable amavisd Fix [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to setup Postfix, Amavisd-new, Clamav, OpenDKIM &#038; OpenDMARC on Centos 7</h4>
<p><span id="more-96"></span></p>
<ol>
<li style="list-style-type: none">
<ol>Just in case, remove sendmail and install postfix:</ol>
</li>
</ol>
<pre class="SCREEN">yum remove sendmail
yum install postfix
</pre>
<p>Make sure it starts on reboot:</p>
<pre class="SCREEN">systemctl enable postfix
</pre>
<p>Install amavis and clamav and make sure it starts on reboot:</p>
<pre class="SCREEN">yum install amvisd-new clamav clamav-scanner-systemd
systemctl enable amavisd
</pre>
<p>Fix the issue with clamd not starting:</p>
<pre class="SCREEN">cd /usr/lib/systemd/system
cp clamd\@scan.service clamd\@amavisd.service

systemctl start clamd@amavisd
systemctl enable clamd@amavisd
systemctl restart amavisd
</pre>
<p>Install OpenDKIM:</p>
<pre class="SCREEN">yum install opendkim
</pre>
<p>Create keys and check:</p>
<pre class="SCREEN">opendkim-default-keygen
cd /etc/opendkim/keys/
ll
</pre>
<p>Edit the following files:<br />
/etc/opendkim.conf (Main configuration file for opendkim)<br />
/etc/opendkim/KeyTable (Defines the path of private key for the domain)<br />
/etc/opendkim/SigningTable (Tells OpenDKIM how to apply the keys)<br />
/etc/opendkim/TrustedHosts (Defines which hosts are allowed to use keys)</p>
<p>If you&#8217;re just verifying incoming mail you don&#8217;t actually need to edit any of the above files, the defaults are fine.</p>
<p>Start and enable on reboot:</p>
<pre class="SCREEN">systemctl start opendkim
systemctl enable opendkim
</pre>
<p>Next you need to add the following lines to your Postfix main.cf</p>
<pre class="SCREEN">smtpd_milters = inet:127.0.0.1:8891
non_smtpd_milters = $smtpd_milters
milter_default_action = accept
</pre>
<p>and restart Postfix.</p>
<p>Now we can install OpenDMARC:</p>
<pre class="SCREEN">yum install opendmarc
</pre>
<p>Edit the file /etc/opendmarc.conf and uncomment the line<br />
# AuthservID name<br />
and set &#8220;name&#8221; to the hostname of your server.</p>
<p>Now enable it on reboot and fire it up:</p>
<pre class="SCREEN">systemctl enable opendmarc
systemctl start opendmarc
</pre>
<p>Now we need to hook it into Postfix, just add the port in main.cf as for opendkim above, i.e. the line in main.cf should now read:</p>
<pre class="SCREEN">smtpd_milters = inet:127.0.0.1:8891, inet:127.0.0.1:8893
</pre>
<p>This will pass incoming mail through OpenDKIM first, then OpenDMARC.</p>
<p>It&#8217;s a good idea to enable the PublicSuffixList in the opendmarc.conf file and create a weekly cronjob to keep the list up to date, so create the file /etc/cron.weekly/opendmarc</p>
<pre class="SCREEN">#!/bin/sh
#
#Get latest effective_tld_names for OpenDMARC
/usr/bin/wget --no-check-certificate -q -N -P /etc/opendmarc https://publicsuffix.org/list/effective_tld_names.dat
</pre>
<p>and restart Postfix.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting up a Galera MariaDB Cluster</title>
		<link>https://g1fef.co.uk/setting-galera-mariadb-cluster/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sat, 27 May 2017 05:58:55 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=89</guid>

					<description><![CDATA[How to setup a Galera MariaDB Cluster Remove any existing packages: yum remove maria* Update: yum update Add the official repo for MariaDB by creating the file /etc/yum.repos.d/MariaDB.repo [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 Now install MariaDB: yum install -y MariaDB-server MariaDB-client MariaDB-compat galera socat jemalloc Setup MariaDB: systemctl start mariadb mysql_secure_installation [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to setup a Galera MariaDB Cluster</h4>
<p><span id="more-89"></span></p>
<p>Remove any existing packages:</p>
<pre class="SCREEN">
yum remove maria*
</pre>
<p>Update:</p>
<pre class="SCREEN">
yum update
</pre>
<p>Add the official repo for MariaDB by creating the file /etc/yum.repos.d/MariaDB.repo</p>
<pre class="SCREEN">
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
</pre>
<p>Now install MariaDB:</p>
<pre class="SCREEN">
yum install -y MariaDB-server MariaDB-client MariaDB-compat galera socat jemalloc
</pre>
<p>Setup MariaDB:</p>
<pre class="SCREEN">
systemctl start mariadb
mysql_secure_installation
systemctl stop mariadb
</pre>
<p>To generate the CA certificate:</p>
<pre class="SCREEN">
openssl genrsa 2048 > ca-key.pem
openssl req -new -x509 -nodes -days 3600 -key ca-key.pem -out ca.pem
</pre>
<p>To generate the server certificate, remove passphrase, and sign it:</p>
<pre class="SCREEN">
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout server-key.pem -out server-req.pem
openssl rsa -in server-key.pem -out server-key.pem
openssl x509 -req -in server-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial -1 -out server-cert.pem
</pre>
<p>(Optional) To generate the client certificate, remove passphrase, and sign it:</p>
<pre class="SCREEN">
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout client-key.pem -out client-req.pem
openssl rsa -in client-key.pem -out client-key.pem
openssl x509 -req -in client-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem
</pre>
<p>Edit the file: /etc/my.cnf.d/server.cnf</p>
<pre class="SCREEN">
[sst]
encrypt=4
ssl-ca=/etc/pki/ca.pem
ssl-cert=/etc/pki/server-cert.pem
ssl-key=/etc/pki/server-key.pem

[galera]
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address='gcomm://a.a.a.a,b.b.b.b,c.c.c.c'
wsrep_cluster_name='cluster.name'
wsrep_node_address='10.0.0.11'
wsrep_node_name='node1'
wsrep_sst_method=rsync
wsrep_sst_receive_address='x.x.x.x'
wsrep_provider_options='socket.ssl_key=/etc/pki/server-key.pem;socket.ssl_cert=/etc/pki/server-cert.pem;socket.ssl_ca=/etc/pki/ca.pem;evs.inactive_timeout=PT45S;evs.install_timeout=PT45S;evs.keepalive_period=PT3S;evs.max_install_timeouts=8;evs.send_window=512;evs.suspect_timeout=PT30S;evs.user_send_window=256;'
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
</pre>
<p>In the file above the line &#8220;wsrep_sst_receive_address=&#8217;x.x.x.x'&#8221; is required if any of the nodes are behind a NAT router on private IP addresses, where x.x.x.x is the public IP address of the router. Without this SST donors will try to send snapshot data to the nodes private IP address which will invariably fail.</p>
<p>The &#8220;wsrep_provider_options&#8221; are tailored to for nodes that talk to each other over a WAN (i.e. the internet). If your nodes are all on the same LAN then you can leave this option out completely &#8211; it adjusts some timeout default values to better cope with varying connectivity quality across a WAN.</p>
<p>Start the primary node:</p>
<pre class="SCREEN">
galera_new_cluster
</pre>
<p>Start the other nodes:</p>
<pre class="SCREEN">
systemctl start mariadb
</pre>
<p>Login to any of the nodes and check status:</p>
<pre class="SCREEN">
show status like 'wsrep%';
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Update MediWiki</title>
		<link>https://g1fef.co.uk/update-mediwiki/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Thu, 11 May 2017 12:42:26 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=82</guid>

					<description><![CDATA[How to update MediaWiki Put wiki into readonly mode by editing the LocalSettings.php file and adding the line: $wgReadOnly = 'Wiki is currently undergoing maintenance, as a result it is in read only mode for a while'; Backup the SQL database, e.g. mysqldump -h host -u wiki -p wiki > wiki.sql Backup the entire wiki [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to update MediaWiki</h4>
<p><span id="more-82"></span></p>
<p>Put wiki into readonly mode by editing the LocalSettings.php file and adding the line:</p>
<pre class="SCREEN">
$wgReadOnly = 'Wiki is currently undergoing maintenance, as a result it is in read only mode for a while';
</pre>
<p>Backup the SQL database, e.g. mysqldump -h host -u wiki -p wiki > wiki.sql</p>
<p>Backup the entire wiki folder:</p>
<pre class="SCREEN">
mkdir backups/20170218
cp -rp http/* backups/20170218/.
</pre>
<p>Download latest version of MediaWiki from www.mediawiki.org/wiki/Download e.g.</p>
<pre class="SCREEN">
wget https://releases.wikimedia.org/mediawiki/1.28/mediawiki-1.28.2.tar.gz
</pre>
<p>Unpack the file over the existing installation:</p>
<pre class="SCREEN">
tar zxvf mediawiki-1.28.2.tar.gz -C http/w --strip-components=1
</pre>
<p>Now run the update:</p>
<pre class="SCREEN">
cd http/w/maintenance
php update.php
</pre>
<p>Don&#8217;t forget to take it out of readonly mode by removing or commenting out the $wgReadOnly line in LocalSettings.php</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Interacting with certbot non-interactively</title>
		<link>https://g1fef.co.uk/interacting-certbot-non-interactively/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Tue, 09 May 2017 13:40:03 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=78</guid>

					<description><![CDATA[Command line parameters for the LetsEncrypt certbot script The letsencrypt python script called cartbot does all the hard work for you, it can request a new certificate, renew existing certificates, revoke and delete certificates. It can do ths from the command line interactively, i.e. asking you questions when it needs to, or non-interactively so you [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>Command line parameters for the LetsEncrypt certbot script</h4>
<p><span id="more-78"></span></p>
<p>The letsencrypt python script called cartbot does all the hard work for you, it can request a new certificate, renew existing certificates, revoke and delete certificates. It can do ths from the command line interactively, i.e. asking you questions when it needs to, or non-interactively so you can use it in scripts. Here are some useful commands in the non-interactive mode:</p>
<p>Revoke a certificate</p>
<pre class="SCREEN">
certbot -n revoke --cert-path /etc/letsencrypt/live/www.example.com/cert.pem
</pre>
<p>Request a new certificate</p>
<pre class="SCREEN">
certbot certonly -d www.g1fef.co.uk --webroot --webroot-path /path/to/web/docs/
</pre>
<p>Delete a certificate</p>
<pre class="SCREEN">
certbot -n delete --cert-name www.example.com
</pre>
<p>Don&#8217;t forget to restart your webserver, especially after you revoke or delete a certificate!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Update Cacti</title>
		<link>https://g1fef.co.uk/update-cacti/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sun, 16 Apr 2017 14:00:19 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=74</guid>

					<description><![CDATA[How to upgrade Cacti to the latest version Here we are assuming that the current installation in in the directory &#8216;https&#8217; and the new version we are installing is cacti-1.1.3 First of all download the latest version: http://www.cacti.net/downloads/cacti-latest.tar.gz Unpack it: tar zxvf cati-latest.tar.gz Edit the config file to set the database access correctly: cd cacti-1.1.3/include [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to upgrade Cacti to the latest version</h4>
<p><span id="more-74"></span></p>
<p>Here we are assuming that the current installation in in the directory &#8216;https&#8217; and the new version we are installing is cacti-1.1.3</p>
<p>First of all download the latest version:</p>
<p><a href="http://www.cacti.net/downloads/cacti-latest.tar.gz">http://www.cacti.net/downloads/cacti-latest.tar.gz</a></p>
<p>Unpack it:</p>
<p>tar zxvf cati-latest.tar.gz</p>
<p>Edit the config file to set the database access correctly:</p>
<p>cd cacti-1.1.3/include</p>
<p>vim config.php</p>
<ol type="1">
<li>
<pre class="SCREEN">
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";
</pre>
</li>
<li>
<pre class="SCREEN">
$url_path = '/';
</pre>
</li>
</ol>
<p>Copy the *.rrd files from the old Cacti directory to the new one.</p>
<pre class="SCREEN">
cp -rp https/rra/* cacti-1.1.3/rra/
</pre>
<p>Copy any relevant custom scripts from the old Cacti directory to the new one.</p>
<pre class="SCREEN">
cp -u https/scripts/* cacti-1.1.3/scripts/
</pre>
<p>Copy any relevant custom resource XML files from the old Cacti directory to the new one.</p>
<pre class="SCREEN">
cp -u -R https/resource/* cacti-1.1.3/resource/
</pre>
<p>Set the appropriate permissions on Cacti&#8217;s directories for graph/log generation.</p>
<pre class="SCREEN">
cd cacti-1.1.3
chown -R cactiuser rra/ log/
cd ..
</pre>
<p>Move your old installation away:</p>
<pre class="SCREEN">
mv https https-old
</pre>
<p>Move your new installation in:</p>
<pre class="SCREEN">
mv cacti-1.1.3 https
</pre>
<p>Point your web browser to your cacti URL and follow the instructions.</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GNU screen scrollback and other navigation</title>
		<link>https://g1fef.co.uk/gnu-screen-scrollback-navigation/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sun, 16 Apr 2017 13:25:33 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=65</guid>

					<description><![CDATA[GNU screen commands The GNU screen program has some useful navigation facilities. To enter COPY MODE you need to press CTRL + A + [ Once in copy mode use the keys below to navigate: h Move the cursor left by one character j Move the cursor down by one line k Move the cursor [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>GNU screen commands</h4>
<p><span id="more-65"></span></p>
<p>The GNU screen program has some useful navigation facilities. To enter COPY MODE you need to press CTRL + A + [</p>
<p>Once in copy mode use the keys below to navigate:</p>
<table class="table table-hover">
<tbody>
<tr>
<td>h</td>
<td>Move the cursor left by one character</td>
</tr>
<tr>
<td>j</td>
<td>Move the cursor down by one line</td>
</tr>
<tr>
<td>k</td>
<td>Move the cursor up by one line</td>
</tr>
<tr>
<td>l</td>
<td>Move the cursor right by one character</td>
</tr>
<tr>
<td>0</td>
<td>Move to the beginning of the current line</td>
</tr>
<tr>
<td>$</td>
<td>Move to the end of the current line</td>
</tr>
<tr>
<td>G</td>
<td>Moves to the specified line</td>
</tr>
<tr>
<td>C-u</td>
<td>Scrolls a half page up</td>
</tr>
<tr>
<td>C-b</td>
<td>Scrolls a full page up</td>
</tr>
<tr>
<td>C-d</td>
<td>Scrolls a half page down</td>
</tr>
<tr>
<td>C-f</td>
<td>Scrolls the full page down</td>
</tr>
</tbody>
</table>
<p>When starting screen you can set the size of the scrollback buffer by using the -h command line argument, for example to set the scrollback buffer to 1000 lines:</p>
<p>screen -h 1000</p>
<p>This can also be set in .screenrc with defscrollback</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Backup and Restore a running KVM guest</title>
		<link>https://g1fef.co.uk/live-snapshot-of-running-kvm-guest/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Thu, 16 Mar 2017 14:11:55 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=23</guid>

					<description><![CDATA[How to backup and restore a running KVM guest on the command line If you need to update the software: wget http://resources.ovirt.org/pub/yum-repo/ovirt-release36.rpm yum localinstall ovirt-release36.rpm yum update -y Backup the VM: Assuming a guest called &#8220;test&#8221;, list location of VM: virsh domblklist test Export the XML data that defines the VM: virsh dumpxml test &#62; [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to backup and restore a running KVM guest on the command line</h4>
<p><span id="more-23"></span></p>
<h3>If you need to update the software:</h3>
<pre class="lang:bash">wget http://resources.ovirt.org/pub/yum-repo/ovirt-release36.rpm
yum localinstall ovirt-release36.rpm
yum update -y
</pre>
<h3>Backup the VM:</h3>
<p>Assuming a guest called &#8220;test&#8221;, list location of VM:</p>
<pre class="lang:bash">virsh domblklist test</pre>
<p>Export the XML data that defines the VM:</p>
<pre class="lang:bash">virsh dumpxml test &gt; test.xml</pre>
<p>Take the snapshot:</p>
<pre class="lang:bash">virsh snapshot-create-as --domain test NAME_OF_SNAPSHOT --diskspec vda,file=/tmp/snapshot_test.qcow2 --disk-only --atomic --no-metadata
</pre>
<p>Guest is now running in /tmp/snapshot_test.qcow2</p>
<p>Copy XML and original data file to where you need it.</p>
<p>Pivot back to original:</p>
<pre class="lang:bash">virsh blockcommit test vda --active --verbose --pivot</pre>
<h3>Restore the VM:</h3>
<p>Copy the .qcow2 file into place.</p>
<p>Creating a new vm:</p>
<pre class="lang:bash">virsh define /path/to/your/xml/test.xml
</pre>
<p>Check it is present:</p>
<pre class="lang:bash">virsh list --all
</pre>
<p>Start the vm:</p>
<pre class="lang:bash">virsh start test
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
