Tuesday 14 January 2014

How to move mysql to backend server

This is a great solution to off-load struggling server under load:

On backend server:


nano /etc/network/interfaces

#add following
auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
mtu 9000


Don't forget to assign permissions to the front-end user:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON mydb.* TO 'myuser'@'192.168.1.2' IDENTIFIED BY 'supersecretpassword';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON mydb.* TO 'myuser'@'192.168.1.2.localdomain' IDENTIFIED BY 'supersecretpassword';
FLUSH PRIVILEGES;
quit;

To allow packet comming through:
iptables -A INPUT -i eth1 -s 192.168.1.2 -p tcp --destination-port 3306 -j ACCEPT

service networking restart


On frontend server:

 nano /etc/network/interfaces

#add follwing
auto eth1
iface eth1 inet static
address 192.168.1.2
netmask 255.255.255.0
mtu 9000
Check whether you can connect to the backend:

mysql -u myuser -h 192.168.1.1  -p

service networking restart

 et voila!

thanks:
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html


No comments:

Post a Comment