本文共 4542 字,大约阅读时间需要 15 分钟。
环境:软件xshell6,xftp6,JDK1.8安装文件,elasticsearch7.1.1zip.gz文件
首先是上传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
接下来解压,上传的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
# 创建用户组groupadd es# 创建用户useradd -g es elastic# 切换到elastic用户su elastic#设置用户密码 ,后续sudo的时候会用到 passwd elastic
# 更改elasticsearch目录拥有者chown elastic:es -R elasticsearch-7.1.1
#编辑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"]
etc/sysctl.conf 中添加上
vm.max_map_count=655360 保存然后执行
sysctl -p
#切换到root用户修改vim /etc/security/limits.conf# 在最后面追加下面内容 *表示所有用户,记得其后有空格* hard nofile 65536* soft nofile 65536
# 配置文件位置/etc/sudoers
## Allow root to run any commands anywhere root ALL=(ALL) ALL#在这里添加,elsatic是普通用户elastic ALL=(ALL) ALL
curl 127.0.0.1:9200
以及外部浏览器的访问
成功截图
转载地址:http://vzcii.baihongyu.com/