当前位置: 代码迷 >> 综合 >> Centos 7 离线安装 elasticsearch6.1.1
  详细解决方案

Centos 7 离线安装 elasticsearch6.1.1

热度:18   发布时间:2023-12-14 18:47:26.0

目录

 elasticsearch6.1.1 安装

 es 集群 看这里


 

 elasticsearch6.1.1 安装

1、检查是否配置java环境

[ela@miguvideo-6 bin]$ java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

java安装连接:https://blog.csdn.net/QWERTY55555/article/details/105435042

2、安装elasticsearch6.1.1

①为es新生成用户、用户组

# 切换到root用户
su root
# 添加esgroup 用户组
groupadd esgroup
# 新建用户并添加用户ela到esgroup 并设置密码为123456
useradd ela -g esgroup -p 123456

②上传文件到/tools/soft 目录并重命名目录

软件下载地址:

https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-1-1

网盘地址:

链接:https://pan.baidu.com/s/1aImUy9ZaFQGn-D8Pglg2-Q 
提取码:epmz 
 

# 新建目录
mkdir -p /tools/soft
# 上传文件
cd /tools/soft
rz -be 
# 解压
tar -zxvf /tools/soft/elasticsearch-6.1.1.tar.gz -C /tools/
# 重命名文件夹
mv /tools/elasticsearch-6.1.1/ /tools/elasticsearch
# 将目录设置为ela所有
chown -R ela:esgroup /tools/elasticsearch/

③试运行

# 切换到ela
su ela
# 切换到bin目录
cd /tools/elasticsearch/bin/
# 后台运行es
./elasticsearch &
# 查看日志 ps :启动比较慢一般5分钟左右,会生产/tools/elasticsearch/logs 目录
tail -f /tools/elasticsearch/logs/elasticsearch.log
启动成功会显示如下
[2020-05-12T12:27:51,933][INFO ][o.e.n.Node               ] [XDyLa4A] started
[2020-05-12T12:27:51,950][INFO ][o.e.g.GatewayService     ] [XDyLa4A] recovered [0] indices into cluster_state

④使用curl在本机(虚拟机)测试一下成功如下:

#
curl 127.0.0.1:9200返回如下
{"name" : "XDyLa4A","cluster_name" : "elasticsearch","cluster_uuid" : "hKlf1X5xSa6KqXtwIcYiWA","version" : {"number" : "6.1.1","build_hash" : "bd92e7f","build_date" : "2017-12-17T20:23:25.338Z","build_snapshot" : false,"lucene_version" : "7.1.0","minimum_wire_compatibility_version" : "5.6.0","minimum_index_compatibility_version" : "5.0.0"},"tagline" : "You Know, for Search"
}

⑤设置其它计算机上可以访问虚拟机数据库

# 修改elasticsearch.yml文件
vi /tools/elasticsearch/config/elasticsearch.yml
内容如下:# Set the bind address to a specific IP (IPv4 or IPv6):
#network.host 为本机IP地址 ifconfig可查看
network.host: 192.168.1.211
#
# Set a custom port for HTTP:
#
http.port: 9200
#

⑥ 遇到问题解决方案

#第一个问题
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]#切换到root用户修改
vim /etc/security/limits.conf
# 在最后面追加下面内容
ela hard nofile 65536
ela soft nofile 65536#第二个问题
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]vi /etc/sysctl.conf 文件最后添加一行
vm.max_map_count=262144
并执行命令:sysctl -p

es 集群 看这里

机器为三台,配置如下

 hostname   IP地址 节点角色&端口
master  10.150.201.48  Master:9200 
node1 10.150.201.45  Slave :9200
node2 10.150.201.44  Slave :9200



       
     
     
     

一、修改三台机器/tools/elasticsearch/config/elasticsearch.yml

# 分别修改配置
vi /tools/elasticsearch/config/elasticsearch.yml# 10.150.201.48 配置如下:
[root@miguvideo-6 config]# cat elasticsearch.yml | grep -v "^#" | grep -v "^$"
cluster.name: germey-es-clusters
node.name: node-1
node.master: true
node.attr.rack: r1
network.host: 0.0.0.0 
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.150.201.48", "10.150.201.45","10.150.201.44"]
discovery.zen.minimum_master_nodes: 2 # 10.150.201.45 配置如下:
cluster.name: germey-es-clusters
node.name: node-2
node.attr.rack: r2
network.host: 0.0.0.0 
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.150.201.48", "10.150.201.45","10.150.201.44"]# 10.150.201.44配置如下:
cluster.name: germey-es-clusters
node.name: node-3
node.attr.rack: r3
network.host: 0.0.0.0 
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.150.201.48", "10.150.201.45","10.150.201.44"]

二、 修改jvm

# 分别修改三台jvm 配置。我的三台机器内存为8g 设置为4g 是配置的一半vi /tools/elasticsearch/config/jvm.options
-Xms4g  #内存为8g 设置为4g
-Xmx4g  #内存为8g 设置为4g

三、启动三台服务

# 切换到ela用户
su ela
# 分别启动 三台es 
./tools/elasticsearch/bin/elasticsearch &
# 查看日志
tail -f /tools/elasticsearch/logs/elasticsearch.log

四、验证是否集群成功

# 在任意一台上面执行如下命令
[root@miguvideo-6 bin]# curl -XGET 'http://localhost:9200/_cluster/state?pretty'
{"cluster_name" : "germey-es-clusters","compressed_size_in_bytes" : 354,"version" : 12,"state_uuid" : "qX0wlY4lQMeE9svhbpd05A","master_node" : "SO3dU3ARRZ26pYBmI490WQ","blocks" : { },"nodes" : {"XDyLa4ANTz2z3LDW4kA2xg" : {"name" : "node-1","ephemeral_id" : "F4vYbkIhSPiUscIZzzvS7w","transport_address" : "10.150.201.48:9300","attributes" : {"rack" : "r1"}},"bXiq5NijQvW23RLtPfa5hQ" : {"name" : "node-2","ephemeral_id" : "ioXoUng3Rdyeheq5t8OeOg","transport_address" : "10.150.201.45:9300","attributes" : {"rack" : "r2"}},"SO3dU3ARRZ26pYBmI490WQ" : {"name" : "node-3","ephemeral_id" : "EOOppxPmTvmqMuSDMiAtoA","transport_address" : "10.150.201.44:9300","attributes" : {"rack" : "r3"}}},"metadata" : {"cluster_uuid" : "low6IK-dTyKFdDgxS8gnHw","templates" : { },"indices" : { },"index-graveyard" : {"tombstones" : [ ]}},"routing_table" : {"indices" : { }},"routing_nodes" : {"unassigned" : [ ],"nodes" : {"bXiq5NijQvW23RLtPfa5hQ" : [ ],"SO3dU3ARRZ26pYBmI490WQ" : [ ],"XDyLa4ANTz2z3LDW4kA2xg" : [ ]}},"snapshot_deletions" : {"snapshot_deletions" : [ ]},"restore" : {"snapshots" : [ ]},"snapshots" : {"snapshots" : [ ]}
}

集群ok

参考: https://cloud.tencent.com/developer/article/1189282

 

  相关解决方案