指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
homestead下配置elasticsearch
1.homestead.yaml文件修改,我这里使用 7.10.0,这是之前项目一直使用的版本,也是云服务器上的版本,注意后面安装ik分词器的时候也需要对应版本
features:
    - mysql: true
    - redis: true
    - memecached: true
    - mariadb: false
    - postgresql: true
    - ohmyzsh: false
    - webdriver: false
    - elasticsearch:
       version: 7.10.0

services:
    - enabled:
          - "mysql"
          - "postgresql"
          - "redis"
          - "memecached"
          - "elasticsearch"
#    - disabled:
#        - "postgresql@11-main"

ports:
    - send: 33060 # MySQL/MariaDB
      to: 3306
    - send: 54320
      to: 5432
    - send: 6379
      to: 6379
    - send: 11211
      to: 11211
    - send: 9200
      to: 9200

2.重新启动vagrant加载配置
$ vagrant.exe reload --provision

3.安装ik分词器插件
#]cd /usr/share/elasticsearch/plugins
#]mkdir ik
#]chmod -R 777 ./ik
#]cd ik
#]wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.10.0/elasticsearch-analysis-ik-7.10.0.zip
#]unzip elasticsearch-analysis-ik-7.10.0.zip

4.重启es服务
#]service elasticsearch restart

5.本地测试
#] curl 127.0.0.1:9200
{
  "name" : "homestead",
  "cluster_name" : "homestead",
  "cluster_uuid" : "aoCViOY0ScGvX9AXldGbRQ",
  "version" : {
    "number" : "7.10.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "51e9d6f22758d0374a0f3f5c6e8f3a7997850f96",
    "build_date" : "2020-11-09T21:30:33.964949Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

6.配置除本机以外的客户端访问
我记得自己搭建es会创建 elasticsearch:elasticsearch 用户名:用户组
所以 修改 /etc/elasticsearch/elasticsearch.yml 需要 elasticsearch 用户 或者 root 用户
我就直接使用 root用户:
vagrant@homestead:/etc$ sudo su root

root@homestead:/etc/elasticsearch# vim elasticsearch.yml

cluster.name: homestead
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- 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
#
# 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"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true


再次重启报错:
[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

原因是: 如果配置了network.host  0.0.0.0 ,就是允许除了本机以外的其它客户端访问,那么就需要配置一个主节点的名字才行,所以 在上面的 yml 文件里配置了: cluster.initial_master_nodes: ["node-1"]