In order to provide a search service on www.nucleus.com, we needed to set up an Elastic Search instance. Our web site is hosted as an Azure App Service, so we decided to use an Azure Virtual Machine. The original source for most of the Elastic Search installation steps is from the Elasticsearch documentation.
We don't need a high capacity service, and search is used infrequently, so our Azure Virtual machine is a Standard B1ms virtual machine (1 vCpu, 2gb RAM), running Ubuntu Linux. The Azure Portal wizard is fairly easy to use, so we're not going to run through how to set up a virtual machine in Azure.
Once the virtual machine is set up, select it in the Azure Portal and choose "Connect" from the "Settings" menu at the left-hand side of the page, then choose the "SSH" tab. If you don't already have your SSH key, you may need to click the "replace/reset your SSH private key" link to generate a new key, then download it to your computer.
The "connect" page displays the ssh command which you can use to connect to your virtual machine. You can run this from a Windows command prompt.
The PGP key is used to verify the installation package.
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
The apt-transport-package is used to download the install package. It will generally already be installed, this step ensures that it is installed, and won't do anything if it is already installed.
sudo apt-get install apt-transport-https
This step saves the repository definition:
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt-get update && sudo apt-get install elasticsearch
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
The Elasticsearch ingest-attachment plugin is used to index file contents, and is required by the Nucleus Elastic Search extension.
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment
During installation, a security warning is displayed. Enter "y" to allow the installation to proceed.
sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
Record the password, which is displayed on-screen after being reset. The default elastic search user name is 'elastic'. You will need the password for the Nucleus Elastic Search extension settings page.
sudo openssl x509 -fingerprint -sha256 -in /etc/elasticsearch/certs/http_ca.crt
You will need the certificate thumbprint for the Nucleus Elastic Search extension settings page.
sudo nano /etc/elasticsearch/elasticsearch.yml
Un-comment and set the cluster.name (name it whatever you want), and set the network.host value to 0.0.0.0. The other default settings will work. Press CTRL-X to exit, and press Y to save your settings.
sudo systemctl start elasticsearch.service
The steps above set up a simple single-node server, with no backup or redundancy. The setup is suitable for our search requirements, because we can re-build the index at any time. Other use cases may require more server resources, or a cluster.