1、使用命令下载:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-linux-x86_64.tar.gz
2、移动包至 你想放入的目录中:我的:/usr/local
mv elasticsearch-7.4.2-linux-x86_64.tar.gz /usr/local/
3、解压
tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz
4、创建目录 :mkdir data
5、进入config包下
6、编辑 elasticsearch.yml
vi elasticsearch.yml
按 i 进入编辑模式
# 名称要设置一样,这样就是一个集群了
cluster.name: imooc-elasticsearch
# 节点名称:必须不一样 三个节点这里不一样其他都一样
node.name: es-node1
# 设置存储路径
path.data: /usr/local/elasticsearch-7.4.2/data
# 设置日志路径
path.logs: /usr/local/elasticsearch-7.4.2/logs
# 设置外网可以访问
network.host: 0.0.0.0
# 设置端口 可以设置一样,也可以不一样
http.port: 9200
# 主节点,作用主要是用于来管理整个集群,负责创建或删除索引,管理其他非master节点
node.master: true
# 数据节点,用于对文档数据的增删改查
node.data: true
# 集群列表
discovery.seed_hosts: ["192.168.56.6", "192.168.56.7", "192.168.56.8"]
#启动跨域head访问
http.cors.enabled: true
http.cors.allow-origin: "*"
# 启动的时候使用一个master节点
cluster.initial_master_nodes: ["es-node1"]
按 esc 并输入":wq"保存退出
查询
more elasticsearch.yml | grep ^[^#]
8.es不能用root用户启动,所以创建一个用户启动
useradd esuser #添加用户
chown -R esuser:esuser /usr/local/elasticsearch-7.4.2/ #对该目录授权
9.启动es
su esuser
/usr/local/elasticsearch-7.4.2/bin/elasticsearch