Elasticsearch非集群单节点安装教程

Elasticsearch单节点安装教程

安装

  1. 下载elasticsearch安装包
    https://www.elastic.co/cn/products/elasticsearch
  2. 解压
tar -xzf elasticsearch-7.5.1-linux-x86_64.tar.gz
  1. elasticsearch不能以root用户启动,需创建一个新的用户
# 以root用户来创建新的用户 , groupadd 添加一个用户组
[root@localhost home]# groupadd elasticsearch 
# 添加一个用户,-g是在用户组下 -p是密码
[root@localhost home]# useradd elasticsearch -g elasticsearch -p elasticsearch
  1. 授权新用户elasticsearch为elasticsearch-7.5.1/文件夹的所有者
# 给用户elasticsearch 授权
[root@localhost home]# chown -R elasticsearch:elasticsearch elasticsearch-7.5.1/
  1. 用root用户,编辑limits.conf配置文件,修改用户最大可创建文件数,因为可创建文件数太小的话elasticsearch启动不了
vim /etc/security/limits.conf
#添加以下配置
elastic   hard    nofile  65536
elastic   soft    nofile  65536
* soft    nproc   65536
* hard    nproc   65536
  1. 用root用户,修改配置文件sysctl.conf文件,调大最大虚拟内存,因为虚拟内存太小的话es也启动不了
vim /etc/sysctl.conf
#添加
vm.max_map_count=655360
#因为默认vm.max_map_count=65530
#添加完成后必须执行以下命令配置才可生效
sysctl -p
  1. 进入es文件夹,修改config/elasticsearch.yml配置文件,将network.host的值设置为0.0.0.0表示对所有的ip授权
# ------------------------------------ Node ------------------------------------
# Use a descriptive name for the node:
node.name: node-1
# ----------------------------------- Paths ------------------------------------
# Path to directory where to store the data (separate multiple locations by comma):
path.data: /data/appdatas/elasticsearch/to/data
# Path to log files:
path.logs: /data/appdatas/elasticsearch/to/logs
# ---------------------------------- Network -----------------------------------
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: 0.0.0.0
# Set a custom port for HTTP:
http.port: 9200
# --------------------------------- Discovery ----------------------------------
# Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["node-1"]
  1. 切换到elasticsearch用户下就可以启动了( es7要使用jdk11)
# 切换到 elasticsearch 用户
su elasticsearch
#进到es的bin目录下
cd elasticsearch-7.5.1/bin
#启动。
./elsticsearch

#要想放到后台进程启动,就用
./elsticsearch -d
#判断后台启动是否成功,可执行如下命令,查看是否存在9200端口
ss -tanl

测试es

  1. 访问 http://192.168.8.101:9200
{
  "name" : "ip101",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "7.4.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "fc0eeb6e2c25915d63d871d344e3d0b45ea0ea1e",
    "build_date" : "2019-10-22T17:16:35.176724Z",
    "build_snapshot" : false,
    "lucene_version" : "8.2.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
  1. curl http://192.168.8.101:9200
结果同上

遇到的问题

(1)org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node(es版本为5.6.16)
在这里插入图片描述
解决办法:
修改elasticsearch config目录下的elasticsearch.yml,添加node.max_local_storage_nodes: 256

#action.destructive_requires_name: true
node.max_local_storage_nodes: 256

(2)ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured(es版本为7.5.1)
在这里插入图片描述
解决办法:
修改elasticsearch.yml

修改前:
#cluster.initial_master_nodes: ["node-1"]
修改后(将注释取消即可):
cluster.initial_master_nodes: ["node-1"]
发布了13 篇原创文章 · 获赞 11 · 访问量 550

猜你喜欢

转载自blog.csdn.net/sinat_34241861/article/details/103872538