QA/Sync/Sync Server Install On Ubuntu 11 04

From MozillaWiki
< QA‎ | Sync
Jump to: navigation, search

Back To ==> Mozilla BT Services


Installing Sync Server on Ubuntu 11.04 64-Bit

ISO Source

http://releases.ubuntu.com/

Example: http://releases.ubuntu.com/natty/ubuntu-11.04-desktop-amd64.iso

Using Python 2.7

The default version of Python on Ubuntu 11.04 is 2.7.1+

Sync Server assumes a python version of 2.6.6, but newer versions can be used for testing purposes.

If you want to install a local copy of Python 2.6.6 to match the Sync Server requirements, you can follow these basic steps:

  1. Install Python 2.6.6 in a local or public directory
  2. Create a symbolic link from /usr/bin/python2.6 to the bin/python2.6 file in the local install folder
Example:
/usr/bin/python2.6 -> /home/mozilla/python2.6.6/bin/python2.6
  1. Install the python virtualenv for 2.6.6
  2. Create a symbolic link from /usr/bin/virtualenv-2.6 to the bin/virtualenv file in the install folder
Example:
/usr/bin/virtualenv-2.6 -> /home/mozilla/python2.6.6/bin/virtualenv

Pre-Installed Packages

The following applications should already be installed on Ubuntu 11.04:

  • FireFox
  • Python
  • make
  • gcc
$ firefox -V
Mozilla Firefox 5.0
$ python -V
Python 2.7.1+
$ which make
/usr/bin/make
$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
$ which gcc
/usr/bin/gcc
$ gcc --version
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Required Packages

The following packages are required before installing Sync Server:

  • Mecurial
  • Sqlite3
  • make
  • gcc

The following packages are optional, but highly recommended:

  • MySQL-Server
$ which hg
$ which sqlite3
$ which mysql

Media:Ubuntu11_04BeforeSnapshot.jpg


Install Python Tools and Developer Tools

$ cd $home
$ which python
/usr/bin/python
$ python -V
Python 2.7.1+

So, you need to install the Python Tools, Developer Tools, and the virtualenv for 2.7

$ sudo apt-get install python-dev python-virtualenv

And, then the rest of the Python Tools:

$ sudo apt-get install curl
$ curl -O http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py
$ sudo easy_install-2.7 MoPyTools

Media:Ubuntu11_04Output1.pdf


Install Mercurial and Sqlite3

The sqlite3 install is good for quick testing the Sync Server.

