# Installation with Ansible

## Introduction

This manual describes the installation procedures for GBDS.

## Installation Preparation

This section covers the essential steps required to install GBDS.

{% hint style="warning" %}
All steps must be performed with root privileges on all nodes, unless otherwise indicated.
{% endhint %}

To fully install GBDS, you will need:

* Root permission on the server
* GBDS Tools package link
* Ambari Ansible package link
* OpenCV package link
* GBDS .rpm and .sql files
* Griaule Biometric Suite software .war and .sql files (optional)

{% hint style="info" %}
If you do not have the repository links or the files, contact the Griaule support team.
{% endhint %}

Next, you must follow the steps shown below. These steps will be fully described in their sections.

1. Log in to the server as root
2. [Install GBDS Tools](#instalando-o-gbds-tools)
3. [Configure the GBDS Tools configuration files](#configurando-o-gbds-tools)
4. [Run the automatic GBDS Tools environment setup](#executando-a-configuracao-automatica-do-ambiente)
5. [Install the RDB](#instalando-o-rdb)
6. [Install Ambari via Ansible](#instalando-o-ambari)
7. [Install GBDS](#instalando-o-gbds)
8. [Install the GBS applications (optional)](#instalando-as-aplicacoes-gbs)

{% hint style="success" %}
Before you start, make sure the `hostname` of the machine is correct. To check it, run the command:

```shell
hostname
```

If it is not correct, run the command:

```shell
hostnamectl set-hostname <desired-hostname>
                         ^^^^^^^^^^^^^^^^^^^
```

{% endhint %}

If the hostname is changed, restart the machine before proceeding.

## GBDS Tools

GBDS Tools is a collection of bash scripts with specific features and dynamic usability. The main purpose of the tool is to facilitate, improve, and speed up the creation, configuration, and management of environment applications.

All scripts use a single configuration file called `properties.ini` and a single list file called `cluster.list`, which must contain all server cluster information.

{% hint style="success" %}
Before you start, make sure the `wget` is installed:

```shell
wget --version
```

If not, run the command:

```shell
yum install wget -y
```

{% endhint %}

### Installing GBDS Tools

You have two methods to choose from to install GBDS Tools, one if you already have the Griaule repository configured on your server and another if you do not. These are explained below.

{% hint style="info" %}
Choose only one alternative. After finishing one, there is no need to do the other.
{% endhint %}

#### Repository already configured

If you have already configured the Griaule repository on your server, you can complete all installations with just one command.

```shell
yum install gbds-tools
```

{% hint style="danger" %}
If the Griaule repository is not configured, running the command above will result in the following error:

```default
No package gbds-tools available
Error: Nothing to do
```

In this case, proceed to [Repository not configured](#repositorio-nao-configurado).
{% endhint %}

#### Repository not configured

If you do not have the repository configured, you must ensure the tool works properly. To do this, you **MUST** place the tool in the `/opt/griaule`.

directory. Start by creating the directory:

```shell
mkdir -p /opt/griaule
```

Enter the created directory:

```shell
cd /opt/griaule
```

Then, download the GBDS Tools package:

```shell
wget <GBDS Tools package link>
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

{% hint style="info" %}
If you do not have the link, contact the Griaule Support Team.
{% endhint %}

{% hint style="success" %}
In the commands below, make sure to replace `<version>` with the version of the package that was downloaded.
{% endhint %}

Then, install it:

```shell
rpm -ivh gbds-tools-<version>.el7.noarch.rpm
                    ^^^^^^^^
```

And create a symbolic link:

```shell
ln -s /opt/griaule/gbds-tools-<version>/ /opt/griaule/tools
                              ^^^^^^^^
```

After a successful installation, proceed to the [configuration section](#configurando-o-gbds-tools).

### Configuring GBDS Tools

The configuration files used by GBDS Tools are located in the directory: `/opt/griaule/tools/shared`. In this directory, there are three files that must be edited:

* `properties.ini` - main configuration file
* `cluster.list` - main hostname list file
* `ip.list`- secondary hostname file

The files are preconfigured with default values for most parameters. Check whether anything needs to be changed to meet the needs of your environment.

{% hint style="warning" %}
Change the **hostnames** in the files to match those of the environment is imperative.
{% endhint %}

{% hint style="success" %}
In the `properties.ini`file, look for the `SPECIFIC TO` settings and make the necessary changes to match your environment.

In the `SPECIFIC TO AUTO_ENVSETUP`section, make sure the **username** and **password** are configured correctly in `usernm`, `userpw` and `rootpw`.

In the `SPECIFIC TO INSTALL_MYSQL`, note the **RDB password**, configured in `dbuspw`, as it [will be used later](#configurando-a-senha-do-rdb).
{% endhint %}

{% hint style="success" %}
In the `cluster.list`, make sure to change the **hostnames** and adapt the **number of hosts** in each component so that it matches the environment.

By default, the file is configured for a cluster of **three** nodes. If the environment has, for example, only **one node**, remove the references to nodes 2 and 3 and replace all names with your server hostname.
{% endhint %}

{% hint style="success" %}
In the `ip.list`, make sure to change the **hostnames** and the **IP addresses** to match the environment, following the format `<hostname>|<IP address>` on each line.
{% endhint %}

### Running the automatic environment setup

The automatic environment setup, called `auto_envsetup.sh`, is the automation for configuring the environment. You need to run this script when building a new server from scratch.

To run the script, execute the following command:

```shell
/opt/griaule/tools/auto_envsetup/auto_envsetup.sh --all
```

Then, it is recommended to update all packages, if possible:

```shell
yum update -y
```

## Installing the RDB

To use GBDS, you will need a relational database installed and configured. You can choose between [MySQL Server](#mysql-server) or [NDB Cluster](#ndb-cluster).

{% hint style="warning" %}
You only need to perform **one** RDB installation.
{% endhint %}

### MySQL Server

{% hint style="warning" %}
It is recommended to install MySQL on the master node.
{% endhint %}

To install MySQL Server, run:

```shell
/opt/griaule/tools/install_mysql/install_mysql.sh --single
```

Then, proceed to [Configuring the RDB password](#configurando-a-senha-do-rdb).

### NDB Cluster

{% hint style="warning" %}
The NDB installation **MUST** be on the **MASTER**.
{% endhint %}

**node**Or, if you choose to install NDB Cluster, run:

```shell
/opt/griaule/tools/install_mysql/install_mysql.sh --cluster
```

Then, proceed to [Configuring the RDB password](#configurando-a-senha-do-rdb).

### Configuring the RDB password

After the installation, try logging in to MySQL by running the command:

```shell
mysql -u root -p
```

And entering the password configured in the file `properties.ini` in `dbuspw`, as mentioned in the [previous step](#configurando-o-gbds-tools).

If you can log in, the installation and password configuration were successful and you can proceed to [Configuring MySQL](#configurando-o-mysql).

***

If you cannot log in and you see the following error:

```html
Error: Access denied for user '<username>'@'<host>' (using password: YES)
```

You will need to change the password manually. To do this, use the following command to obtain the temporary password created during installation:

```shell
grep "temporary password" /var/log/mysqld.log
```

Copy the temporary password shown.

Then, change the password using the following command:

{% hint style="info" %}
Make sure to replace `<desired_password>` with the desired password. Keep the quotes.
{% endhint %}

```shell
mysqladmin -u root -p password "<desired_password>"
                                ^^^^^^^^^^^^^^^^
```

When prompted, enter the temporary password.

Then, try logging in to MySQL again using the new password.

If you can log in, the installation and password configuration were successful and you can proceed to [Configuring MySQL](#configurando-o-mysql).

### Configuring MySQL

Finally, configure the database for your environment.

The configuration file is located at: `/etc/my.cnf`.

{% hint style="warning" %}
The default RDB installation settings may not be the desired settings. Check them in the configuration file `my.cnf` and adapt them to meet the needs of the environment.
{% endhint %}

After making the necessary changes, apply them by restarting the service:

```shell
systemctl restart mysqld
```

## Installing Ambari

To install Ambari via Ansible, it is necessary to access the Griaule repository.

{% hint style="warning" %}
If your GBDS RDB is not on the **MASTER**node, it is recommended to start another RDB instance for Ambari.
{% endhint %}

{% hint style="info" %}
The installation requires an internet connection and may take 45 minutes to complete without errors. Before installing, check that your connection is stable.
{% endhint %}

To start the Ambari installation, enter the Ansible directory:

```shell
cd /etc/ansible
```

Then, download the package:

```shell
wget <Ambari Ansible package link>
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

{% hint style="info" %}
If you do not have the link, contact the Griaule Support Team.
{% endhint %}

Next, extract the files into the main Ansible directory, `/etc/ansible`, with the following command:

{% hint style="success" %}
In the command below, make sure to replace `<version>` with the version of the package that was downloaded.
{% endhint %}

```shell
tar -xvf ansible_hdp-<version>.tar
                     ^^^^^^^^
```

Enter the extracted directory:

```shell
cd /etc/ansible/ansible-hadoop
```

{% hint style="success" %}
Since the process takes some time to complete, it is recommended to run the installation script using `screen` to avoid interruptions.

To do this, install *screen*:

```shell
yum install screen -y
```

Start a new session in *screen*:

```shell
screen -S ambari-install
```

Then, proceed with running the installation script as described below.

—

If the connection to the server is lost, the script will not be interrupted and you can resume the session by reconnecting to the server and running:

```shell
screen -r ambari-install
```

{% endhint %}

Then, run the installation script:

```shell
./full-hadoop.sh
```

Answer the installation questions and proceed until finished.

{% hint style="warning" %}
Once started, **DO NOT interrupt** any of the scripts. If any problem occurs, contact the Griaule support team.
{% endhint %}

## Installing GBDS

To install GBDS, you will need:

* GBDS Cluster .rpm
* GBDS Distribution .rpm
* GBDS RDB dump script .sql
* OpenCV package link

Start by moving the two `.rpm` files to the `/opt/griaule/tools/deploy_application/files`.

The `.sql` dump script file must be saved in another directory.

{% hint style="warning" %}
After running the following script, all contents of the `/opt/griaule/tools/deploy_application/files` directory will be deleted.
{% endhint %}

Then, run the following command to install GBDS:

```shell
/opt/griaule/tools/deploy_application/deploy_application.sh --gbds
```

{% hint style="info" %}
After trying to run the script above, if you get the error:

```
[ERROR] No OPENCV RPM found to be deployed. Make sure to stage the desired RPM
```

Enter the `files`:

```shell
cd /opt/griaule/tools/deploy_application/files
```

And download the OpenCV package:

```shell
wget <OpenCV package link>
     ^^^^^^^^^^^^^^^^^^^^^
```

Then, try running the `deploy_application.sh` script again.
{% endhint %}

Next, run the RDB dump script on the SQL server.

```shell
mysql -u root -p < /PATH/TO/FILE/clear-rdb-<version>.sql
                   ^^^^^^^^^^^^^^^^^          ^^^^^^^^
```

{% hint style="success" %}
The RDB password was configured [here](#configurando-a-senha-do-rdb).
{% endhint %}

After finishing the GBDS installation, configure it by running:

```shell
/opt/griaule/tools/auto_appconfig/auto_appconfig.sh --gbds
```

To review or manually change the settings, edit the configuration file located at: `/etc/griaule/conf/gbds/application.conf`. For more information about the settings, see the [GBDS Configuration Manual](/gbs/en/gbds-configuration/gbds4conf.md).

{% hint style="warning" %}
Make sure that the **hostname** in the configuration file (`application.conf`) matches the **hostname** of the server.
{% endhint %}

Then, start the GBDS API:

```shell
service gbsapid start
```

Test whether the API is running:

```shell
curl http://<host-ip>:8085/gbds/v2/operations/ping
            ^^^^^^^^^
```

The expected response is:

```json
{
	"data": "pong!"
}
```

Finally, start GBDS:

```shell
gbdsstart
```

And monitor the execution *log* :

```shell
gbdslogt
```

## Installing GBS applications

To install the GBS Applications, you will need:

* File *.war* for each application
* Dump script *.sql* for each application

First, install and configure Tomcat for the web applications. This should only be done on the server that will host the web applications. Use the following command:

```shell
/opt/griaule/tools/install_services/install_services.sh
```

Then, move the files `.war` files to the `/opt/griaule/tools/deploy_application/files` and run the command:

```shell
/opt/griaule/tools/deploy_application/deploy_application.sh --services
```

After that, configure the applications with the following command:

```shell
/opt/griaule/tools/auto_appconfig/auto_appconfig.sh --services
```

{% hint style="info" %}
To explore the individual settings of each application, consult the corresponding configuration manuals listed [here](/gbs/en/web-components/gbsappssetup.md).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.griaule.com/gbs/en/gbds-installation/gbds4ansibleinstall.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
