此文摘自https://www.linuxidc.com/Linux/2018-08/153718.htm 作了部分修改java
ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文检索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并做为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,可以达到实时搜索,稳定,可靠,快速,安装使用方便。node
1)JDK8以上环境 2)CentOS7.3,IP地址:192.168.144.112 3)elasticsearch6.3.1
yum install java -y
java -version 查看java版本
首先在官网当中下载es的软件包,本文采用压缩包解压缩安装方式启动服务。linux
tar zxvf elasticsearch-6.3.1.tar.gz -C /opt/
groupadd ela 建立ela组 useradd -g ela ela 建立ela用户,而且加入ela组 passwd ela 为ela用户设定登陆密码 visudo(或者vim /etc/sudoers)
chown -R ela.ela /opt/elasticsearch-6.3.1/ ls -l /opt/elasticsearch-6.3.1/
su ela [ela@localhost ~]$ cd /opt/elasticsearch-6.3.2/config/ [ela@localhost config]$ sudo vim elasticsearch.yml # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # cluster.name: abner //打开设定es群集名称 # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: node-1 //es当前节点名称,用于区分不一样节点 # # 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: /data/es-data //修改数据目录,此目录为自定义,须要在root用户下建立,且属主属组更改成ela # # Path to log files: # path.logs: /var/log/elasticsearch //日志目录位置,需本身建立,方式同上 //yum安装则系统自定义,在软件版本或者系统升级时会被删除,因此建议修改 # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # bootstrap.memory_lock: true //elasticsearch官网建议生产环境须要设置bootstrap.memory_lock: true # # 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 //服务监听端口 #
sudo mkdir -p /data/es-data sudo mkdir -p /var/log/elasticsearch sudo chown -R ela.ela /data/ sudo chown -R ela.ela /var/log/elasticsearch
[ela@localhost /]$ cd /opt/elasticsearch-6.3.2/bin/ [ela@localhost bin]$ ./elasticsearch 后面能够跟上-d后台执行
-当发现如上图没法分配内存错误等,可执行以下操做。(须要在root用户权限下)web
vim /etc/security/limits.conf
* soft nofile 65536 * hard nofile 131072 ela soft memlock unlimited ela hard memlock unlimited
vim /etc/sysctl.conf vm.max_map_count = 655360 //添加 sysctl -p
[ela@localhost abc]$ cd /opt/elasticsearch-6.3.2/bin/ [ela@localhost bin]$ ./elasticsearch
netstat -ntap | grep 9200 tcp6 0 0 :::9200 :::* LISTEN 2095/java