In this post I will be writing steps to set up an ubuntu server to run elasticsearch on it.

Setting up ubuntu server

You will need a usb at least 4 gb in size.

  1. Download ubuntu server from here.
  2. Create a bootable usb stick with the server iso using the steps from How to create a bootable USB stick on Ubuntu
  3. Use the usb to boot the laptop in which you want to setup the server
  4. Install the ubuntu server as explained in this askubuntu answer.
  5. In between you might get following error:

    ``` Your installation CD-ROM couldn’t be mounted. This probably means that yhe CD-ROM was not in the drive. If so you can insert it and try again.

    Retry mounting the CD-ROM?

    ``` The error is coming because the setup needs the `ubuntu server iso` to be mounted to `/cdrom`. There are many solutions suggested on web (like [this](http://ubuntuforums.org/showthread.php?t=1750464), [this](https://pricklytech.wordpress.com/2013/04/21/ubuntu-server-unattended-installation-custom-cd/)) which were suggesting to mount the iso to `cdrom` manually. But nothing worked for me except [this silly answer](http://askubuntu.com/a/614902/78177).
  6. After this restart the server and login.

Setting up network

There are many ways suggested on web like this, this, this, but what worked for me is Ubuntu 14.04 Server - WiFi WPA2 Personal.

Also in case you get confused router-ssid is the name of the router network you want to connect to.

Setting up ssh server

Follow Install SSH server on Ubuntu Linux.

Setup Java

cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz"
tar xzf jdk-8u51-linux-x64.tar.gz
apt-get install chkconfig
update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_51/bin/java 3

ref: How to Install JAVA 8 (JDK 8u66) on CentOS/RHEL and Fedora

Setup elasticsearch

  1. Getting es

    cd wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.1.zip apt-get install unzip unzip elasticsearch-1.7.1.zip rm *.zip cd elasticsearch-1.7.1/

  2. Configure es

    apt-get install vim vi ~/elasticsearch-1.7.1/config/elasticsearch.yml #cluster.name: elasticsearch #node.name: "es-node2" #script.inline: on #script.indexed: on

  3. Setting up templates

    Add templates: mkdir ~/elasticsearch-1.7.1/config/templates vi ~/elasticsearch-1.7.1/config/templates/message_template.json # Copy template

  4. Installing plugins

    Install kopf plugin: ~/elasticsearch-1.7.1//bin/plugin --install lmenezes/elasticsearch-kopf/1.5.7

  5. Starting es: /bin/elasticsearch

Make es aut start on boot

Again there are many options to do this using upstart, rc.d, rc.local, cron as explained here Add /home/aapa/softwares/elasticsearch-1.7.1/bin/elasticsearch to the /etc/rc.local file as explained in How to run scripts on start up?.

Make system don’t go to sleep on closing lid

Follow Ubuntu Server 13.10 now goes to sleep when closing laptop lid

Switch off the screen

Follow Turn off monitor using command line

Make the system auto startable

As I am using my old laptop to make the server, it doesn’t have much battery backup. In case the system shutdowns due to any reason be it no power, I want it to start automatically.

Right now I am unabel to find any solution for this, but will update soon. The closest resource I found is: Automatic Reboot After Power Failure

References

  1. How to create a bootable USB stick on Ubuntu
  2. How do I install Ubuntu Server (step-by-step)
  3. Installing 11.04 server via USBstick
  4. Ubuntu server – unattended installation (custom cd)
  5. Ubuntu Server 14.04.2 install error: can’t umount /media
  6. Connect to WiFi network through Ubuntu terminal
  7. How to connect and disconnect to a network manually in terminal?
  8. How do I connect to a WPA wifi network using the command line?
  9. Ubuntu 14.04 Server - WiFi WPA2 Personal
  10. Install SSH server on Ubuntu Linux
  11. How to Install JAVA 8 (JDK 8u66) on CentOS/RHEL and Fedora
  12. Scripting
  13. Index templates
  14. lmenezes/elasticsearch-kopf
  15. Run automatically program on startup under linux ubuntu
  16. Initialize Script on Startup
  17. How to run scripts on start up?.
  18. Ubuntu Server 13.10 now goes to sleep when closing laptop lid
  19. Turn off monitor using command line
  20. Automatic Reboot After Power Failure