经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 大数据/云/AI » Hadoop » 查看文章
hadoop2-elasticsearch的安装
来源:cnblogs  作者:Hongten  时间:2018/11/22 10:11:05  对本文有异议

本文主要讲elasticsearch-2.2.1的安装过程。

准备工作:

1.搭建虚拟机

你需要先参考

hadoop2集群环境搭建

把你的虚拟机搭建起来-hadoop环境可以先不用搭建(完成步骤1到步骤8

2.下载elasticsearch包

下载elasticsearch-2.2.1.tar.zip

 

这里我搭建的是4台虚拟机(node1,node2,node3,node4)

elasticsearch 只允许普通用户操作,不允许root用户操作

  1. --1.关闭防火墙
  2. service iptables stop
  3. --2.创建用户elsearch
  4. useradd elsearch
  5. --3.给用户elsearch设置密码
  6. passwd elsearch
  7. --4.在/opt目录下面创建elsearch/es/目录
  8. mkdir /opt/elsearch/es/
  9.  
  10. --5.进入到/opt目录下面
  11. cd /opt/
  12.  
  13. --6.elsearch目录以及里面的子目录的权限设置为elsearch
  14. chown -R elsearchelsearch elsearch
  15. --此时,/elsearch, /elsearch/es的权限都应该为elsearch
  16.  
  17. --7.切换用户到elsearch
  18. su elsearch

 

此时,所有节点都应该是elsearch用户,而不是root用户。

现在去到node1节点上面进行操作

  1. --此时,在node1上面操作
  2. --1.此时,我们就可以把下载好的elasticsearch-2.2.1.tar.zip文件上传到node1下面的/opt/elsearch/es/
  3. --2.解压/opt/elsearch/es/elasticsearch-2.2.1.tar.zip文件
  4. cd /opt/elsearch/es/
  5. unzip elasticsearch-2.2.1.tar.zip
  6. --3.修改配置文件
  7. cd /opt/elsearch/es/elasticsearch-2.2.1/conf/
  8. vi elasticsearch.yml
  9. # ======================== Elasticsearch Configuration =========================
  10. #
  11. # NOTE: Elasticsearch comes with reasonable defaults for most settings.
  12. # Before you set out to tweak and tune the configuration, make sure you
  13. # understand what are you trying to accomplish and the consequences.
  14. #
  15. # The primary way of configuring a node is via this file. This template lists
  16. # the most important settings you may want to configure for a production cluster.
  17. #
  18. # Please see the documentation for further information on configuration options:
  19. # <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
  20. #
  21. # ---------------------------------- Cluster -----------------------------------
  22. #
  23. # Use a descriptive name for your cluster:
  24. #
  25. cluster.name: elsearch-app
  26. #
  27. # ------------------------------------ Node ------------------------------------
  28. #
  29. # Use a descriptive name for the node:
  30. #
  31. node.name: node1
  32. #
  33. # Add custom attributes to the node:
  34. #
  35. # node.rack: r1
  36. #
  37. # ----------------------------------- Paths ------------------------------------
  38. #
  39. # Path to directory where to store the data (separate multiple locations by comma):
  40. #
  41. # path.data: /path/to/data
  42. #
  43. # Path to log files:
  44. #
  45. # ----------------------------------- Memory -----------------------------------
  46. #
  47. # Lock the memory on startup:
  48. #
  49. # bootstrap.mlockall: true
  50. #
  51. # Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
  52. # available on the system and that the owner of the process is allowed to use this limit.
  53. #
  54. # Elasticsearch performs poorly when the system is swapping the memory.
  55. #
  56. # ---------------------------------- Network -----------------------------------
  57. #
  58. # Set the bind address to a specific IP (IPv4 or IPv6):
  59. #
  60. network.host: 192.168.79.138
  61. #
  62. # Set a custom port for HTTP:
  63. #
  64. http.port: 9200
  65. #
  66. # For more information, see the documentation at:
  67. # <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
  68. #
  69. #
  70. # discovery.zen.ping.unicast.hosts: ["host1", "host2"]
  71. #
  72. # Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
  73. #
  74. # discovery.zen.minimum_master_nodes: 3
  75. #
  76. # For more information, see the documentation at:
  77. # <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
  78. #
  79. # ---------------------------------- Gateway -----------------------------------
  80. #
  81. # Block initial recovery after a full cluster restart until N nodes are started:
  82. #
  83. # gateway.recover_after_nodes: 3
  84. #
  85. # For more information, see the documentation at:
  86. # <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
  87. #
  88. # ---------------------------------- Various -----------------------------------
  89. #
  90. # Disable starting multiple nodes on a single system:
  91. #
  92. # node.max_local_storage_nodes: 1
  93. #
  94. # Require explicit names when deleting indices:
  95. #
  96. # action.destructive_requires_name: true
  97. discovery.zen.ping.multicast.enabled: false
  98. discovery.zen.ping.unicast.hosts: ["192.168.79.138","192.168.79.139", "192.168.79.140","192.168.79.141"]
  99. discovery.zen.ping_timeout: 120s
  100. client.transport.ping_timeout: 60s
  101. :wq
  102. --4.然后从node1分发到其他节点(node2, node3, node4)的相同目录
  103. cd /opt/elsearch/es
  104. scp -r ./elasticsearch-2.2.1 elsearch@node2:/opt/elsearch/es
  105. scp -r ./elasticsearch-2.2.1 elsearch@node3:/opt/elsearch/es
  106. scp -r ./elasticsearch-2.2.1 elsearch@node4:/opt/elsearch/es

接下来在node2,node3,node4上面进行操作

  1. --分别修改node2node3node4上面的配置文件
  2. cd /opt/elsearch/es/elasticsearch-2.2.1/conf/
  3. vi elasticsearch.yml
  4. --修改两个地方
  5. --1.node.name: node1
  6. --2.network.host: 192.168.79.138
  7.  
  8. --修改为和下面相对应,然后保存
  9. 192.168.79.138 node1
  10. 192.168.79.139 node2
  11. 192.168.79.140 node3
  12. 192.168.79.141 node4

 

最后,在所有节点(node1,node2,node3,node4)上面进行操作

  1. --启动elasticsearch
  2. cd /opt/elsearch/es/elasticsearch-2.2.1/bin
  3. ./elasticsearch

 

打开浏览器,输入:node1:9200可以看见一下效果

 

添加插件elasticsearch-head

下载elasticsearch-head

把下载好的插件重命名为

  1. head

然后添加到所有节点(node1,node2,node3,node4)的

  1. /opt/elsearch/es/elasticsearch-2.2.1/plugins

目录。

 

然后重启所有节点。

  1. --启动elasticsearch
  2. cd /opt/elsearch/es/elasticsearch-2.2.1/bin
  3. ./elasticsearch

 

效果如下:

了解更多:elasticsearch-head

 

========================================================

More reading,and english is important.

I'm Hongten

 

  1. 大哥哥大姐姐,觉得有用打赏点哦!你的支持是我最大的动力。谢谢。
    Hongten博客排名在100名以内。粉丝过千。
    Hongten出品,必是精品。

E | hongtenzone@foxmail.com  B | http://www.cnblogs.com/hongten

======================================================== 

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号