LightCloud manager can manage your nodes, take backups, purge logs etc.
Getting the LightCloud manager
Simply check out the LightCloud manager in a directory:
$ svn co http://opensource.plurk.com/svn/opensource/tyrant_manager ~/tyrant_manager $ cd ~/tyrant_manager
Create a config file
Create a config file config.py. A sample config file is included ~/lightcloud_manager/config.sample.py:
DATA_DIR = '~/lightcloud_manager/data'
TOKYO_SERVER_PARMS = '#bnum=1000000#fpow=13#opts=ld'
USE_MASTER = True
NODES = {
#Lookup nodes
'lookup1_A': { 'id': 1, 'host': '127.0.0.1:41201', 'master': '127.0.0.1:51201' },
'lookup1_B': { 'id': 2, 'host': '127.0.0.1:51201', 'master': '127.0.0.1:41201' },
#Storage nodes
'storage1_A': { 'id': 5, 'host': '127.0.0.1:44201', 'master': '127.0.0.1:54201' },
'storage1_B': { 'id': 6, 'host': '127.0.0.1:54201', 'master': '127.0.0.1:44201' },
}
The options of the manager
$ python -m manager -c config.py Script that is used to handle Tokyo Tyrant nodes. Starting nodes: python manager.py -c config.py all start python manager.py -c config.py lookup1 start Stopping nodes: python manager.py -c config.py all stop python manager.py -c config.py lookup1 stop Status: python manager.py -c config.py all status python manager.py -c config.py lookup1 status Misc: python manager.py -c config.py purge_logs python manager.py -c config.py delete_logs python manager.py -c config.py delete_data python manager.py -c config.py hot_copy python manager.py -c config.py hot_restore hot_copy_23232.zip View a sample config file in config.sample.py.
Starting the nodes:
$ python -m manager all start
Checking out status:
$ python manager.py all status
lookup1_A (127.0.0.1:41201):
node running - node items: 10306
master 127.0.0.1:51201 running - master items: 10306
lookup1_B (127.0.0.1:51201):
node running - node items: 10306
master 127.0.0.1:41201 running - master items: 10306
storage1_A (127.0.0.1:44201):
node running - node items: 10067
master 127.0.0.1:54201 running - master items: 10067
storage1_B (127.0.0.1:54201):
node running - node items: 10067
master 127.0.0.1:44201 running - master items: 10067
How to debug
If you run into problems, try to start a ttserver manually. python manager.py all start prints out the commands.
How to take a hot backup and restore it
LightCloud Tyrant manager supports taking hot backups of your database, without shutting the database down. The interface is super simple as well.
To take a hot-copy, simply do following thing:
$ python manager.py hot_copy ... Created hot copy in ~/lightcloud_manager/data/hot_copy_1245055938.zip
This creates a zip file of database files and their log positions.
To restore a hot copy simply do following:
$ python manager.py hot_restore ~/lightcloud_manager/data/hot_copy_1245055938.zip Restored hot copy of master in ~/lightcloud_manager/data/restore_dir
You should inspect ~/lightcloud_manager/data/restore_dir and ensure that everything looks reasonable (i.e. you have all the database files [tch files] and their log positions [rts files]).
When you have ensured that everything looks reasonable, you can do following to swap the current data directory:
$ python manager.py all stop $ mv ~/lightcloud_manager/data/data ~/lightcloud_manager/data/data_old $ mv ~/lightcloud_manager/data/restore_dir ~/lightcloud_manager/data/data $ python manager.py all start
You can then run status to check consistency:
$ python manager.py all status
lookup1_A (127.0.0.1:41201):
node running - node items: 10306
master 127.0.0.1:51201 running - master items: 10306
lookup1_B (127.0.0.1:51201):
node running - node items: 10306
master 127.0.0.1:41201 running - master items: 10306
storage1_A (127.0.0.1:44201):
node running - node items: 10067
master 127.0.0.1:54201 running - master items: 10067
storage1_B (127.0.0.1:54201):
node running - node items: 10067
master 127.0.0.1:44201 running - master items: 10067
