关闭防火墙
7.17.1单节点安装部署
点击下载Linux版es7.17.1(网络原因,下载可能会慢,297MB)
-
上传到 /opt/es_7.17.1 目录下,并解压、重命名
cd /opt/ mkdir es_7.17.1 tar -zxvf elasticsearch-7.17.1-linux-x86_64.tar.gz
因为安全问题,es不允许使用root用户运行,需要创建新用户,命令:
# 新增用户 useradd ziye # 设置密码 passwd ziye # 输入两次密码
修改配置信息,修改如下配置,或直接再结尾插入
vim config/elasticsearch.yml
# 集群名称 cluster.name: elasticsearch-7.17.1 network.host: 0.0.0.0 #端口号 http.port: 9200 #节点名称 node.name: node-1 #设置当前机器为主节点,需要与 节点名称 相同 cluster.initial_master_nodes: ["node-1"]
修改文件数限制
vim /etc/security/limits.conf
# 在文件末尾中增加下面内容 ziye soft nofile 65536 ziye hard nofile 65536 ziye soft nproc 4096 ziye hard nproc 4096
vim /etc/security/limits.d/20-nproc.conf
# 在文件末尾中增加下面内容 # 每个进程可以打开的文件数的限制 ziye soft nofile 65536 ziye hard nofile 65536
vim /etc/sysctl.conf
# 一个进程可以拥有的 VMA(虚拟内存区域)的数量,默认值为 65536 vm.max_map_count=655360
设置文件夹所有者
chown -R ziye:ziye /opt/es_7.17.1/
进入到es根目录,切换到刚刚创建的用户下,启动ElasticSearch,执行命令(启动过程可能有点慢):
su ziye #启动 bin/elasticsearch #后台启动 bin/elasticsearch -d
网页或postman验证:
ip:9200/_cat/indices?v
需要准备 3 台虚拟机
7.17.1 集群部署
-
分别上传到centos 1,2,3 的 /opt/es_7.17.1 的文件夹下,解压并重命名 es7.17-cluster
tar -zxvf elasticsearch-7.17.1-linux-x86_64.tar.gz mv elasticsearch-7.17.1-linux-x86_64.tar.gz es7.17-cluster
因为安全问题,es不允许使用root用户运行,需要创建新用户跳转
centos 2 和 centos 3 均使用该配置
只需将 network.host: 改为本机ip
节点名称改为 node.name:node-2 和node.name:node-3 ,其他不变在 config/elasticsearch.yml 中添加如下内容:
#集群名称 cluster.name: cluster-es #节点名称,每个节点的名称不能重复 node.name: node-1 #ip 地址,每个节点的地址不能重复 network.host: 本机的虚拟机ip #表示节点是否具有成为主节点的选举资格 node.master: true #表示节点是否存储数据 node.data: true http.port: 9200 # head 插件需要这打开这两个配置 http.cors.allow-origin: "*" http.cors.enabled: true http.max_content_length: 200mb #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master cluster.initial_master_nodes: ["node-1"] #es7.x 之后新增的配置,节点发现 discovery.seed_hosts: ["虚拟机1的ip:9300","虚拟机2的ip:9300","虚拟机3的ip:9300"] gateway.recover_after_nodes: 2 network.tcp.keep_alive: true network.tcp.no_delay: true transport.tcp.compress: true #集群内同时启动的数据任务个数,默认是 2 个 cluster.routing.allocation.cluster_concurrent_rebalance: 16 #添加或删除节点及负载均衡时并发恢复的线程个数,默认 4 个 cluster.routing.allocation.node_concurrent_recoveries: 16 #初始化数据恢复时,并发恢复线程的个数,默认 4 个 cluster.routing.allocation.node_initial_primaries_recoveries: 16
修改 /etc/security/limits.conf ,添加如下内容:
ziye soft nofile 65536 ziye hard nofile 65536
修改 /etc/security/limits.d/20-nproc.conf
ziye soft nofile 65536 ziye hard nofile 65536 * hard nproc 4096 # 注:* 带表 Linux 所有用户名称
修改/etc/sysctl.conf
# 在文件中增加下面内容 vm.max_map_count=655360
重新加载
sysctl -p
文件夹授权,命令
chown -R ziye:ziye /opt/es7.17-cluster/
切换到根目录,用户切换到 ziye ,启动,测试
su ziye bin/elasticsearch # 测试 ip:9200/_cat/nodes
测试成功,继续配置 centos 2 和 centos 3,每次配置启动完后,均可测试一下
其他章节 -> 跳转
end...