博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos系统安装elasticsearch
阅读量:4090 次
发布时间:2019-05-25

本文共 4542 字,大约阅读时间需要 15 分钟。

1.安装过程

  环境:软件xshell6,xftp6,JDK1.8安装文件,elasticsearch7.1.1zip.gz文件

1.1.安装JDK1.8

首先是上传JDK1.8的文件,这里通过xft6进行上传

修改JDK的环境变量,path ,JAVA_HOME ,classpath

在root用户下,修改配置文件

# vi /etc/profile

接下来在文件末尾增加如下代码:

export JAVA_HOME=/java/jdk1.8.0_131export PATH=$JAVA_HOME/bin:$PATHexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib

然后更新下,这样子不仅root用户的JDK 环境可以配置,elastic search环境也可以配置。(为安装elasticsearch 需要新增加用户做铺垫)

#  source /etc/profile

 

1.2解压文件

接下来解压,上传的elasticsearch压缩文件,这里选择的安装包是elasticsearch-7.1.1-linux-x86_64.tar.gz,

这里是在root环境下进行的解压(也只能如此,博主尝试在elastic用户解压,权限不予许),这里存放的路径是

/usr/local/software/elasticsearch-7.1.1

# tar -zxvf elasticsearch-7.1.1-linux-x86_64.tar.gz

1.3创建新的用户

# 创建用户组groupadd es# 创建用户useradd -g es elastic# 切换到elastic用户su elastic#设置用户密码 ,后续sudo的时候会用到 passwd  elastic

1.4文件赋予权限

# 更改elasticsearch目录拥有者chown elastic:es -R elasticsearch-7.1.1

1.5修改elastic配置文件

#编辑elasticsearch配置文件#vi config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================## NOTE: Elasticsearch comes with reasonable defaults for most settings.#       Before you set out to tweak and tune the configuration, make sure you#       understand what are you trying to accomplish and the consequences.## The primary way of configuring a node is via this file. This template lists# the most important settings you may want to configure for a production cluster.## Please consult the documentation for further information on configuration options:# https://www.elastic.co/guide/en/elasticsearch/reference/index.html## ---------------------------------- Cluster -----------------------------------## Use a descriptive name for your cluster:#cluster.name: my-application## ------------------------------------ Node ------------------------------------## Use a descriptive name for the node:#node.name: node-1## Add custom attributes to the node:##node.attr.rack: r1## ----------------------------------- Paths ------------------------------------## Path to directory where to store the data (separate multiple locations by comma):#path.data: /path/to/data## Path to log files:#path.logs: /path/to/logs## ----------------------------------- Memory -----------------------------------## Lock the memory on startup:#bootstrap.memory_lock: falsebootstrap.system_call_filter: false ## Make sure that the heap size is set to about half the memory available# on the system and that the owner of the process is allowed to use this# limit.## Elasticsearch performs poorly when the system is swapping the memory.## ---------------------------------- Network -----------------------------------## Set the bind address to a specific IP (IPv4 or IPv6):#network.host: 0.0.0.0## Set a custom port for HTTP:#http.port: 9200## For more information, consult the network module documentation.## --------------------------------- Discovery ----------------------------------## Pass an initial list of hosts to perform discovery when this node is started:# The default list of hosts is ["127.0.0.1", "[::1]"]##discovery.seed_hosts: ["host1", "host2"]## Bootstrap the cluster using an initial set of master-eligible nodes:#cluster.initial_master_nodes: ["node-1"]## For more information, consult the discovery and cluster formation module documentation.## ---------------------------------- Gateway -----------------------------------## Block initial recovery after a full cluster restart until N nodes are started:##gateway.recover_after_nodes: 3## For more information, consult the gateway module documentation.## ---------------------------------- Various -----------------------------------## Require explicit names when deleting indices:##action.destructive_requires_name: truehttp.cors.enabled: truehttp.cors.allow-origin: "*"

1)解决启动elasticsearch的时候,bootstrap的相关报错bootstrap checks failed

      bootstrap.memory_lock: false

      bootstrap.system_call_filter: false 

2)解决外部浏览器可以访问的问题

      http.cors.enabled: true

      http.cors.allow-origin: "*"

     network.host: 0.0.0.0 

3)重要设置

cluster.initial_master_nodes: ["node-1"]

2.安装碰到的问题

2.1报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least

etc/sysctl.conf 中添加上

vm.max_map_count=655360  保存然后执行

sysctl -p

2.2max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

#切换到root用户修改vim /etc/security/limits.conf# 在最后面追加下面内容 *表示所有用户,记得其后有空格* hard nofile 65536* soft nofile 65536

2.3sudo命令的配置

# 配置文件位置/etc/sudoers
## Allow root to run any commands anywhere root    ALL=(ALL)       ALL#在这里添加,elsatic是普通用户elastic ALL=(ALL)       ALL

 

3.成功的访问

curl 127.0.0.1:9200

以及外部浏览器的访问

成功截图

 

转载地址:http://vzcii.baihongyu.com/

你可能感兴趣的文章
乘法逆元
查看>>
Objective-C 基础入门(一)
查看>>
Objective-C 基础入门(三) 读写文件与回调
查看>>
C++ STL标准库与泛型编程(一)概述
查看>>
C++ STL标准库与泛型编程(四)Deque、Queue、Stack 深度探索
查看>>
C++ STL标准库 算法
查看>>
JVM内存模型_Minor GC笔记
查看>>
SpringCloud学习之PassCloud——(一)PassCloud源代码下载
查看>>
Nginx篇-springCloud配置Gateway+Nginx进行反向代理和负载均衡
查看>>
缓存篇-Redis缓存失效以及解决方案
查看>>
缓存篇-使用Redis进行分布式锁应用
查看>>
缓存篇-Redisson的使用
查看>>
phpquery抓取网站内容简单介绍
查看>>
找工作准备的方向(4月22日写的)
查看>>
关于fwrite写入文件后打开查看是乱码的问题
查看>>
用结构体指针前必须要用malloc,不然会出现段错误
查看>>
Linux系统中的美
查看>>
一些实战项目(linux应用层编程,多线程编程,网络编程)
查看>>
原来k8s docker是用go语言写的,和现在所讲的go是一个东西!
查看>>
STM32CubeMX 真的不要太好用
查看>>