elasticsearch5.4.1 linux 搭建集群

来源:互联网 发布:淘宝到家保洁好吗 编辑:程序博客网 时间:2024/05/16 04:49

下载地址: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/"

[javascript] view plain copy
  1. {  
  2.   "name" : "node-1",  
  3.   "cluster_name" : "edgeserver",  
  4.   "cluster_uuid" : "n8My_gsHR6GYLdvCHV1-Ug",  
  5.   "version" : {  
  6.     "number" : "5.4.0",  
  7.     "build_hash" : "780f8c4",  
  8.     "build_date" : "2017-04-28T17:43:27.229Z",  
  9.     "build_snapshot" : false,  
  10.     "lucene_version" : "6.5.0"  
  11.   },  
  12.   "tagline" : "You Know, for Search"  
  13. }  

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


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个节点都启动好了

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 地铁站务员入职体检身高差点怎么办 车子钥匙锁在车里了怎么办 打错账户了怎么办5天了 下岗失业人员在就业后档案怎么办 皮秒祛斑后没有敷面膜怎么办 硕士毕业工资好低不想工作怎么办 车卖了etc忘拿了怎么办 成熟卵泡打破卵针也不破怎么办? 深圳孩子户口挂别人名下上学怎么办 襄阳东风合运花园房贷怎么办下来 猫在外面躲起来找不到了怎么办 本科三批取消以后三本学校怎么办 机票名字多了个字母安检怎么办 出隧道口限速40超速了怎么办 社保交了五年后断交以后该怎么办 躺椅折叠椅坐的地方坏了怎么办 苹果手机锁频密码忘了怎么办 客户要货公司不给进怎么办 高铁23:00买的票怎么办 带电子手刹的车刹车失灵怎么办 下坡刹车失灵遇行人不看车怎么办 跟大车后面看不见红灯闯了怎么办 跟着大货车后面闯了红灯怎么办 如果用工单位不发放加班工资怎么办 事故家属要司机向医院多交钱怎么办 在大学里和室友关系弄僵怎么办 房产证办出来房产局不给证怎么办 单位全员竞聘老员工没岗位怎么办 快件被快递公司签收了没给送怎么办 总公司跑路了分公司代理法人怎么办 大使馆领的结婚证现在离婚怎么办 日本签证照片被使馆贴错了怎么办 在菲律宾护照和签证丢了怎么办 新疆工地上班老板不肯发工资怎么办 德国大使馆签证如果拒签了怎么办 护照在大使馆办签证期间出国怎么办 法院两次判决不准离婚我该怎么办? 法院判决不准离婚妻子不回来怎么办 被告人在不调解的情况下怎么办 知道弟兄的孩子是别人的怎么办? 办居住证的回执单丢了怎么办