Virtual MusicBrainz Server: Difference between revisions

From MusicBrainz Wiki
Jump to navigationJump to search
((Imported from MoinMoin))
 
m (Redirecting to MusicBrainz Server/Setup)
 
(41 intermediate revisions by 14 users not shown)
Line 1: Line 1:
#REDIRECT [[MusicBrainz Server/Setup]]
<small>[[Products]] > [[Server]] > [[Server Development|Server development]] > [[Server Setup|Server setup]] > Virtual MusicBrainz Server </small>

==What Is the Virtual MusicBrainz Server?==

The Virtual [[MusicBrainz]] Server is a virtual machine image containg a Linux environment fully configured with the latest release of the mb_server source code. If you want to experiment with the data, or try hacking on some new features, it is intended to be the fastest way to get up and running.

The image is built using VMWare Workstation, and can be run in the free [http://www.vmware.com/player/ VMWare Player] or [http://www.vmware.com/server/ VMWare Server] software. On the PC you're intending to run VMWare, you need at least 512Mb of RAM and at least 10Gb of free disk space.

==What's in the Image?==

The virtual server is running the base [[WikiPedia:Debian|Debian]] unstable installation, fully patched as of the time of release. It also includes pre-configured versions of Apache, mod_perl, all the perl dependencies, and Postgresql.

There is a full check-out of the latest [[MusicBrainz]] server release, and an empty [[MusicBrainz]] database.

[TODO: Explain disk partitions. 4Gb root, 10Gb data. vmdx files will expand]

==Running the Virtual MusicBrainz Server==

===Before you begin===

# Download [http://www.vmware.com/products/player VMWare Player] or [http://www.vmware.com/products/beta/fusion/ VMWare Fusion Beta] for Mac OS-X and follow the instructions for installing and setting it up.
# Download the Virtual [[MusicBrainz]] Server image from [ftp://ftp.musicbrainz.org/pub/musicbrainz/MBServer-20060712.tar.bz2 ftp://ftp.musicbrainz.org/pub/musicbrainz/MBServer-20060712.tar.bz2]. To extract it in Windows, you can use [http://www.7-zip.org/ 7-Zip]. From the .bz2 you will extract a .tar from which you will extract the VMware files themselves. You can remove the .tar file now. Linux users can use <code><nowiki>tar xvjf MBServer-20060712.tar.bz2</nowiki></code>.

===First run===

# Start the virtual machine in VMWare: run VMware, then navigate to the folder where you extracted the VMware files and choose MBServer. VMware will now boot Linux in a virtual machine. Wait until you get the prompt: "brainzvm login:" (If you get asked about changing the virtual image ID, select "Create new ID")
# There are two users on the system with passwords: "root" and "mbserver". '''By default, the user passwords are the same as the usernames.''' So the first thing to do is login as root, and change the passwords to something a smidge more secure.

<pre>brainzvm:~# passwd root
Enter new UNIX password: [enter a new password]
Retype new UNIX password: [repeat it]
passwd: password updated successfully
brainzvm:~# passwd mbserver
Enter new UNIX password: [enter a new password]
Retype new UNIX password: [repeat it]
passwd: password updated successfully
</pre>
# Make sure you have an internet connection inside your virtual machine by pinging Google. (This may fail if you're behind a firewall that blocks pings.)

<pre>brainzvm:~# ping -c 3 google.com
PING google.com (216.239.37.99) 56(84) bytes of data.
64 bytes from 216.239.37.99: icmp_seq=1 ttl=244 time=17.3 ms
64 bytes from 216.239.37.99: icmp_seq=2 ttl=244 time=17.9 ms
64 bytes from 216.239.37.99: icmp_seq=3 ttl=244 time=8.85 ms

--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2029ms
rtt min/avg/max/mdev = 8.854/14.718/17.950/4.153 ms
</pre>
# If this works, find out what IP address is assigned to your virtual server by running ifconfig.

<pre>brainzvm:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:62:7F:57
inet addr:192.168.213.42 Bcast:192.168.213.255 Mask:255.255.255.0
[ ^^^^^^^^^^^^^^ this is the address you care about ]
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[snip]
</pre>
# '''BUG FIX''': As root run <code><nowiki>chmod 777 ~mbserver/svn/mb_server</nowiki></code>
# Outside of your virtual machine, open a webbrowser and try accessing the virtual IP address as [http://ipaddress/ http://ipaddress/]. You should see the [[MusicBrainz]] homepage, but with a banner that reads "Virtual Server".
# Logout.

===Loading data===

# Outside the VM, ssh into it, as the mbserver user. (Windows users can use the excellent ssh client [http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY])
# In mbserver's home directory is a directory called ''svn''. This contains the latest [[MusicBrainz]] server code at the time of release. To make sure you have an up-to-date copy:

<pre>mbserver@brainzvm:~$ cd svn/mb_server
mbserver@brainzvm:~/svn/mb_server$ svn up
</pre>
# Now let's download the latest MB data dump. Use <code><nowiki> lynx http://ftp.musicbrainz.org/pub/musicbrainz/data/fullexport/ </nowiki></code>, go into the latest folder and get the ''mbdump.tar.bz2'', ''mbdump-derived.tar.bz2'' and ''mbdump-stats.tar.bz2'' files. (You can grab the other files if you want, but the data they contain is stuff like old moderations; Nothing necessary to get your server up and running) Save them to the mbserver home directory then press 'q' to exit lynx.
# Stop apache, drop the empty musicbrainz database, and import these dumps:

<pre>mbserver@brainzvm:~$ su -
Password:
brainzvm:~# /etc/init.d/apache-perl stop
Stopping web server: apache-perl.
brainzvm:~# exit

mbserver@brainzvm:~$ cd svn/mb_server
mbserver@brainzvm:~/svn/mb_server$ dropdb -U postgres musicbrainz_db
DROP DATABASE
mbserver@brainzvm:~/svn/mb_server$ perl ./admin/InitDb.pl --createdb --echo --import ~/mbdump*.tar.bz2
<snip> -- Go get some coffee and a book, cause this'll take at least an hour to run.
Fri Oct 21 21:11:56 2005 : Initialized and imported data into the database.
Fri Oct 21 21:11:56 2005 : InitDb.pl succeeded
mbserver@brainzvm:~$ su -
Password:
brainzvm:~# /etc/init.d/apache-perl start
Starting web server: apache-perl.
brainzvm:~# exit

</pre>
<ul><li style="list-style-type:none">If there appears a syntax error in apache-perl start command, you might want to edit the server name:
</ul>

<pre>brainzvm:~# editor /etc/apache-perl/conf.d/vh_httpd.conf
</pre>
<ul><li style="list-style-type:none">Then search for Servername and [[Server Alias|ServerAlias]] lines.
Going to [http://ipaddress/ http://ipaddress/] should now present you with your very own searchable [[MusicBrainz]] server. Hurrah!
</ul>

===Troubleshooting===

Depending on how much you filled up your virtual system disk, you might run into space problems - For example, if you import all the 6 bzipped dumps at once. In that case, you'd better move the dumps to the other virtual disk that's in the package, and create an alternative temporary dir under that same disk: <pre>mbserver@brainzvm:~/svn/mb_server$ mv ~/mbdump*.tar.bz2 /mnt/data

mbserver@brainzvm:~/svn/mb_server$ su -
Password:
brainzvm:~# mkdir /mnt/data/tmp
brainzvm:~# chmod 777 /mnt/data/tmp
brainzvm:~# exit
</pre>

... and after doing that, the command for importing would become: <code><nowiki> mbserver@brainzvm:~/svn/mb_server$ perl ./admin/InitDb.pl --createdb --echo --import -- --tmp-dir=/mnt/data/tmp /mnt/data/mbdump*.tar.bz2 </nowiki></code>

===Hacking on the code===

[TODO: Link to some developer documentation]

===Working with the database===

[TODO: Write something here about access Postgresql from other tools]

===Setting up your server as a replication "Master"===

As root, <pre># edit /etc/apt/sources.list and uncomment the `deb-src` line

apt-get update
apt-get install postgresql-server-dev-8.1
apt-get source postgresql-contrib-8.1
cd ~/postgresql-8.1-8.1.4
tar jxf postgresql-8.1.4.tar.bz2
cd postgresql-8.1.4/contrib/dbmirror
wget ftp://ftp.musicbrainz.org/pub/musicbrainz/dbmirror-7.4-compat.patch
patch -p0 < dbmirror-7.4-compat.patch
make USE_PGXS=1
cp -av pending.so /usr/lib/postgresql/8.1/lib/pending-7.4-compat.so
</pre>

Edit <code><nowiki>DBDefs.pm</nowiki></code> and set REPLICATION_TYPE to RT_MASTER.

If you haven't yet run <code><nowiki>InitDb.pl</nowiki></code>, simply make sure that when you do so, you add <code><nowiki>--with-pending=/usr/lib/postgresql/8.1/lib/pending-7.4-compat.so</nowiki></code> .

If you have already run <code><nowiki>InitDb.pl</nowiki></code> (and therefore have a "standalone" database", proceed as follows (as the user "mbserver"): <pre>brainzvm:/home/mbserver/svn/mb_server# ./admin/psql SYSTEM
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

template1=# \c musicbrainz_db
You are now connected to database "musicbrainz_db".
musicbrainz_db=# CREATE FUNCTION "recordchange" () RETURNS trigger AS '/usr/lib/postgresql/8.1/lib/pending-7.4-compat.so', 'recordchange' LANGUAGE 'C';
CREATE FUNCTION
musicbrainz_db=# \q
brainzvm:/home/mbserver/svn/mb_server# ./admin/psql READWRITE < admin/sql/CreateReplicationTriggers.sql
SET
BEGIN
CREATE TRIGGER
CREATE TRIGGER
...
CREATE TRIGGER
CREATE TRIGGER
COMMIT
brainzvm:/home/mbserver/svn/mb_server#
</pre>

===Comments===

----


Author: [[User:RodBegbie|RodBegbie]]
[[Category:To Be Reviewed]] [[Category:Development]]

Latest revision as of 01:35, 11 November 2011