欢迎访问 生活随笔!

凯发ag旗舰厅登录网址下载

当前位置: 凯发ag旗舰厅登录网址下载 > 运维知识 > linux >内容正文

linux

elasticsearch集群部署【windows linux双系统搭建】 -凯发ag旗舰厅登录网址下载

发布时间:2024/10/5 linux 33 豆豆
凯发ag旗舰厅登录网址下载 收集整理的这篇文章主要介绍了 elasticsearch集群部署【windows linux双系统搭建】 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

es集群部署

  • 一、windows部署
  • 二、linux单节点部署
  • 三、linux集群部署

如果已经使用过,删除其中的data和logs文件夹中的内容

新建一个es-cluster文件夹,用于存放集群中的三个es结点

1.结点1(master)配置

首先打开node-1文件夹->config目录下-》bin目录下的elasticsearch.yml文件

2.改变以下内容

不要在配置文件中加入中文注释,启动会失败

# ======================== 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 //结点名 node.master: true //既做为master node.data: true //也做为data # # 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: 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: localhost //ip地址,我在本地搭建 # # set a custom port for http: # http.port: 9200 //es启动端口 transport.tcp.port: 9201 //通信端口,因为各个结点之间要进行通信 # # 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", "node-2"] # # 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: true http.cors.enabled: true //跨域设置 http.cors.allow-origin: "*"

2.结点2配置

打开node-2文件夹-》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: my-application //集群名要一致 # # ------------------------------------ node ------------------------------------ # # use a descriptive name for the node: # node.name: node-2 //结点名不一致 node.master: true node.data: true # # 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: 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: localhost # # set a custom port for http: # http.port: 9300 transport.tcp.port: 9301 discovery.seed_hosts: ["localhost:9201"] //这是为了发现其他结点 discovery.zen.fd.ping_timeout: 1m //9201代表了master(node-1)的通信端口 discovery.zen.fd.ping_retries: 5 # # 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", "node-2"] # # 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: true http.cors.enabled: true http.cors.allow-origin: "*"

3.结点3配置

# ======================== 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-3 node.master: true node.data: true # # 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: 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: localhost # # set a custom port for http: # http.port: 9400 transport.tcp.port: 9401 discovery.seed_hosts: ["localhost:9201","localhost:9301"] //发现结点1和结点2(9201是node-1的通信端口,9301是node-2的通信端口 discovery.zen.fd.ping_timeout: 1m discovery.zen.fd.ping_retries: 5 # # 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", "node-2"] # # 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: true http.cors.enabled: true http.cors.allow-origin: "*"

4.使用postman进行测试

依次启动node-1,node-2,node-3




(1)cd到/usr/local目录下,新建es文件夹,cd到es文件夹下

cd /usr/local/
mkdir es
cd es

(2)下载elasticsearch

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-linux-x86_64.tar.gz
es下载教程:https://blog.csdn.net/kevinnsm/article/details/120604537?spm=1001.2014.3001.5501


(3)解压缩

tar -zxvf elasticsearch-7.10.1-linux-x86_64.tar.gz

(4)改变文件名为es

mv elasticsearch-7.10.1 es

(5)🌞新建es用户

📜linux环境下elasticsearch不能以root用户启动,所以需要新建用户

🧊创建用户名为es的用户,输入useradd es

🧊为es用户设置密码,passwd es(密码要满足大于8位且含有大小写字母已经数字,否者会匹配失败)

(6)🌞修改文件目录的所有者

chown:表示修改文件的所有者和所属组
chown [-r] 所有者:所属组 文件或目录
chown -r es:es /usr/local/es/es


(7)🌞修改elasticsearch.yml文件内容
在文件末尾加入以下内容

cluster.name: elasticsearch
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: [“node-1”]


(8)🌞修改 /etc/security/limits.conf中的内容

由于es生成得内容比较多,所以需要修改相关配置


在文件末尾加入
es soft nofile 65535
es hard nofile 65535

加粗样式(9)🌞修改20-nproc.conf文件

vim /etc/security/limits.d/20-nproc.conf


(10)🌞修改/etc/sysctl.conf文件

vim /etc/sysctl.conf

在文件底部加入vm.max_map_count = 655360

重新加载

sysctl -p

(11)🌞切换到es用户下,启动elasticsearch

启动脚本在bin目录下


在es用户下启动报错是因为elasticsearch在第一次启动过程中,会动态的生成一些文件,因为是刚生成的,所以es用户没有相应权限。则需要再次设置文件所有权
1.切换到root用户下(在es用户下是无法改变文件所有权的)
2.执行chown -r es:es /usr/local/es/es/


(12)🌞再次切换到es目录,启动即可


(13)🌞访问ip:9200即可

如果是云服务器需要开放9200端口

持续更新中…

总结

以上是凯发ag旗舰厅登录网址下载为你收集整理的elasticsearch集群部署【windows linux双系统搭建】的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。

  • 上一篇:
  • 下一篇:
网站地图