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.
Join the DZone community and get the full member experience.
Join For FreeZato 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.
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:
x
# IPv4 local connections:
host zato zato 127.0.0.1/32 trust
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:
xxxxxxxxxx
docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
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:
xxxxxxxxxx
$ mkdir --parents /opt/zato/env/qs-1
$ /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
[1/9] Certificate authority created
[2/9] ODB schema created
[3/9] ODB initial data created
[4/9] server1 created
[5/9] server2 created
[6/9] Load-balancer created
Superuser created successfully.
[7/9] Web admin created
[8/9] Scheduler created
[9/9] Management scripts created
Quickstart cluster quickstart-726934 created
Web admin user:[admin], password:[9bR3Ith8w4LePItJ-8eulU9VgNnH4L8s]
Start the cluster by issuing the /opt/zato/env/qs-1/zato-qs-start.sh command
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:
x
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/zato/code/bin" ] ; then
PATH="$HOME/zato/code/bin:$PATH"
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:
$ /opt/zato/env/qs-1/zato-qs-start.sh
Starting Zato cluster quickstart-726934
Checking configuration
[1/8] Redis connection OK
[2/8] SQL ODB connection OK
[3/8] Checking TCP ports availability
[4/8] Load-balancer started
[5/8] server1 started
[6/8] server2 started
[7/8] Scheduler started
[8/8] Web admin started
Zato cluster quickstart-726934 started
Visit https://zato.io/support for more information and support options
Optionally, check the running processes to get a better understanding of what has been accomplished so far:
xxxxxxxxxx
$ ps --user zato x
PID TTY STAT TIME COMMAND
44 pts/0 S 0:00 -su
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=
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
191 pts/0 Sl 0:02 gunicorn: master [gunicorn]
232 pts/0 Sl 0:02 gunicorn: master [gunicorn]
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=
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=
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.
Published at DZone with permission of Jaume Sabater. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Conditional Breakpoints: A Guide to Effective Debugging
-
Security Challenges for Microservice Applications in Multi-Cloud Environments
-
Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
-
Top 10 Pillars of Zero Trust Networks
Comments