{{announcement.body}}
{{announcement.title}}

Installing Zato from sources on Ubuntu 18.04 using Python 3

DZone 's Guide to

Installing Zato from sources on Ubuntu 18.04 using Python 3

Check out how to install open-source integration orchestration platform Zato using Ubuntu 18.04 and Python 3.

· Open Source Zone ·
Free Resource

Zato is an open-source platform to orchestrate integration services and expose new or existing APIs, either cloud or on-premise, using a wide range of connectors, data formats, and protocols. A Zato installation consists of a number of clusters, a web admin panel, an operational database and an in-memory key-value database to store statistics. Each cluster is made of a scheduler, a load balancer and two or more application servers. These last two components are tasked with dealing with the external applications.

To develop services, programmers use Python, a very high-level and powerful programming language, famously known for its ease of use and readability.

Technical overview of a Zato installation

In this article, we will be learning how to set up a test environment for Zato running on Python 3 inside a Docker container. PostgreSQL (for Zato’s SQL Operational Database) and Redis (for Zato’s statistics) are kept outside of the container for our convenience.

Redis

Install from the distribution sources (version 4.0.9):

sudo apt install --yes redis-server 

The default configuration binds Redis to the localhost IP address, which is just what we need. Nonetheless, to test access to it the following command can be issued:

redis-cli -h localhost -p 6379 ping

If in the need to reinstall Zato, you will most probably have to delete all keys from all existing databases, which can be done through the following command:

redis-cli -h localhost -p 6379 flushall

PostgreSQL

Install from the distribution sources (version 10.12):

sudo apt install --yes postgresql 

Edit /etc/postgresql/10/main/pg_hba.conf to add access rules:

Shell
 




x


1
# IPv4 local connections: 
2
host    zato            zato            127.0.0.1/32            trust
3
host    all             all             127.0.0.1/32            md5


And reload the server:

sudo service postgresql reload 

Create the user and the database. As postgres  user:

createuser --no-createdb --no-createrole --no-superuser zato
createdb --encoding=UTF8 --owner=zato --template=template0 zato 

In case you have to reinstall Zato it will be necessary to recreate the  zato  database, which can be done through the following commands:

dropdb zato 
createdb --encoding=UTF8 --owner=zato --template=template0 zato

Docker

Install from the distribution sources (version 19.03.6):

apt install --yes docker.io 

Add your username to the  docker  group so there’s no need to use  sudo  to manage the container:

sudo usermod -aG docker ${USER} 

Apply the changes:

su - ${USER} 

Install the Ubuntu 18.04 official image from the Docker hub:

docker pull ubuntu:18.04 

Run the container. Given that it is for for testing purposes, we can just run the container using the network host mode instead of publishing ports:

docker run --interactive --tty --network="host" --name zato ubuntu:18.04 

You are now  root  inside the container.

root@myhostname:/# 

From outside of the container, use the  docker  command to find out the id and check the name of the container:

Shell
 




xxxxxxxxxx
1


 
1
 docker ps --all
2
CONTAINER ID   IMAGE          COMMAND       CREATED              STATUS              PORTS   NAMES
3
886355a5e310   ubuntu:18.04   "/bin/bash"   About a minute ago   Up About a minute           zato


Whenever you exit the container (using the  exit  command), you can start it again with the following command:

docker start --interactive zato 

And you can stop the container from outside with the following command:

docker stop zato 

You can get a bash terminal, as  root  user, with the following command:

docker exec --user root --interactive --tty zato bash

Zato Installation

Inside the container, update the packages list and, optionally, upgrade the installed packages:

apt update 
apt upgrade --yes 

Install a number of dependencies in the form of system packages:

apt install --yes python3 python3-dev python3-pip git 

Optionally, install some helpers also as system packages:

apt install --yes apt-utils ccze dialog htop mc net-tools sudo tzdata vim 

Create the  zato  user and set a password:

groupadd zato 
useradd --comment "Zato Enterprise Service Bus" --home-dir /opt/zato --create-home --shell /bin/bash --gid zato zato 
adduser zato sudo 
passwd zato 

