Steps to install Elasticsearch on Ubuntu 16.04
Create the elastic source list
update the apt packages on database
then install elasticsearch
elasticsaerch will be installed on /etc/elasticsearch
you can test wheter elasticsaerch is running by viewing the status log or try to hit the api by running this command
the result should be as follow
{
"name" : "Barbara-Gordon",
"cluster_name" : "myCluster",
"version" : {
"number" : "2.3.3",
"build_hash" : "218bdf10790eef486ff2c41a3df5cfa32dadcfde",
"build_timestamp" : "2016-05-17T15:40:04Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
Install Elasticsearch
Run the following to import elasticsearch public GPGwget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
Create the elastic source list
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
update the apt packages on database
sudo apt-get update
then install elasticsearch
sudo apt-get -y install elasticsearch
elasticsaerch will be installed on /etc/elasticsearch
Configure Elasticsearch
Next we should configure elasticsearch by modifying the elasticsearch.yml filesudo nano /etc/elasticsearch/elasticsearch.yml
Set Cluster Name
first you need to set up cluster name to the name of your cluster, otherwise the default is "elasticsearch"cluster.name: myCluster
Set Node Name
then configure the node name, otherwise a random name will be assignednode.name: Barbara-Gordon
Set Network address and port
the default network host is set to localhost and port 9200, which only allow elastic to be accessed locally, you can set it to 0.0.0.0 so that elasticsearch can be accessed locally and from outside.network.host: 0.0.0.0 http.port: 9200
Set master and data configuration
An elasticsearch can behave either master or data node, or can also be both which you can configure on node.master and node.slave item, if we try to set a standalone server then set it tonode.master = true node.slave = true
Set number of shards and replica
On elasticsearch data can be stored in many shards and replicated a few times, which you can configure on index.number_of_shards and index.number_of_replicas, if we try to set a standalone server, it can be set toindex.number_of_shards: 1 index.number_of_replicas: 0because on a standalone server you want to put data on single shards without replication
Run Elasticsearch
to run elasticsearch you can start, stop and check status with the following commandsudo service elasticsearch start sudo service elasticsearch stop sudo service elasticsearch status
you can test wheter elasticsaerch is running by viewing the status log or try to hit the api by running this command
curl localhost:9200
the result should be as follow
{
"name" : "Barbara-Gordon",
"cluster_name" : "myCluster",
"version" : {
"number" : "2.3.3",
"build_hash" : "218bdf10790eef486ff2c41a3df5cfa32dadcfde",
"build_timestamp" : "2016-05-17T15:40:04Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
No comments :
Post a Comment