Trang chủ >> Using Tooz in OpenStack

Using Tooz in OpenStack

At first, I do like the idea of this guy about solutions of encountered problem in OpenStack that is Synchronization of multiple distributed workers (

We can see that there is a lots of dependencies and interactions between services of OpenStack. It does really take time for services cooperating for each wanted task, for example, if we want to boot an instance, Nova has to make a lots of calls to Neutron, Glance, Storage and does a lots of internal self actions like conducting, scheduling, etc. In the distributed architecture of OpenStack, some internal components of each service are distributed (e.g Nova compute, l3-agent, etc.). We have some solutions for distributed systems such as Zookeeper, Redis, Memcached, etc. and their roles are reporting to controllers about the status of members in the group that they take care about (which one is online, which one is responding, which one is offline, leaving the group, etc.). But the main problem is that not all of the solutions have the same robustness, functionalities. The fact that if we implement only one solution for all of the services, it does not utilize the advantages of others or even make some obstacles for implementing new applications, plugins to OpenStack environment. On the other hand, if we use multiple solutions for each service, it will create some of asynchronization, uncooperative between them.

The idea for this concept is creating a general solution by which developers, operators can choose whichever backend to use due to the purpose of usage or applications, plugins implementation. Tooz is nothing else but the abstraction layers for some current supported backends such as memcached, zookeeper, etc.(

In this below example, I will show you how to use zookeeper backend with Tooz on localhost:

I use magic vagrant to boot a virtual machine with Trusty image of Ubuntu and do some below steps:

1. Down load zookeeper package:

2. Execute the following instructions:

  • tar -xvf zookeeper-3.4.6.tar.gz
  • mkdir -p /var/lib/zookeeper

3. Put the “1” to myid in /var/lib/zookeeper/myid (or any id number if you want but you must provide the same ID in zoo.cfg):

  • echo “1” > /var/lib/zookeeper/myid

4. Put the following configs to conf/zoo.cfg in zookeeper directory:





Note that the above values are default of zookeeper except server ID and host ( You can change the tickTime or ports if you want.

5. Activate zookeeper:

  • cd zookeeper-3.4.6
  • bin/ start
  • bin/ -server

If you see some errors, that means Java is not installed in your Ubuntu:

  • apt-get install -y python-software-properties
  • add-apt-repository ppa:webupd8team/java
  • apt-get update
  • apt-get install -y oracle-java8-installer

Run again:

  • bin/ -server



6. Install Tooz:

  • pip install tooz

7. Check the list of backends of tooz:

>>> from pkg_resources import iter_entry_points

>>> for object in iter_entry_points( group=’tooz.backends’, name=None):

…             print object

ipc = tooz.drivers.ipc:IPCDriver

postgresql = tooz.drivers.pgsql:PostgresDriver

kazoo = tooz.drivers.zookeeper:KazooDriver

zookeeper = tooz.drivers.zookeeper:KazooDriver

redis = tooz.drivers.redis:RedisDriver

zake = tooz.drivers.zake:ZakeDriver

file = tooz.drivers.file:FileDriver

mysql = tooz.drivers.mysql:MySQLDriver

memcached = tooz.drivers.memcached:MemcachedDriver

8. I use zookeeper in this example so I will use kazoo driver. Install kazoo:

  • pip install kazoo

9. Using zookeeper to call tooz:

>>> from tooz import coordination

>>> coordinator = coordination.get_coordinator(‘kazoo://′, b’host-1’)

>>> coordinator.start()


10. Check with zookeeper cli:

  • bin/ -server



You can extend this example by using this below instruction:

Otherwise, this Tooz is now useful for solving the problems of group membership, leader election for distributed components in OpenStack. We can easily contribute more for Tooz project or write plugins to enforce Tooz to do more fucntions such as VM monitoring, host monitoring, etc.

In Nova, there is a spec that will replace service group primitives such as Zookeeper, Memcached by Tooz. Actually, tooz is now implemented in Ceilometer, Nova is on its way:



VietStack team


Tin liên quan:

Các tin khác:

Sự kiện