Become zato and clone the repository:

su - zato 
git clone https://github.com/zatosource/zato 

Compile and install:

cd zato 
./code/install.sh -p python3 

To test that the connection from inside the container to PostgreSQL is working fine, use the following commands:

sudo apt install --yes postgresql-client 
psql --host=localhost --username=zato --dbname=zato --tuples-only --no-align --command="SELECT 1"

To test that the connection from inside the container to Redis is working fine, use the following commands:

sudo apt install --yes redis-tools 
redis-cli -h localhost -p 6379 ping 

Zato Environment

Create a complete Zato environment using the quickstart option:

Shell
 




xxxxxxxxxx
1
16


1
$ mkdir --parents /opt/zato/env/qs-1
2
$ /opt/zato/zato/code/bin/zato quickstart create --odb_host localhost --odb_port 5432 --odb_user zato --odb_db_name zato --odb_password '' --kvdb_password '' /opt/zato/env/qs-1/ postgresql localhost 6379
3
[1/9] Certificate authority created
4
[2/9] ODB schema created
5
[3/9] ODB initial data created
6
[4/9] server1 created
7
[5/9] server2 created
8
[6/9] Load-balancer created
9
Superuser created successfully.
10
[7/9] Web admin created
11
[8/9] Scheduler created
12
[9/9] Management scripts created
13
Quickstart cluster quickstart-726934 created
14
Web admin user:[admin], password:[9bR3Ith8w4LePItJ-8eulU9VgNnH4L8s]
15
Start the cluster by issuing the /opt/zato/env/qs-1/zato-qs-start.sh command
16
Visit https://zato.io/support for more information and support options


Edit the  zato  user’s profile file  ~/.profile  to add the binaries to the path:

Shell
 




x


1
# set PATH so it includes user's private bin if it exists
2
if [ -d "$HOME/zato/code/bin" ] ; then
3
    PATH="$HOME/zato/code/bin:$PATH"
4
fi


Re-log as the  zato  user or reload the configuration:

source ~/.profile 

Change the given password for the  admin  user, that will be required when accessing the web administration panel, by using the following command:

zato update password --password <your-password> ~/env/qs-1/web-admin/ admin

Start the cluster to test that the installation was correct:

Shell

Optionally, check the running processes to get a better understanding of what has been accomplished so far:

Shell
 




xxxxxxxxxx
1
10


 
1
$ ps --user zato x
2
  PID TTY      STAT   TIME COMMAND
3
   44 pts/0    S      0:00 -su
4
  131 pts/0    S      0:02 /opt/zato/zato/code/bin/python -m zato.agent.load_balancer.main /opt/zato/env/qs-1/load-balancer/config/repo fg=FalseZATO_ZATO_ZATOsync_internal=FalseZATO_ZATO_ZATOsecret_key=
5
  173 ?        Ss     0:00 haproxy -D -f /opt/zato/env/qs-1/load-balancer/config/repo/zato.config -p /opt/zato/env/qs-1/load-balancer/pidfile
6
  191 pts/0    Sl     0:02 gunicorn: master [gunicorn]
7
  232 pts/0    Sl     0:02 gunicorn: master [gunicorn]
8
  275 pts/0    Sl     0:02 /opt/zato/zato/code/bin/python -m zato.scheduler.main fg=FalseZATO_ZATO_ZATOsync_internal=FalseZATO_ZATO_ZATOsecret_key=
9
  307 pts/0    S      0:02 /opt/zato/zato/code/bin/python -m zato.admin.main fg=FalseZATO_ZATO_ZATOsync_internal=FalseZATO_ZATO_ZATOsecret_key=
10
  353 pts/0    R+     0:00 ps -u zato x


Connect to the admin panel at  http://localhost:8183/  and log in with the  admin  username, then start the necessary configuration, as per your requirements.

Topics:
docker ,integration ,open source ,open source platform ,python 3 ,tutorial ,ubuntu 18.04 ,zato esb

Published at DZone with permission of Jaume Sabater . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}