Tutorial – Deploying Solrcloud 5 on Amazon EC2

UPDATE: This tutorial is based on Solr 5. If you want to use Solr 8, we strongly recommend to use our recent blog entry to set up Solrcloud 8 on Amazon EC2

NOTE: There is a French version to this tutorial, which you’ll find on the second half of this blog entry.

In this tutorial, we’ll be setting up a Solrcloud cluster on Amazon EC2.
We’ll be using Solr 5.1, the embedded Jetty, Zookeeper 3.4.6 on Debian 7 instances.
This tutorial explains step by step how to reach this objective.

We’ll be installing a set of 3 machines, with 3 shares and 2 replicas per shard, which gives us a total of 9 shards.
We’ll also be installing a Zookeeper ensemble of 3 machines.

This architecture will be flexible enough to allow for a fail-over of one or two machines, depending on whether we’re at the indexing phase or at the querying phase:

  • Indexing: a machine can fail without impacting the cluster (the zookeeper ensemble of 3 machines allows for one machine down). The updates are successfully broadcasted to the machines still running.
  • Querying: two machines can fail without impacting the cluster. Since each machine hosts 3 shards, a search query can be processed without problems, the only constraints being a slower response time due to the higher load on the remaining machine.

Here is the architecture of what we want to achieve :

Solrcloud 5 archi EC2

To achieve this, we’ll be using Amazon EC2 instances.
The steps are:

  • Configuration of the EC2 instances
  • Installation of the software components
  • Configuration of Solr Home
  • Configuration of Zookeeper
  • Configuration of Solrcloud

Configuration of EC2 instances:

In this tutorial, the chosen instances are of type m3 medium with the following specs :

Sorlcloud EC2 machines specs

This will be more than enough for our tutorial.

Once connected to AWS, go to the EC2 page and create 3 instances of type m3 medium. Chose the Debian8 image (Jessy) 64 bits, which is available for free on the AWS Store:

Create or use a security key common to the 3 instances.

Once started, you should have the following 3 AWS instances, named respectively solrcloud1, solrcloud2 and solrcloud3:
EC2 machines running

You need to set the group security associated to the instances so that the instances can communicate with each other, and so that we can access to the Jetty from outside.

The rules to added are (in addition of the SSH connection):
Jetty: TCP 8983
Zookeeper: TCP 2181, 2888, 3888

The ports for the tutorial

We advise to assign « elastic ip » addresses to the instances, in order to connect to it using a fix public ip address.
Without elastic ip addresses, you’d be forced to declare the private ip addresses of the instances within the Zookeeper (ZK) configuration, and these IPs change everytime you restart your machines, meaning you’d need to reconfigure your ZK after every restart. Using elastic ips, you benefit from the public dns which takes care of mapping the private ip addresses.

Once the instances are ready, we can connect to it.

