ElasticSearch 5.4 Linux安装教程

来源:互联网 发布:linux怎么查看gpu型号 编辑:程序博客网 时间:2024/05/16 15:01

下载地址:https://www.elastic.co/downloads/past-releases/elasticsearch-5-4-1


首先新建用户,es规定root用户不能启动es,所以必须新建用户

groupadd es

useradd -g es es

chown es:es elasticsearch-5.4.1.zip

su es 切换到es用户执行以下命令操作


unzip elasticsearch-5.4.1.zip 解压缩

如果你只想玩玩单机版的话,解压缩直接就可以使用了


如果你想做集群测试,请继续往下看

ln -s elasticsearch-5.4.1 es生成一个快捷方式,方便记忆路径

cd es/config 进入es的配置文件夹,其实在linux上的很多开源软件都喜欢把配置文件放在config/conf文件夹下面


修改集群配置,下面是完整的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: edgeserver #集群名称,要部署为同一个集群,这个名称必须相同
#
# ------------------------------------ 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: false  #这两个配置最好配置上,否则会报错
bootstrap.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: 10.100.124.205 #要对外开放的IP地址
#
# Set a custom port for HTTP:
#
http.port: 9200 #restful接口调用端口
transport.tcp.port: 9300  #集群内部传输端口
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
# #集群里所有的ip地址和端口
discovery.zen.ping.unicast.hosts: ["10.100.124.205:29300", "10.100.124.206:29300", "10.100.124.207:29300", "10.100.124.208:29300"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery 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: true
xpack.security.enabled: false #如果你安装了xpack,这个要配置上,否则集群的节点之间无法通信,因为要登录密码

# ======================== Elasticsearch Configuration =========================


把elasticsearch拷贝到其他集群节点上,修改上面配置文件的节点名称(node.name)即可


启动集群

在各节点上进入es/bin

执行:./elasticsearch -d


测试

curl "http://10.100.124.205:29200/"

{  "name" : "node-1",  "cluster_name" : "edgeserver",  "cluster_uuid" : "n8My_gsHR6GYLdvCHV1-Ug",  "version" : {    "number" : "5.4.0",    "build_hash" : "780f8c4",    "build_date" : "2017-04-28T17:43:27.229Z",    "build_snapshot" : false,    "lucene_version" : "6.5.0"  },  "tagline" : "You Know, for Search"}

像类似的返回,表示启动节点成功


curl "http://10.100.124.205:29200/_cat/nodes"

10.100.124.205 37 93 8 1.01 1.04 1.02 mdi * node-1
10.100.124.207 37 95 0 0.00 0.00 0.00 mdi - node-3
10.100.124.208 56 85 0 0.13 0.08 0.02 mdi - node-4
10.100.124.206 57 99 0 0.17 0.12 0.09 mdi - node-2

根据返回结果,可以知道集群的4个节点都启动好了

原创粉丝点击