docker centos7离线安装ElasticSearch单机版


本文以 elasticsearch-7.8.1为例。

1.下载ES并解压

cd /root/install
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-7.8.1-linux-x86_64.tar.gz

2.新建elasticsearch用户

使用root用户登录,新建elasticsearch用户。

useradd elasticsearch
passwd elasticsearch
chown -R elasticsearch:elasticsearch /root/install/elasticsearch-7.8.1

3.修改ES配置文件

vi /opt/elasticsearch-7.8.1/config/elasticsearch.yml
###############################################################
cluster.name: elasticsearch    #集群名
node.name: node-1    #节点名称
path.data: /opt/data/es/data    #数据存储路径
path.logs: /opt/data/es/logs    #日志存储路径
network.host: 0.0.0.0    #本机IP,可以写0.0.0.0
http.port: 9200    #访问端口
discovery.seed_hosts: ["127.0.0.1"]    #通信地址
cluster.initial_master_nodes: ["node-1"]    #master节点名称
http.cors.enabled: true #是否支持跨域,默认为false
http.cors.allow-origin: "*"    #当设置允许跨域,默认为*,表示支持所有域名
###############################################################

4.启动ES服务

# 切换用户 
su - elasticsearch
# 启动ES
sh /root/install/elasticsearch-7.8.1/bin/elasticsearch

5.设置开机启动

vi /etc/init.d/elasticsearch
#!/bin/bash
#
#chkconfig: 345 63 37
#description: elasticsearch
#processname: elasticsearch-7.8.1

ES_HOME=/root/install/elasticsearch-7.8.1

case $1 in
  start)
    su - elasticsearch -c "$ES_HOME/bin/elasticsearch -d -p pid"
    echo "elasticsearch is started"
    ;;
  stop)
    pid=`cat $ES_HOME/pid`
    kill -9 $pid
    echo "elasticsearch is stopped"
    ;;
  restart)
    pid=`cat $ES_HOME/pid`
    kill -9 $pid
    echo "elasticsearch is stopped"
    sleep 1
    su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
    echo "elasticsearch is started"
    ;;
  *)
    echo "start|stop|restart"
    ;;  
esac
exit 0
chmod 777 /etc/init.d/elasticsearch
chkconfig --add elasticsearch #设置开机启动
chkconfig --del elasticsearch #删除开机启动

chkconfig elasticsearch on    #打开开机启动
chkconfig elasticsearch off   #关闭开机启动

相关推荐

  1. docker centos7线安装ElasticSearch单机

    2024-03-30 14:04:04       40 阅读
  2. k8s线安装单节点elasticsearch7.x

    2024-03-30 14:04:04       30 阅读
  3. CentOS 7 线安装Docker

    2024-03-30 14:04:04       44 阅读
  4. CentOS7线安装supervisor

    2024-03-30 14:04:04       49 阅读
  5. centos7.9线安装docker

    2024-03-30 14:04:04       38 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-30 14:04:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-30 14:04:04       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-30 14:04:04       82 阅读
  4. Python语言-面向对象

    2024-03-30 14:04:04       91 阅读

热门阅读

  1. R语言数据分析基础(一)

    2024-03-30 14:04:04       42 阅读
  2. 【React】React表单组件

    2024-03-30 14:04:04       39 阅读
  3. 【C语言】程序翻译过程

    2024-03-30 14:04:04       42 阅读
  4. sqlmap基础知识

    2024-03-30 14:04:04       36 阅读
  5. Go的数据结构与实现【LinkedList】

    2024-03-30 14:04:04       41 阅读
  6. 手写DNS服务器测速程序(工具分享)

    2024-03-30 14:04:04       56 阅读
  7. test6

    test6

    2024-03-30 14:04:04      46 阅读
  8. 成都某公司笔试题sql

    2024-03-30 14:04:04       45 阅读