ElasticSearch在linux上安装部署 傷城~ 2022-12-21 03:08 179阅读 0赞 一.安装准备工作 安装参考文档: ELK官网:[https://www.elastic.co/][https_www.elastic.co] ELK官网文档:[https://www.elastic.co/guide/index.html][https_www.elastic.co_guide_index.html] ELK中文手册:[https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html][https_www.elastic.co_guide_cn_elasticsearch_guide_current_index.html] ELK中文社区:[https://elasticsearch.cn/][https_elasticsearch.cn] ELK-API :[https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html][https_www.elastic.co_guide_en_elasticsearch_client_java-api_current_transport-client.html] (1)、规划安装目录 /usr/local (2)、下载安装包 访问elasticSearch官网地址 [https://www.elastic.co/][https_www.elastic.co] 下载指定版本的安装包:elasticsearch-6.6.0.tar.gz (3)、上传安装包到指定目录 通过[FTP工具][FTP]上传安装包到指定目录, 或者在服务器目录下直接下载: wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz (4)、解压安装包 tar -zxvf elasticsearch-6.6.0.tar.gz -C /export/servers (5)、重命名安装目录 mv elasticsearch-6.6.0 elasticsearch (6)、修改配置文件 进入到es安装目录下的config文件夹中,修改elasticsearch.yml 文件 修改的主要内容: ![复制代码][48304ba5e6f9fe08f3fa1abda7d326ab.png] #配置es的集群名称,默认是elasticsearch,es会自动发现在同一网段下的es,如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。 cluster.name: my-es #节点名称 node.name: node-1 #设置索引数据的存储路径 path.data: /usr/local/elasticsearch/data #设置日志的存储路径 path.logs: /usr/local/elasticsearch/logs #设置当前的ip地址,通过指定相同网段的其他节点会加入该集群中 network.host: 0.0.0.0 #设置对外服务的http端口 http.port: 9200 #设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点 discovery.zen.ping.unicast.hosts: ["127.0.0.1","10.10.10.34:9200"] ![复制代码][48304ba5e6f9fe08f3fa1abda7d326ab.png] 注: 1、补齐必要的目录 mkdir -p /usr/local/elasticsearch/data mkdir -p /usr/local/elasticsearch/logs (目录可能已经存在,需先确定清楚) 2、network.host: 0.0.0.0 修改Elasticsearch的配置,使其支持外网访问。在浏览器中,访问http://xxxx:9200/(xxxx是运行elasticsearch的服务器的ip地址)即可。否则这可以在本机使用。 # 二.解决启动时报错 # (1)、在[root][]用户下启动时报错 ![61acc961e46f9646fbbfab9d20b47682.png][] 因为安全问题elasticsearch 不让用root用户直接运行,所以要创建新用户。 具体操作如下: useradd testuser passwd testuser 再输入两次密码(自定义) 为用户赋权限 chown -R testuser:testuser /usr/local/elasticsearch 然后使用es用户启动 :su testuser cd /usr/local/elasticsearch 启动es命令:bin/elasticsearch (2)、在testuser用户下启动时报错 ![1442cbcf3b93999ab3c14d30ca4af699.png][] 为用户赋权限 chown -R testuser:testuser /usr/local/elasticsearch 然后使用es用户启动 :su testuser cd /usr/local/elasticsearch 启动es命令:bin/elasticsearch (3)、在testuser用户下启动时报错 ![5379f4c22f57670723770d9c2b75de61.png][] 原因:Centos6不支持SecComp,而ES默认bootstrap.system\_call\_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。 详见 :[https://github.com/elastic/elasticsearch/issues/22899][https_github.com_elastic_elasticsearch_issues_22899] 解决方案: 在elasticsearch.yml中新增配置bootstrap.system\_call\_filter,设为false。 bootstrap.system\_call\_filter: false ![3320174a9f4292dfc2fc32041609f237.png][] (4)、在testuser用户下启动继续报错 ![6f9c1c37f645c085e7b8df0f9a842c1c.png][] a、原因:无法创建本地文件问题,用户最大可创建文件数太小,解决方案:切换到root用户,编辑limits.conf配置文件, 添加类似如下内容: vi /etc/security/limits.conf 然后添加如下内容: 注意\*不要去掉了 \* soft nofile 65536 \* hard nofile 131072 注:\* 代表Linux所有用户名称(比如 hadoop) 需要保存、退出、重新登录才可生效。 b、原因:最大虚拟内存太小,解决办法切换到[root][]用户修改配置sysctl.conf: vi /etc/sysctl.conf 添加下面配置: vm.max\_map\_count=655360 最后记得执行: sysctl -p 然后,重新启动elasticsearch,即可启动成功。 # 三.测试 # 切换到testuser用户执行: ![042c076d84a35a3ec2e75f3b194ce8b6.png][] 看到这个界面证明已经成功了,可以用浏览器访问ip:9200查看,会下载一个json文件打开如下: ![1c715a37e5e2098d1f72bb6a56357e4d.png][] 至此Elasticsearch就安装完成了,当然这只是一台机器,如果有需要还可以搭成集群. # 三.ES插件安装 # 1、安装head elasticsearch-head是一个界面化的集群操作和管理工具,可以对集群进行傻瓜式操作。你可以通过插件把它集成到es(首选方式),也可以安装成一个独立webapp。 es-head主要有三个方面的操作: a、显示集群的拓扑,并且能够执行索引和节点级别操作 b、搜索接口能够查询集群中原始json或表格格式的检索数据 c、能够快速访问并显示集群的状态 有一个输入窗口,允许任意调用RESTful API。这个接口包含几个选项,可以组合在一起以产生有趣的结果; 请求方法(get、put、post、delete),查询json数据,节点和路径 支持JSON验证器 支持重复请求计时器 支持使用javascript表达式变换结果 收集结果的能力随着时间的推移(使用定时器),或比较的结果,能力图表转换后的结果在一个简单的条形图(包括时间序列) 1), 直接安装 ./bin/plugin install mobz/elasticsearch-head 2) ,zip包安装 1. https://github.com/mobz/elasticsearch-head下载zip 解压 2. 建立elasticsearch-2.4.0\plugins\head文件 3. 将解压后的elasticsearch-head-master文件夹下的文件copy到head 4. 运行es 安装验证: ![6c21546022fe8fcea5101000a8bc3a7e.png][] 2, 安装其他插件 ![复制代码][48304ba5e6f9fe08f3fa1abda7d326ab.png] ![复制代码][48304ba5e6f9fe08f3fa1abda7d326ab.png] $ ${ES_HOME}/bin/plugin --install lukas-vlcek/bigdesk # 安装完成访问:http://localhost:9200/_plugin/bigdesk/#nodes $ ${ES_HOME}/bin/plugin -install royrusso/elasticsearch-HQ # 安装完成访问:http://localhost:9200/_plugin/HQ/ $ ${ES_HOME}/bin/plugin -install lmenezes/elasticsearch-kopf # 安装完成访问:http://localhost:9200/_plugin/kopf/#!/cluster ![复制代码][48304ba5e6f9fe08f3fa1abda7d326ab.png] ![复制代码][48304ba5e6f9fe08f3fa1abda7d326ab.png] [https_www.elastic.co]: https://www.elastic.co/ [https_www.elastic.co_guide_index.html]: https://www.elastic.co/guide/index.html [https_www.elastic.co_guide_cn_elasticsearch_guide_current_index.html]: https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html [https_elasticsearch.cn]: https://elasticsearch.cn/ [https_www.elastic.co_guide_en_elasticsearch_client_java-api_current_transport-client.html]: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html [FTP]: https://www.baidu.com/s?wd=FTP%E5%B7%A5%E5%85%B7&tn=24004469_oem_dg&rsv_dl=gh_pl_sl_csd [48304ba5e6f9fe08f3fa1abda7d326ab.png]: /images/20221120/5b8cfb1cb8024651a01ae5a2d63424dc.png [root]: https://www.baidu.com/s?wd=root&tn=24004469_oem_dg&rsv_dl=gh_pl_sl_csd [61acc961e46f9646fbbfab9d20b47682.png]: /images/20221120/358318a2b3ef429ab52c2ab5e821ddc6.png [1442cbcf3b93999ab3c14d30ca4af699.png]: /images/20221120/3cbfd478a2bb45738d18a3743c8e713d.png [5379f4c22f57670723770d9c2b75de61.png]: /images/20221120/06a057d34c1e40c7af61abdf74874517.png [https_github.com_elastic_elasticsearch_issues_22899]: https://github.com/elastic/elasticsearch/issues/22899 [3320174a9f4292dfc2fc32041609f237.png]: /images/20221120/16550160972f41cd8136695b43f59ba9.png [6f9c1c37f645c085e7b8df0f9a842c1c.png]: /images/20221120/923edf9d38c84eb1b806d5dfdb9bd776.png [042c076d84a35a3ec2e75f3b194ce8b6.png]: /images/20221120/803ec101e02e4b96976b88cc1cac49fe.png [1c715a37e5e2098d1f72bb6a56357e4d.png]: /images/20221120/225b88e5e81145088bac57b10fc1ccf6.png [6c21546022fe8fcea5101000a8bc3a7e.png]: /images/20221120/bb59e2f5e7c84fbebe5d7c6958c1cd72.png
还没有评论,来说两句吧...