设为首页 收藏本站
查看: 1355|回复: 0

[经验分享] installation and basic usage on Ubuntu 16.04-Arnold

[复制链接]

尚未签到

发表于 2019-1-29 14:30:41 | 显示全部楼层 |阅读模式
  Elasticsearch is a powerful production-ready search engine written in Java. It can be used as a standalone search engine for the web or as a search engine for e-commerce web applications.

  eBay,>  In this tutorial, we will be going through the installation steps for Elasticsearch followed by the installation of Kibana. Then we will use Kibana to store and retrieve data.
1 Installing Java
  Since Elasticsearch is written in Java, it has to be installed first. Use the commands below to install the open source versions of JRE and JDK:
  sudo apt-get install default-jre
  sudo apt-get install default-jdk
  These two commands will install the latest open-jre and open-jdk on your system. I'll use JAVA 8 here. The following images show, the output you will get when you do not have java installed and run the above commands.
DSC0000.png

DSC0001.png

2 Install Elasticsearch

  Elasticsearch 5 has been>  mkdir elasticsearch; cd elasticsearch
  wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.deb
  With this, the .deb file should start downloading. It will look similar to the image below:
DSC0002.png

  Once the download is successfully completed, we can install it by running the following command. The output of successful installation is below.
  sudo dpkg -i elasticsearch-5.2.2.deb
DSC0003.png

3 Configure and Run Elasticsearch
  Elasticsearch runs as a background process. But before we start it we have to edit the config file to add the current system as the host running the engine. use the following command to open the config file:
  sudo gedit /etc/elasticsearch/elasticsearch.yml
  Once the editor opens, you have to uncomment the line:
#network.host: 192.168.0.1  and then change the IP to localhost as shown in the image below:
DSC0004.png

  Now, we are ready to run the process. Use the following commands:
  sudo systemctl daemon-reload
  sudo systemctl enable elasticsearch
  sudo systemctl restart elasticsearch
  These three commands add the Elasticsearch process to the system daemon so that it will automatically start when your system boots up and then it restarts the process itself. To test if the system is up and running, use the following command. The output should be similar to the image shown below.
  curl -XGET "http://localhost:9200"
DSC0005.png

4 Install Kibana
  Download and install the deb file using the following commands:
  wget https://artifacts.elastic.co/downloads/kibana/kibana-5.2.2-amd64.deb
  sudo dpkg -i kibana-5.2.2-amd64.deb
  while running the second command, if it asks you to modify the existing Kibana config file, you can press enter to keep defaults and finish the competition. Once it has been installed, it will look similar to the image below.
DSC0006.png

5 Configure and Run Kibana
  in the Kibana configuration file, uncomment the following lines:
server.port:  
server.host:
  
server.name:
  
elasticsearch.name:
  
kibana.index:
  Use the following command to open the config file. The file after you have made the changes should look like the image below:
  sudo gedit /etc/kibana/kibana.yml
  "server.name" can be anything, so feel free to change it. Once these changes are made, save and close the file. The final thing to do is to add Kibana process to the system process list so that it starts automatically each time the system boots up. Run the following commands:
  sudo systemctl daemon-reload
  sudo systemctl enable kibana
  sudo systemctl start kibana
  Once these commands are run, you can open your web browser and use the following URL to test if it has been installed correctly. The image below shows how it should look:
http://localhost:5601
DSC0007.png

  That's it. You have now successfully installed Kibana and Elasticsearch.
6 Basic Usage
  We can use the "Dev Tools" utility provided by Kibana to talk to Elasticsearch. It provides a clean and simple interface to execute the commands as JSON objects. We will be interacting with the core engine through a REST interface.
  Go to the "Dev Tools" by clicking on the DSC0008.png icon on the left Panel. You can also use the following URL:
http://localhost:5601/app/kibana#/dev_tools/  Once it loads, you will get a "Welcome to Console" introduction to the UI. You can read that or just click on the "Get To Work" Button at the bottom of that intro. Once you click on that button, the UI will look like the image below:
DSC0009.png

  On the left side we will type the commands and on the right side panel we will get the output. Let us try to send and store some data to the search engine.
6.1 Create an Index
  Data is stored in an index. To create an index, we use the PUT command. The request JSON will contain the name of the index and some optional settings that we can provide. The following command is an example to create an index called "student".
PUT student  
{
  
"settings": {
  
"number_of_shards": 3
  

  
}
  
}
  You can type this on the "Dev Tools" and press the green play button beside it to run it.  The output will be similar to the image below:
DSC00010.png

6.2 Insert some data to index
  We will be using the POST calls to insert data to index. The data to be inserted is in the form of JSON and so let us go ahead add students to the index. The Command is :
POST student/course  
{
  
"name":"james",
  
"course": "mathematics"
  
}

  In the above command, "course" indicates the type of data that is being indexed. From the response, you can see that, this entry has got a unique>POST student/course/2  
{
  
"name":"tina",
  
"course": "physics"
  
}
  Following are the images that show the response from the search engine when both the commands are run:
DSC00011.png

DSC00012.png

6.3 Fetch data from Index
  You can also fetch data be various fields from the stored record or entry. Each entry that we saved in the previous step is called a document in Elasticsearch. We will be using the GET call to fetch documents from the index. Here is how you can fetch one document using the "name" field:
GET student/course/_search  
{
  
"query": {
  
"term": {
  
"name": {
  
"value": "james"
  
}
  
}
  
}
  
}
  This command searches the "student" index for documents of type "course"  and tries to match a term with field name "name" which has the value "James". Since there is a student named James in the index, we get a response as shown in the image below:
DSC00013.png

  These were just basics, There are tons of things that can be done with Elasticsearch and lots of exploration is required to master this framework and use it to the best of its capability.



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-669280-1-1.html 上篇帖子: spring boot2集成ES详解 下篇帖子: 使用Kibana4
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表