Setup Elasticsearch and Kibana on Ubuntu 18.04 on a single node

Topic created · 1 Posts · 3 Views
  • This is for test / non prod environments

    Requirements

    Even for a test environment, considering that both Elasticsearch and Kibana will consume memory anc cpu, we need at least 1 VM with 16g of ram and 4vCPU

    Installation

    We need to install the following packages in our system:

    • openjdk-11-jre-headless
    • apt-transport-https
    • elasticsearch
    • kibana

    To do so we will execute the following commands as root:

    apt install openjdk-11-jre-headless
    apt-get install apt-transport-https
    
    

    Add the elasticsearch GPG key and repo

    wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
    add-apt-repository "deb https://artifacts.elastic.co/packages/7.x/apt stable main"
    

    Then, proceed to install Kibana and elasticsearch

    apt-get update
    apt-get install kibana
    apt-get install elasticsearch
    

    Configuration

    Prior to start the services, we will need to perform a initial configuration

    Edit the file /etc/elasticsearch/elasticsearch.yml and add the following parameters:

    Replace the cluster name, node name, publish host and initial mater nodes values by your host IP address

    cluster.name: mycluster
    node.name: elkserver
    network.host: 192.168.1.73
    network.publish_host: 192.168.1.73
    node.master: true
    node.data: true
    action.auto_create_index: true
    http.port: 9200
    cluster.initial_master_nodes: 192.168.1.73
    index.number_of_replicas: 0
    

    Then, edit the kibana config file /etc/kibana/kibana.yml and add the following parameters:
    (replace the elastic host IP for your IP)

    server.port: 5601
    server.host: "0.0.0.0"
    server.name: "elkserver"
    elasticsearch.hosts: ["http://192.168.1.73:9200"]
    kibana.index: ".kibana"
    

    Start Services

    Then, start the elastic service by executing

    systemctl enable elasticsearch.service
    systemctl start elasticsearch.service
    

    Start also the kibana service:

    systemctl enable kibana.service
    systemctl start kibana.service
    

    Validate

    From any other node, you can verify that Elasticsearch is accessible by querying its status by running:

    curl -X GET "http://192.168.1.73:9200/?pretty"
    

    Result:

    curl -X GET "http://192.168.1.73:9200/?pretty"
    {
      "name" : "elkserver",
      "cluster_name" : "mycluster",
      "cluster_uuid" : "q3aOcBEsQWOGfuT0_5bWqg",
      "version" : {
        "number" : "7.6.0",
        "build_flavor" : "default",
        "build_type" : "deb",
        "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
        "build_date" : "2020-02-06T00:09:00.449973Z",
        "build_snapshot" : false,
        "lucene_version" : "8.4.0",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    

    You can also verify the node:

    curl -XGET 'http://192.168.1.73:9200/_cat/nodes?v&pretty'
    
    curl -XGET 'http://192.168.1.73:9200/_cat/nodes?v&pretty'
    ip           heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
    192.168.1.73           45          37   1    0.00    0.01     0.04 dilm      *      elkserver
    

    Then, you can create your first index

    curl -XPUT "http://192.168.1.73:9200/myfirstindex"
    

    And verify its creation

    curl -XGET 'http://192.168.1.73:9200/_cat/indices?v&pretty'
    

    Result:

    curl -XGET 'http://192.168.1.73:9200/_cat/indices?v&pretty'
    health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
    green  open   .kibana_task_manager_1   jHpC_e8mRzq5A8JdwHVu_g   1   0          2            0     43.4kb         43.4kb
    green  open   .apm-agent-configuration yoVyzzG5S56Q05Mqxghaog   1   0          0            0       283b           283b
    green  open   .kibana_1                2oE1URIITm6KNwqYgEd9ng   1   0         16            0     36.7kb         36.7kb
    green  open   myfirstindex             0bNB5LNMT6m31rHeTy_usQ   1   1          0            0       230b           230b
    

    Finally, access the Kibana dashboard by typing in your browser your host url on port 5601

    alt text

Log in to reply