For this, use either Putty on Windows, or the terminal on Linux/Mac OS X, with the security key bound to the instances.
In this tutorial, we’ll be using EC2Box (http://ec2box.com) which can easily send grouped commands to several EC2 instances.
For this, download EC2Box: https://github.com/skavanagh/EC2Box/releases
As a windows user in this tutorial screenshots, the version installed is ec2box-jetty-v-0.26.00
Once installed, launch startEC2Box.bat
Then connect to https://localhost:8443
The default credentials are:

username:admin
password:changeme

Then go to Set AWS Credentials and enter the access key of the AWS user.
Next, go to Set EC2 Keys, enter the private key of the security key bound to the EC2 instances.
Last, go to Secure Shell -> Composite SSH Terms and pick the 3 solrcloud instances.

Pick the admin user in order to connect properly.
Solrcloud5_EC2_05_instancescmds

To send each command simultaneously to the 3 instances, you must click on each window or click on select all on top of the screen.
To be root:

sudo -i

Our instances are successfully created and we successfully connected to it, so now let’s now the real work!

Installing Java and the software components:

We will start with installing Oracle Java JDK 8, then we’ll download the latest versions of Solr and Zookeeper.

Installing Java:

To quickly setup Java, we’ll be using a repository hosted by webupd8team :
http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html
Here are the commands :

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer

Accept the licence terms of Oracle and wait for install to complete.
To check that Java is properly installed, enter :

java –version

And you should be getting :

java version
"1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Solrcloud5_EC2_15_java_success

Installing the software components:

Go to /home/admin :

cd /home/admin

Download Solr :
http://apache.mirrors.ovh.net/ftp.apache.org/dist/lucene/solr/5.1.0

Download Zookeeper :
http://mirrors.ircam.fr/pub/apache/zookeeper/stable/zookeeper-3.4.6.tar.gz

Then unzip these archives :

Tar xfvz solr*.tar.gz
Tar xfvz zookeeper-3.4.6.tar.gz

Solr is installed as a service using the provided script :

cd /home/admin/solr-5.1.0/solr/bin
./install_solr_service.sh /home/admin/solr-5.1.0.zip

You can leave the default parameters of the script.
All the install files are in /opt/solr (do not modify them) and all the files to be modified are located in /var/solr (solr home, logs)
Solr is installed by defaults in /opt/solr-5.1.0 with a symbolic link towards /opt/solr.
The RAM is also configured by default. To change these values, you need to modify SOLR_JAVA_MEM in /var/solr/solr.in.sh :

SOLR_JAVA_MEM="-Xms512m -Xmx512m"

Next, move the zookeeper folder into /opt :

mv zookeeper-3.4.6 /opt/zookeeper

Java is correctly installed, as well as all the software components required to configure our SolrCloud cluster.
Let’s move on to the configuration aspects !

Configuring Solr Home:

Let’s go into the solr home folder :

cd /var/solr/data

Open the solr.xml file, and replace the the host param with the public ip address of each ec2 instance.
EC2 config Solrcloud

You also need to modify the Solr start script, to notify that we want to start Solr in SolrCloud mode.

Nano /var/solr/solr.in.sh :

ZK_HOST=ec2-54-216-117-22.eu-west-1.compute.amazonaws.com:2181,ec2-54-74-44-196.eu-west-1.compute.amazonaws.com:2181,ec2-54-74-32-181.eu-west-1.compute.amazonaws.com:2181
SOLR_PID_DIR=/var/solr
SOLR_HOME=/var/solr/data
LOG4J_PROPS=/var/solr/log4j.properties
SOLR_LOGS_DIR=var/solr/logs
SOLR_PORT=8983
SOLR_MODE=solrcloud

The most important parameters are ZK_HOST where one needs to specify the IP addresses of our ZK ensemble, and SOLR_MODE=solrcloud to specify that Solr is in Solrcloud mode.

Configuring Zookeeper:

Go to /opt/zookeeper :

cd /opt/zookeeper

We will be creating the configuration that allows to setup a ZK ensemble made of 3 machines.
Create a folder allowing Zookeeper to place its data :

mkdir /opt/zookeeper/tmp

Et à l’intérieur de celui-ci créer un fichier myid :

nano /opt/zookeeper/tmp/myid

Change the value for each instance :
For solrcloud1, enter 1
For solrcloud2, enter 2
For solrcloud3, enter 3

Solrcloud5_EC2_07_running_instances

Now let’s move on to the configuration per se, by creating the zoo.cfg file in /opt/zookeeper/conf :

nano /opt/zookeeper/conf/zoo.cfg

Now put the following configuration :

tickTime=2000
dataDir=/opt/zookeeper/tmp
clientPort=2181
initLimit=5
syncLimit=2
server.1=ec2-54-155-21-60.eu-west-1.compute.amazonaws.com:2888:3888
server.2=ec2-54-216-61-115.eu-west-1.compute.amazonaws.com:2888:3888
server.3=ec2-54-195-44-73.eu-west-1.compute.amazonaws.com:2888:3888

Solrcloud5_EC2_08_running_instances

Hints :
– Take care not to put the public IP address, but rather the public DNS, otherwise the machines won’t be able to talk with each other.
To be sure, check upfront that they can ping each other
– Also beware of the instances security group. Ensure that the ports that are necessary for communication between instances on Zookeeper are properly open (2181, 2888 et 3888)

Open the ZK logs and check that everything is fine :

tail –f /opt/zookeeper/zookeeper.out

Solrcloud5_EC2_09_running_zookeeper

We can now connect to the web interface from any instance, and start configuring our SolrCloud cluster.

Configuration de SolrCloud:

To connect to the web interface, for instance solrcloud1 :
http://54.195.44.73:8983/solr/
You should see a Cloud tab, which is a good sign !
Click on this tab, then on Tree, and you should get… an empty screen, which is normal since no collection has been configured yet.

Solrcloud5_EC2_10_solr_admin

So let’s add a collection made of 3 shards with 2 replicas each, on our ensemble of 3 instances.
To achieve this, let’s use the collections API of SolrCloud : https://cwiki.apache.org/confluence/display/solr/Collections+API
The syntax looks like this :
/admin/collections?action=CREATE&name=name&numShards=number&replicationFactor=number&maxShardsPerNode=number&createNodeSet=nodelist&collection.configName=configname

To do this, we firstt need a Solr configuration in Zookeeper (paramètre collection.configName=configname).
We’ll be using here the zkcli.sh script which is available in the Solr distro under server/scripts/cloud-scripts to upload our Solr configuration towards ZK.

BEWARE ! From now on, the commands must be entered in only one instance, not simultaneously on the 3 instances anymore !

For this, go to /home/admin/solr-5.1.0/server/scripts/cloud-scripts :

cd /home/admin/solr-5.1.0/server/scripts/cloud-scripts

Then enter :

./zkcli.sh -zkhost ec2-54-74-44-196.eu-west-1.compute.amazonaws.com:2181,ec2-54-216-61-115.eu-west-1.compute.amazonaws.com:2888,ec2-54-195-44-73.eu-west-1.compute.amazonaws.com:2888 -cmd upconfig -confdir /home/admin/solr-5.1.0/server/solr/configsets/basic_configs/conf -confname myconfig

zkhost represents the ZK ensemble, -cmd upconfig represents the folder in which you’ll find the Solr configuration to be sent (here we use the default configuration provided with Solr) and last the name with which the configuration will be stored in ZK.

Hint: the sequence of the arguments in the command does matter

What’s left for us is to connect to the web interface to check if the configuration is present in ZK :

Solrcloud5_EC2_11_zookeeper_folders

We can now create the collection on our 3 instances, let’s use the command mentionned above, which comes from the collections API :
/admin/collections?action=CREATE&name=name&numShards=number&replicationFactor=number&maxShardsPerNode=number&createNodeSet=nodelist&collection.configName=configname

Let’s adapt this commande for our case, and type it in in our web browser :

http://54.74.44.196:8983/solr/admin/collections?action=CREATE&name=francelabs&numShards=3&replicationFactor=3&collection.configName=myconfig&maxShardsPerNode=3
Some explanation about the parameters :

  • 54.74.44.196 :8983 : the public ip address of the solrcloud1 instance, we could also have chosen the ones of solrcloud2 or solrcloud3, this doesn’t matter
  • name = francelabs : the name of our collection
  • numShards = 3 : the number of shards that will be sharing the Solr index
  • replicationFactor = 3 : each shard is replicated 2 times (as a matter of fact, using a replication factor of 1 means that shard is alone)
  • maxShardsPerNode : the maximum number of shards per instance: here we have 3 shards with a replication factor of 3 hence 3×3 = 9 shards in total. We have 3 machines hence 9 / 3 = 3 shards per node, so we set maxShardsPerNode to 3.

This command will take some time to complete. Once it is done, check the status of your cloud :
http://54.195.44.73:8983/solr/#/~cloud

Solrcloud5_EC2_12_solr_admin_zookeeper

And if we want to see which files have been created (connect to any instance, here to solrcloud1) :
cd /var/solr/data

Solrcloud5_EC2_13_solr_files

We have 3 created folders, each containing a part of the index :

Solrcloud5_EC2_14_solr_files

The only folder is data, as the configuration of Solr is stored in Zookeeper.

And VOILA, you now have a fully fonctionnal Solrcloud system on Amazon EC2. We hope you enjoyed this blog post!


VERSION FRANCAISE

Dans ce tutoriel, nous allons installer un cluster SolrCloud sur Amazon EC2.
Nous nous servirons de Solr 5.1, de Jetty embarqué avec Solr et de Zookeeper 3.4.6 sur des instances Debian 7.
Le tutoriel expliquera pas à pas comment arriver à ce résultat.
Nous allons installer un ensemble de 3 machines avec 3 shards et 2 réplicas par shard, soit un ensemble de 9 shards.
Nous installerons également un ensemble Zookeeper de 3 machines.
Cette architecture sera assez flexible pour permettre un fail-over d’une ou deux machines suivant que l’on soit à l’indexation ou au requêtage :
– Indexation : une machine peut tomber sans impacter le cluster (l’ensemble Zookeeper de 3 machines permet d’avoir une machine down). Les updates seront bien diffusées sur les machines up
– Requêtage : on peut perdre 2 machines sans impacter le cluster. En effet chaque machine hébergeant les 3 shards, la recherche pourra être effectuée sans problème avec comme seule contrainte la ralentissement du temps de requêtage.

Voici schématiquement ce que l’on souhaite obtenir :

Solrcloud 5 archi EC2

Pour réaliser cela, nous allons nous servir d’instances Amazon EC2.
Les différentes étapes vont être :

  • Configuration des instances EC2
  • Installation des briques logicielles
  • Configuration du Solr Home
  • Configuration de Zookeeper
  • Configuration de SolrCloud

Configuration des instances EC2:

Dans le cadre de ce tutoriel, les instances choisies sont de type m3 medium avec les caractéristiques suivantes :

Sorlcloud EC2 machines specs

Ce qui sera amplement suffisant dans le cadre de ce tutoriel.

Après s’être connecté sur AWS, aller sur la page EC2 puis créer 3 instances de type m3 medium.
Choisir l’image Debian8 (Jessy) 64 bits disponible sur le AWS Store (gratuit) :

Créer ou utiliser une clé de sécurité commune aux 3 instances.

Les 3 instances AWS une fois démarrées nommées respectivement solrcloud1, solrcloud2 et solrcloud3 :
EC2 machines running

Il faut régler le groupe de sécurité associé aux instances pour que les instances puissent communiquer entre elles et que l’on puisse accéder au Jetty de l’extérieur.

Les règles à ajouter sont les suivantes (en plus de la connexion SSH) :
Jetty : TCP 8983
Zookeeper : TCP 2181, 2888, 3888

The ports for the tutorial

Il est conseillé d’associer des « elastic ip » aux instances pour pouvoir y accéder via une ip publique fixe.
En effet, sans elastic ip, nous sommes obligés d’indiquer les ip privées des instances dans la configuration de Zookeeper (ZK) et celles-ci changent à chaque fois que la machine est stoppée puis démarrée. Alors que le public dns permet de faire la résolution de l’ip privée de l’instance.

Une fois les instances prêtes, nous pouvons nous connecter dessus.

Pour cela, se connecter via Putty sur Windows ou le terminal sur Linux/Mac OS X avec la clé de sécurité associée aux instances.
Dans ce tutoriel nous utiliserons EC2Box (http://ec2box.com/) qui permet d’envoyer des commandes groupées à plusieurs instances EC2 facilement.
Pour cela, télécharger EC2box ici : https://github.com/skavanagh/EC2Box/releases
Etant sur Windows, la version installée ici est la ec2box-jetty-v-0.26.00
Une fois installé, lancer startEC2Box.bat.
Puis se connecter sur https://localhost:8443/

Les infos de login par défaut sont :

username:admin
password:changeme

Puis aller dans Set AWS Credentials et rentrer l’access key de l’utilisateur AWS.
Puis dans Set EC2 Keys, entrer la private key de la clé de sécurité associée aux instances EC2.
Enfin aller dans Secure Shell -> Composite SSH Terms et choisir les 3 instances solrcloud.

Choisir comme user admin pour pouvoir se connecter.
Solrcloud5_EC2_05_instancescmds

Pour que les commandes puissent être envoyées en simultané sur les 3 instances il faut cliquer sur chacune des fenêtres ou choisir select all en haut de l’écran.

Pour être en root :

sudo -i

Nos instances ont bien été créées et nous avons pu nous connecter dessus, nous pouvons maintenant commencer le travail !

Installation de Java et des briques logicielles:

Nous allons commencer par installer Oracle Java JDK 8 puis nous allons télécharger les dernières versions de Solr et Zookeeper.

Installation de Java:

Pour installer Java rapidement, nous allons nous servir d’un repository hosté par webupd8team :
http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html
Voici les commandes :

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer

Confirmer l’acceptation des termes de la licence Oracle et attendre que l’installation se termine.
Pour vérifier si java a bien été installé, taper :

java –version

Et on obtient bien :

java version
"1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Solrcloud5_EC2_15_java_success

Installation des briques logicielles:

Se placer dans /home/admin :

cd /home/admin

Télécharger Solr :
http://apache.mirrors.ovh.net/ftp.apache.org/dist/lucene/solr/5.1.0

Télécharger Zookeeper :
http://mirrors.ircam.fr/pub/apache/zookeeper/stable/zookeeper-3.4.6.tar.gz

Puis décompresser chacune des archives :

Tar xfvz solr*.tar.gz
Tar xfvz zookeeper-3.4.6.tar.gz

On installe Solr comme un service avec le script fourni :

cd /home/admin/solr-5.1.0/solr/bin
./install_solr_service.sh /home/admin/solr-5.1.0.zip

On laisse les paramètres par défaut du script.
Tous les fichiers d’installation sont dans /opt/solr (à ne pas modifier) et tous les fichiers à modifier sont dans /var/solr (solr home, logs)
Solr est installé par défaut dans /opt/solr-5.1.0 avec un lien symbolique vers /opt/solr.
La RAM est également paramétrée par défaut. Pour modifier ces valeurs, il faut modifier dans /var/solr/solr.in.sh le paramètre SOLR_JAVA_MEM :

SOLR_JAVA_MEM="-Xms512m -Xmx512m"

On déplace ensuite le répertoire de Zookeeper dans /opt :

mv zookeeper-3.4.6 /opt/zookeeper

Java est bien installé ainsi que toutes les briques logicielles dont nous avons besoin pour configurer notre cluster SolrCloud.
Passons maintenant à la partie Configuration !

Configuration du Solr Home:

Allons maintenant dans le solr home :

cd /var/solr/data

Editer le fichier solr.xml en remplaçant le host par l’ip publique de chaque instance ec2.
EC2 config Solrcloud

Il faut également modifier le script de lancement de Solr pour indiquer que nous désirons démarrer Solr en mode SolrCloud.

Nano /var/solr/solr.in.sh :

ZK_HOST=ec2-54-216-117-22.eu-west-1.compute.amazonaws.com:2181,ec2-54-74-44-196.eu-west-1.compute.amazonaws.com:2181,ec2-54-74-32-181.eu-west-1.compute.amazonaws.com:2181
SOLR_PID_DIR=/var/solr
SOLR_HOME=/var/solr/data
LOG4J_PROPS=/var/solr/log4j.properties
SOLR_LOGS_DIR=var/solr/logs
SOLR_PORT=8983
SOLR_MODE=solrcloud

Les paramètres les plus importants sont ZK_HOST où il faut spécifier les IP de notre ensemble ZK et SOLR_MODE=solrcloud pour spécifier que Solr est en mode Solrcloud.

Configuration de Zookeeper:

Aller dans /opt/zookeeper :
cd /opt/zookeeper
Nous allons créer la configuration permettant de créer un ensemble ZK de 3 machines.
Créer un répertoire pour permettre à Zookeeper de placer ses données :
mkdir /opt/zookeeper/tmp
Et à l’intérieur de celui-ci créer un fichier myid :
nano /opt/zookeeper/tmp/myid
Changer la valeur pour chacune des instances :
Pour solrcloud1, entrer 1
Pour solrcloud2, entrer 2
Pour solrcloud3, entrer 3

Solrcloud5_EC2_07_running_instances

Passons maintenant à la configuration proprement dite en créant le fichier zoo.cfg dans /opt/zookeeper/conf :

nano /opt/zookeeper/conf/zoo.cfg

Puis entrer cette configuration :

tickTime=2000
dataDir=/opt/zookeeper/tmp
clientPort=2181
initLimit=5
syncLimit=2
server.1=ec2-54-155-21-60.eu-west-1.compute.amazonaws.com:2888:3888
server.2=ec2-54-216-61-115.eu-west-1.compute.amazonaws.com:2888:3888
server.3=ec2-54-195-44-73.eu-west-1.compute.amazonaws.com:2888:3888

Solrcloud5_EC2_08_running_instances

Astuces :
– attention à bien entrer les public dns et non pas les ip publiques sinon les machines ne pourront pas se joindre entre elles.
Vérifier au préalable en essayant de les pinguer entre elles
– attention également au groupe de sécurité des instances. Bien vérifier que les ports nécessaires à la communication des instances sur Zookeeper soient bien ouverts (2181, 2888 et 3888)

Regarder les logs de Zookeeper pour voir si tout se passe bien :

tail –f /opt/zookeeper/zookeeper.out

Solrcloud5_EC2_09_running_zookeeper

Nous pouvons maintenant nous connecter à l’interface web par n’importe quelle instance et maintenant configurer notre cluster SolrCloud.

Configuration de SolrCloud:

Se connecter à l’interface web, par exemple solrcloud1 :
http://54.195.44.73:8983/solr/
On a bien un onglet Cloud ce qui est bon signe !
Cliquer dessus puis sur Tree et on obtient… un écran vide ce qui est normal puisqu’aucune collection n’a encore été configurée.

Solrcloud5_EC2_10_solr_admin

Donc ajoutons maintenant une collection qui aura 3 shards avec 2 replicas chacun sur l’ensemble de nos 3 instances.
Pour cela nous allons utiliser la collections API de SolrCloud : https://cwiki.apache.org/confluence/display/solr/Collections+API
La syntaxe sera de cette forme :
/admin/collections?action=CREATE&name=name&numShards=number&replicationFactor=number&maxShardsPerNode=number&createNodeSet=nodelist&collection.configName=configname

Mais pour pouvoir faire cela il faut au préalable avoir une configuration de Solr dans Zookeeper (paramètre collection.configName=configname).
Nous allons utiliser ici le script zkcli.sh qui est présent dans la distribution de Solr dans server/scripts/cloud-scripts pour uploader notre configuration Solr à ZK.

Attention ! A partir d’ici les commandes ne sont à entrer que sur une seule instance et non plus sur les trois en simultané !

Pour cela aller dans /home/admin/solr-5.1.0/server/scripts/cloud-scripts :

cd /home/admin/solr-5.1.0/server/scripts/cloud-scripts

Puis taper :

./zkcli.sh -zkhost ec2-54-74-44-196.eu-west-1.compute.amazonaws.com:2181,ec2-54-216-61-115.eu-west-1.compute.amazonaws.com:2888,ec2-54-195-44-73.eu-west-1.compute.amazonaws.com:2888 -cmd upconfig -confdir /home/admin/solr-5.1.0/server/solr/configsets/basic_configs/conf -confname myconfig

zkhost indique l’ensemble ZK, -cmd upconfig indique le répertoire dans lequel se trouve la configuration Solr à envoyer (ici on a pris une configuration par défaut fournie avec Solr et enfin le nom sous lequel la configuration va être stockée dans ZK.

Astuce : l’ordre des arguments est important dans la commande

Il ne nous reste plus qu’à nous connecter sur l’interface web pour voir si la configuration apparait bien dans ZK :

Solrcloud5_EC2_11_zookeeper_folders

Nous pouvons enfin créer la collection sur nos 3 instances, reprenons la commande évoquée précédemment extraite de la collections api :
/admin/collections?action=CREATE&name=name&numShards=number&replicationFactor=number&maxShardsPerNode=number&createNodeSet=nodelist&collection.configName=configname

Adaptons la commande pour notre cas à entrer dans le browser web :

http://54.74.44.196:8983/solr/admin/collections?action=CREATE&name=francelabs&numShards=3&replicationFactor=3&collection.configName=myconfig&maxShardsPerNode=3
Les paramètres expliqués :

  • 54.74.44.196 :8983 : ip publique de l’instance solrcloud1, on aurait pu prendre indifféremment celles de solrcloud2 ou solrcloud3
  • name = francelabs : le nom de notre collection
  • numShards = 3 : le nombre de shards qui vont se partager l’index Solr
  • replicationFactor = 3 : chaque shard est répliqué 2 fois (en effet un replication factor de 1 veut dire que le shard est tout seul)
  • maxShardsPerNode : le nombre maximum de shards par instance : ici on a 3 shards avec un replication factor de 3 soit 3×3 = 9 shards au total. On a 3 machines donc 9 / 3 = 3 shards par node, on règle donc le maxShardsPerNode à 3.

La commande va mettre un peu de temps à s’exécuter. Une fois celle-ci terminée, vérifier l’état du cloud :
http://54.195.44.73:8983/solr/#/~cloud

Solrcloud5_EC2_12_solr_admin_zookeeper

Et si on regarde du côté des fichiers créés (se connecter sur n’importe quelle instance, ici sur solrcloud1) :
cd /var/solr/data

Solrcloud5_EC2_13_solr_files

On a 3 répertoires qui ont été créés chacun contenant une partie de l’index :

Solrcloud5_EC2_14_solr_files

Seul le dossier data est présent car la configuration de Solr est stockée dans Zookeeper.

Et voilà, votre SolrCloud sur Amazon EC2 est maintenant fonctionnel, en espérant que ce blog vous sera utile!

1 thought on “Tutorial – Deploying Solrcloud 5 on Amazon EC2

  1. Pingback: Tutorial for setting up SolrCloud on Amazon EC2 | Blog of France Labs on Search technologies

Comments are closed.