QA/Sync/Sync Server Install On Ubuntu 11 10
From MozillaWiki
Back To ==> Mozilla BT Services
Contents
- 1 Installing Sync Server on Ubuntu 11.10 64-Bit
- 1.1 ISO Source
- 1.2 Using Python 2.7
- 1.3 Pre-Installed Packages
- 1.4 Required Packages
- 1.5 Install Python Tools and Developer Tools
- 1.6 Install Mercurial and Sqlite3
- 1.7 Install MySQL-Server and the Client Library
- 1.8 Clone and Build the Sync Server
- 1.9 Configure the Sync Server for sqlite3
- 1.10 Start and Verify the Sync Server
- 1.11 Configure MySQL and the sync.conf file
- 2 Running the Sync 1.1 Tests
- 3 Re-building and Re-deploying the Sync Server
- 4 Redeploying a Live Server
- 5 Using your Sync Server as a FireFox Sync Custom Host
- 6 For more information
Installing Sync Server on Ubuntu 11.10 64-Bit
ISO Source
- http://releases.ubuntu.com/
- Example: http://releases.ubuntu.com/oneiric/ubuntu-11.10-desktop-amd64.iso
Using Python 2.7
- The default version of Python on Ubuntu 11.10 is 2.7.x
- 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:
Install Python 2.6.6 in a local or public directory 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 Install the python virtualenv for 2.6.6 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.10:
- 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.6.1-9ubuntu3) 4.6.1 Copyright (C) 2011 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; hg --version $ which sqlite3; sqlite3 --version $ which mysql; mysql --version
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
Install Mercurial and Sqlite3
- The sqlite3 install is good for quick testing the Sync Server.
$ which hg; hg --version /usr/bin/hg Mercurial Distributed SCM (version 1.9.1) (see http://mercurial.selenic.com for more information) Copyright (C) 2005-2011 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; sqlite3 --version /usr/bin/sqlite3 $ sqlite3 --version 3.7.7 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2
Install MySQL-Server and the Client Library
- Install MySQL-Server and/or Client if you will not be using sqlite3
- Note: 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; mysql --version /usr/bin/mysql mysql Ver 14.14 Distrib 5.1.61, 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
- And now the (optional) client library:
$ sudo apt-get install libmysqlclient-dev
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
- Finally, install MySQL-Python (harmless install if you using sqlite3):
$ cd server-full $ bin/easy_install Mysql-Python
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
- Open a terminal and start up the Sync Server (from the server-full directory)
$ cd server-full $ 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
- Open a second terminal and check the Sync Server host using curl:
$ 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
- From the first terminal you should see some server activity from this curl call, for example:
2012-04-17 17:31:17,643 INFO [syncserver] 127.0.0.1 - - [17/Apr/2012:17:31:17 -0700] "GET / HTTP/1.1" 404 154 "-" "curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3" 127.0.0.1 - - [17/Apr/2012:17:31:17 -0700] "GET / HTTP/1.1" 404 154 "-" "curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3"
- 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' to the browser if it is working correctly
- Again, you should see some server activity as a result of the http call:
2012-04-17 17:34:22,467 INFO [syncserver] 127.0.0.1 - - [17/Apr/2012:17:34:22 -0700] "GET /user/1.0/a HTTP/1.1" 200 1 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0" 127.0.0.1 - - [17/Apr/2012:17:34:22 -0700] "GET /user/1.0/a HTTP/1.1" 200 1 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0"
- Stop the Sync Server:
From the first terminal window: Ctrl-C
Configure MySQL and the sync.conf file
- You can optionally use MySQL instead of sqlite3.
- 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('myrootpwd') 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 "myrootpwd" and sync DB on localhost (from above steps): sqluri = mysql://root:myrootpwd@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.
- Note: the server does not need to be running.
- Note: this works for sqlite3 and mysql configurations.
$ 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 if you are using it) 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
- NOTE: More specific redeployment ideas can be found on this great site:
Using your Sync Server as a FireFox Sync Custom Host
- You can use your own Sync server as a custom host for FireFox Sync:
Start up your Sync Server (see instructions above) Open the FireFox browser Select Tools > Set Up Sync > Create a New Account Fill in the necessary information for Login and Password For the Server field, select Custom Host and type in the following http://127.0.0.1:5000/ (make sure to include the trailing "/" character) Click Next
- You should now be set up to sync using your custom host.
- Checking the terminal where you started the host, you should see sync messages similar to the following:
2012-04-17 17:55:14,433 INFO [syncserver] 127.0.0.1 - - [17/Apr/2012:17:55:14 -0700] "GET /user/1.0/a HTTP/1.1" 200 1 "-" "Firefox/11.0 FxSync/1.14.0.20120310010316.desktop" 127.0.0.1 - - [17/Apr/2012:17:55:14 -0700] "GET /user/1.0/a HTTP/1.1" 200 1 "-" "Firefox/11.0 FxSync/1.14.0.20120310010316.desktop" 2012-04-17 17:55:14,439 INFO [syncserver] 127.0.0.1 - - [17/Apr/2012:17:55:14 -0700] "GET /user/1.0/<YOUR USER ID> HTTP/1.1" 200 1 "-" "Firefox/11.0 FxSync/1.14.0.20120310010316.desktop" 127.0.0.1 - - [17/Apr/2012:17:55:14 -0700] "GET /user/1.0/<YOUR USER ID> HTTP/1.1" 200 1 "-" "Firefox/11.0 FxSync/1.14.0.20120310010316.desktop" 2012-04-17 17:55:14,446 INFO [syncserver] 127.0.0.1 - - [17/Apr/2012:17:55:14 -0700] "GET /misc/1.0/captcha_html HTTP/1.1" 404 175 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0" 127.0.0.1 - - [17/Apr/2012:17:55:14 -0700] "GET /misc/1.0/captcha_html HTTP/1.1" 404 175 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0" 2012-04-17 17:55:20,472 WARNI [syncserver] Unicode response returned from: syncreg.controllers.user - create_user Unicode response returned from: syncreg.controllers.user - create_user ...etc...
- Extra credit: if you run your sync server behind a web service, it will be publicly available to other devices for some true syncing...
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
- And another good site for installing/configuring sync server: http://www.wenks.ch/fabian/mozilla-custom-sync-server/
- 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