Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Friday, May 30, 2008

Setup multiple IP addresses on Ubuntu

I'm working on migrating a server again today and we decided that we want to put some of the services on 1 IP and the others on another so if we ever need to move one set of services over the IP can follow. This is the machine that is running Ubuntu 8.04 Server.

It turns out this is a pretty simple thing to do. First, edit your interfaces file:

sudo nano -w /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

Then add in a few new lines below the eth0 section to create a new virtual interface:
auto eth0:0
iface eth0:0 inet static
address 10.10.10.200
netmask 255.255.255.0
Then restart your networking:

$ sudo /etc/init.d/networking restart

And there you have it, your new virtual interface with your new IP.

$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:1d:09:15:74:af
inet addr:10.10.10.122 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::21d:9ff:fe15:74af/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:52 errors:0 dropped:0 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9780 (9.5 KB) TX bytes:5388 (5.2 KB)
Interrupt:17

eth0:0 Link encap:Ethernet HWaddr 00:1d:09:15:74:af
inet addr:10.10.10.200 Bcast:10.10.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:17

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:38081 errors:0 dropped:0 overruns:0 frame:0
TX packets:38081 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1614360 (1.5 MB) TX bytes:1614360 (1.5 MB)

Thanks go to NukeSilo.com for getting me started and the Debian guide on Network configuration for all the details.

Thursday, May 15, 2008

Backup and restore a MySQL database using mysqldump

Today I am working on migrating some web apps to a new server. The old server was running Fedora Core 1 (yeah, really old) and the new box is running Ubuntu 8.04 server edition. (This is the first time I have ever used the server version. A coworker chose the distribution. I think I would have gone with CentOS (a RHEL clone) but it will be nice to play with Ubuntu server too. I am not some super Ubuntu fanboy!)

So I am moving a MediaWiki 1.5 installation (you know, the software that runs Wikipedia) and upgrading it to 1.12. Copying the files and upgrading proved to be pretty simple and painless so far as I can tell but backing up and restoring the MySQL DB between version 3.23.58 and 5.0.51a got me a little concerned. I wanted to copy over an archive of the /var/lib/mysql/mediawiki db data directory and restart MySQL but that didn't work. It has in the past when going from a 3.x to a 4.x but I may have been pushing my luck even then too.

The best way I found to do this though is to use mysqldump. I have used this before but I always forget all the syntax (which is why I am writing this post). mysqldump will spit out SQL statements to recreate your database and reinsert all the data. The problem with that is you then have a gigantic .sql file that you have to import into your new database. That feels a lot less foolproof to me than if just copying the data directory would (had it worked).

Anyway, to backup your database with mysqldump, do this:

$ mysqldump -u root -p DBNAME > DBNAME.sql

And then to restore that, do this:

$ mysql -u root -p
mysql>CREATE DATABASE NEW_DBNAME;
mysql> \q
Bye
$ mysql -u root -p NEW_DBNAME <>

There you have it. There is also the option to use msqlhotcopy but I didn't bother with it.

Other tutorials and thoughts: