Uploaded by stinky.dinky.ps3

APL701 Project 3.docx.docx

advertisement
Table of Contents
APL 701 NA A
PROJECT 03
DATA BACKUP
2019 | APL 701 NA A
1
2
Installing
Installing mysql server on linux server(ABC co)
Open terminal and login as root. Then get the mysql repository and prepare it for the next step.
Run the command “yum –y install mysql-server” start the installation. It should take a few minutes to finish installing.
After enter commands “systemctl start mysqld” and “systemctl enable mysqld” so that msql starts up and will the next
time the server is turned on. Use “systemctl status mysqld” to confirm the changes.
3
Run command “cat /var/log/mysqld.log” to find out what the temporary root password for the mysql database was set
to. It was V=KjclrUt70k is this case.
4
Do the following to change the mysql root user’s password to something else.
5
Now that the root password has been changed, run the server setup script with command “mysql_secure_installation
utility”. Say yes to remove anonymous users, remove the test database and reload the privilege tables.
You also need to allow iptables to allow for mysql server. By default mysql uses port 33306. Use something like command
“iptables -I INPUT -p tcp --dport 3306 -s 192.168.1.1 -j ACCEPT” to allow mysql traffic from the windows server.
Installing mysql server on windows server (Big Guy co)
Might need to update Microsoft .NET Framework as prerequisite. Download from official Microsoft source and run the
package.
6
Also might have to install Microsoft visual studio C ++ redistributable. Do the same as before and download the package
off of official Microsoft sources, then run the package to install.
Then download and run the MySQL installer. It will ask what components to install. Just select server and press next.
After the installation complete, you will have to configure the server. First select standalone MySQL Server and press
next. Configure the type and networking section to be similar to the following settings.
7
Press next for the authentication method section. For the account and roles section setup a root password and an
admin account. “password” was used for the passwords in this section.
8
Press next for the windows service section and then execute on the following page to finish the setup. This might take a
bit of time to fully configure.
Setup ABC linux server as the master server for replication
On the ABC linux server, stop the mysql service with “stystemctl stop mysqld”. Then edit the mysql server config file
located in “/etc/my.cnf”. Make the following changes:
9
CHANGE SETTINGS(PROBABLY USING DIFFERENT)
Then restart the server with command “systemctl restart mysqld”. The changes made was setting this server to be the
master with server id 1. The log bin line is the file that all changes to the database will be logged to. Binlog is the
database that everything will be copied to on the slave.
Sign back in to the mysql server and run the following commands to create a user for the slave server and grant
replication rights to it.
10
Create the database “newdatabase” and switch to using it.
11
Exit to terminal and use the command “mysqldump -u root -p --opt newdatabase > newdatabase.sql” to dump the
current database into a file. Then go back into the mysql server and use command “UNLOCK TABLES” to make the tables
writable again.
12
Setup Big Guy windows server as slave server for replication
Copy over the newdatabase sql file from the linux server. Then create the database from the dump using “mysql –u root
–p newdatabase < C:/Users/Administrator/newdatabase.sql”
Type “services.msc” into run and stop the mysql service for now. Edit the mysql config file located at
“C:\ProgramData\MySQL\MySQL Server 8.0\my.ini”. Use the following settings:
Restart the mysql service.
13
NEED TO FINISH
Transfer database files from secondary server to data server
An easy way to automate database backup files and to transfer them to another server would be to create a script and
set it to run in windows task scheduler. In this case the script will be done in PowerShell. Windows server 2008 R2 does
not have PowerShell ISE enabled by default. To use it just open PowerShell and type in the following commands:
14
On the main Windows server and the secondary windows server, powershell remoting must be enable so that the copy
script can run. Open powershell as Administrator and enter the command Enable-PsRemoting – force.
The script we are using for the transfer is designed to create a SQL dump file from the slave server’s replicated database
and names it based on when the script ran. It then opens a powershell remote session to the storage server and copies it
over to a designated folder.
Replication Monitor Script
A way to monitor the replication process between the master and slave MySQL servers is to create a simple script to run
MySQL commands. Ideally the administrator would run it on the Master server machine and would save the admin a
little bit of time when checking the status of the replication process. The script asks the user for an input to select which
MySQL command to run. The options are the following: run “Show slave status”, “Show slave hosts”, “Show Tables” or
just exit the script. However, it would be more effective to just install and use one of many dedicated monitoring tools.
15
16
17
Download