1.安装包下载
不同版本elasticsearch,可访问es官方网站进行下载,本文使用7.12.1版本进行部署
elasticsearch-7.12.1-linux-x86_64.tar.gz
2.安装包上传服务器
根据各自需要,选择elasticsearch安装位置。
解压elasticsearch-7.12.1-linux-x86_64.tar.gz
tar zxvf elasticsearch-7.12.1-linux-x86_64.tar.gz
3.修改es配置
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-elastic
#
# ------------------------------------ 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: /usr/local/elasticsearch/es-data
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch/es-log
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# 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"]
#开启cors跨域访问支持,默认为false
http.cors.enabled: true
#跨域访问允许的域名地址,(允许所有域名)以上使用正则
http.cors.allow-origin: "*"
4.新增用户
es不允许使用root用户启动,需要新建一个用户并赋予权限
# 创建用户
adduser elastic
# 修改elastic用户密码
passwd elastic
# 给elastic用户赋予文件夹权限
chown 777 /usr/local/elasticsearch-7.12.1 -R
5.修改服务配置
# 在 /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
# 修改 etc/security/limits.conf, 添加如下内容
elastic soft nofile 65536
elastic hard nofile 65536
6.启动elasticsearch
./bin/elasticsearch -d
至此,单节点es服务已部署完毕!
文章仅作为记录方便以后使用查找
7.测试访问
浏览器地址栏输入http://服务器ip:端口号