Project 4 - RichardSwierk/SEC-440 GitHub Wiki

U1 config

sudo adduser richard.swierk --force-badname
sudo usermod -aG sudo richard.swierk
sudo nano /etc/netplan/99_config.yaml
ip= 10.0.5.110/24
sudo netplan apply
sudo apt-get update
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring keepalived --yes
sudo nano /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state MASTER
interface ens160
virtual_router_id 71
priority 255
advert_int 1
authentication {
auth_type PASS
auth_pass Ch@mpl@1n!21
}
virtual_ipaddress {
10.0.5.115/24
}
}
sudo service keepalived start
cd /tmp/ && wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.0.tar.gz
tar -xvzf /tmp/mediawiki-*.tar.gz
sudo mkdir /var/www/html/mediawiki
sudo mv mediawiki-*/* /var/www/html/mediawiki
sudo chown -R 755:www-data /var/www/html/
sudo mysql -u root -p
CREATE DATABASE SEC440;
CREATE USER 'mediawikiuser'@'localhost' IDENTIFIED BY 'new_password_here';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'mediawikiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
sudo nano /etc/apache2/sites-available/mediawiki.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/mediawiki/
ServerName u1-richard.com
ServerAlias www.u1-richard.com
ErrorLog ${APACHE_LOG_DIR}/error.log

sudo a2ensite mediawiki.conf
sudo a2dissite 000-default.conf
sudo service apache2 restart
Then connect to 10.0.5.110 from xubuntu-lan to finish configuration
sudo nano /etc/mysql/conf.d/mysql.cnf
[mysqld]
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
sudo service mysql restart
sudo mysql -u root -p
CREATE USER 'slave_user'@'%' identified by 'password';
GRANT REPLICATION slave ON *.* 'slave_user'@'%'; EXIT;
mysqldump -u root -p --opt SEC440 > SEC440.sql
sudo scp SEC440.sql [email protected]:/home/richard.swierk

U2 config

sudo adduser richard.swierk --force-badname
sudo usermod -aG sudo richard.swierk
sudo nano /etc/netplan/99_config.yaml
ip=10.0.5.111/24
sudo netplan apply
sudo apt-get update
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring keepalived --yes
sudo nano /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state BACKUP
interface ens160
virtual_router_id 71
priority 254
advert_int 1
authentication {
auth_type PASS
auth_pass Ch@mpl@1n!21
}
virtual_ipaddress {
10.0.6.5/24
}
}
sudo service keepalived start
sudo mysql -u root -p
CREATE DATABASE SEC440;
CREATE USER 'mediawikiuser'@'localhost' IDENTIFIED BY 'new_password_here';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'mediawikiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
sudo mysql -u root -p SEC440 < SEC440.sql
sudo nano /etc/mysql/conf.d/mysql.cnf
[mysqld]
server-id = 2
relay-log = /var/log/mysql/mysql-relay-bin.log
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = newdatabase
sudo service mysql restart
sudo mysql -u root -p
CHANGE MASTER TO MASTER_HOST='10.0.5.110',MASTER_USER='slave_user', MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=156;
START SLAVE;
EXIT;

Reflection

  1. Problem I had was setting up the redundacy with the virtual ip. For some reason it was not working and then I am not sure why it started to work. Next time I might try to use a different software then keepalived for the virtual ip address

  2. I could not get the master and slave database to work. The slave would not get new data from the Master. I could try to user mariadb instead of just using mysql