$ which hg
/usr/bin/hg
$ hg --version
Mercurial Distributed SCM (version 1.7.5)
(see http://mercurial.selenic.com for more information)
Copyright (C) 2005-2010 Matt Mackall and others
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which sqlite3
/usr/bin/sqlite3
$ sqlite3 --version
3.7.4

Media:Ubuntu11_04Output2.pdf


Install MySQL-Server and the Client Library

The client library install may actually be an optional step.

$ sudo apt-get install mysql-server
Note: installer should ask for a root password for MySQL-Server
$ which mysql
/usr/bin/mysql
$ mysql --version
mysql  Ver 14.14 Distrib 5.1.54, for debian-linux-gnu (x86_64) using readline 6.2
$ ps aux | grep sql
mysql    15793  0.1  4.8 170304 24252 ?        Ssl  16:43   0:00 /usr/sbin/mysqld
mozroot  15890  0.0  0.2  13124  1048 pts/0    S+   16:45   0:00 grep --color=auto sql

And now the (optional) client library:

$ sudo apt-get install libmysqlclient-dev

Media:Ubuntu11_04Output3.pdf


Clone and Build the Sync Server

Clone and build the Sync Server in your home directory, or in some other directory if it will be used by others:

$ cd $home
$ hg clone https://hg.mozilla.org/services/server-full
$ cd server-full
$ make build

Media:Ubuntu11_04ServerInstall1.jpg

Finally, install MySQL-Python:

$ cd server-full
$ bin/easy_install Mysql-Python

Media:Ubuntu11_104MySqlPython.jpg


Configure the Sync Server for sqlite3

Configure server-full/etc/sync.conf to use sqlite3 for quick testing.

Change the default db file and directory in the sync.conf file:
$ cd server-full
$ vi etc/sync.conf
Change the following two lines:
From: sqluri = sqlite:////tmp/test.db
To: sqluri = sqlite:////home/<YOUR HOME>/sync.db
(or to some other directory outside of /tmp)


Start and Verify the Sync Server

Start up the Sync Server (from the server-full directory)

$ bin/paster serve development.ini

Verify the server is up and running:

Starting server in PID <SOME PID>.
serving on 0.0.0.0:5000 view at http://127.0.0.1:5000

Media:Ubuntu11_04ServerStartup.jpg


Check the Sync Server host using curl:

Open a new terminal window:
$ curl http://127.0.0.1:5000
This should return a 404 error if it is working correctly
(the 404 Not Found error will be within some html returned to STDOUT/STDERR)
Alternatively:
$ curl http://127.0.0.1:5000 > check.html

Check the Sync Server host using HTTP:

From an open browser:
http://127.0.0.1:5000/user/1.0/a
This should return a '0' if it is working correctly

Media:Ubuntu11_04ServerTest.jpg


Both of these should generate Sync Server INFO messages to STDOUT/STDERR (from the terminal running Sync Server).

Media:Ubuntu11_04ServerINFOMessages.jpg


Stop the Sync Server:

From the first terminal window:
Ctrl-C

Configure MySQL and the sync.conf file

Configure MySQL with a root password and add a test sync DB:

$ mysql -u root -p

If your MySQL install does not already have a root password, do the following:

mysql> UPDATE mysql.user set Password=PASSWORD('mozroot') WHERE User='root';
mysql> FLUSH PRIVILEGES

Now set up a sync db for testing:

mysql> CREATE DATABASE syncdb;
mysql> \quit

Configure server-full/etc/sync.conf to use MySQL for testing:

$ cd server-full
$ vi etc/sync.conf
Change the following two lines:
From: sqluri = sqlite:////<YOUR DIR>/sync.db
To: sqluri = mysql://root:<ROOT PWD>@localhost/<DB NAME>
Example for root password of "mozroot" and sync DB on localhaost (from above steps):
sqluri = mysql://root:mozroot@localhost/syncdb

Restart the Sync Server:

$ bin/paster serve development.ini

Notes: If you want to run the Sync Server outside of any login session, you can try the following:

$ nohup bin/paster server development.ini &


Running the Sync 1.1 Tests

  • Once the build is complete, you can run the test as follows
$ make test
  • If everything runs as expected, you should see the following:
bin/nosetests -s --with-xunit deps/server-core/services/tests
deps/server-reg/syncreg/tests deps/server-storage/syncstorage/tests
............................................................etc.......
----------------------------------------------------------------------
Ran 177 tests in 33.031s
OK
  • The tests are located in the following directories:
    • server-full/deps/*/*/tests
  • Note: Remember to cleanup after the test by deleted some db files in /tmp
rm /tmp/sync.db /tmp/tests*.db

Re-building and Re-deploying the Sync Server

To re-build and re-deploy the sync server, you can try these steps:

Kill the Sync Server process
$ kill -9 <Sync Server PID>
(Leave MySQL running)
Save the Sync Server directory and its contents
(this in case you want to keep various snapshots)
$ cd ..
(one level up from server-full directory)
$ mv server-full server-full-<DATE>
(example: mv server-full server-full-08012011
Repeat the build and deploy steps from above
Make the necessary changes in the server-full/etc/sync.conf file:
Change the sqluri entries
Restart the server

Redeploying a Live Server

  • The following steps can be used to redeploy a live sync server
$ cd /path/to/server-full
$ hg pull -uv
$ make build
$ apachectl graceful
  • This should be sufficient, as "make build" will pull and update the repositories underneath the "deps" directory.
  • There is also a "make update" target which will update only the dependent repositories, without rebuilding any of the third-party dependencies from PyPi.
  • Also note that the Makefile will build the production channel by default, meaning this will not update you to the very latest checked-in changes but rather to the latest tags. If instead you want to deploy the very latest code, then use this line instead:
$ make build CHANNEL=dev

For more information

For more advanced configurations, including web server support, please see the following documentation: http://docs.services.mozilla.com/howtos/run-sync.html

For a more technical overview of Sync Server and an introduction to Mozilla Services, please see the following documentation: http://docs.services.mozilla.com


Back To ==> Mozilla BT Services