Py学习  »  Elasticsearch

centos7 安装 ElasticSearch 配置外网访问

webliuxiang • 3 年前 • 228 次点击  
阅读 14

centos7 安装 ElasticSearch 配置外网访问

导入rpm key

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch复制代码

创建 ElasticSearch 的 rpm 源

[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md复制代码

安装 ElasticSearch

sudo yum install --enablerepo=elasticsearch elasticsearch
或者
sudo dnf install --enablerepo=elasticsearch elasticsearch
或者
sudo zypper modifyrepo --enable elasticsearch && \ 
sudo zypper install elasticsearch; \ 
sudo zypper modifyrepo --disable elasticsearch复制代码

或者手动下载rpm包安装

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-7.6.1-x86_64.rpm.sha512 
sudo rpm --install elasticsearch-7.6.1-x86_64.rpm复制代码

启动 ElasticSearch

创建启动服务
sudo chkconfig --add elasticsearch
启动
sudo -i service elasticsearch start
停止
sudo -i service elasticsearch stop复制代码

设置开机自启动

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service复制代码

也可以按以下方式启动和停止

sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service复制代码

验证启动

curl localhost:9200

{
  "name" : "localhost.localdomain",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "stEDG_orQ-GX-69i4WT3xw",
  "version" : {
    "number" : "7.6.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",
    "build_date" : "2020-02-29T00:15:25.529771Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}复制代码

配置外网访问

sudo vim /etc/elasticsearch/elasticsearch.yml复制代码

添加
network.host: 0.0.0.0
放开
cluster.initial_master_nodes: ["node-1", "node-2"]复制代码

重启

如果报错

修改

/etc/sysconfig/elasticsearch复制代码
  • JAVA_HOME Set a custom Java path to be used.

  • MAX_OPEN_FILES 最大打开文件数,默认 65536.

  • MAX_LOCKED_MEMORY 最大锁定的内存大小。 如果使用 elasticsearch.yml 中的 bootstrap.memory_lock 选项,则设置为无限制。

  • MAX_MAP_COUNT 进程可能具有的最大内存映射区数量。如果您使用 mmapfs 作为索引存储类型,请确保将其设置为较高值。有关更多信息,请查看关于 max_map_count 的 linux 内核文档。 这是在启动 Elasticsearch 之前通过 sysctl 设置的。 默认为262144。

  • ES_PATH_CONF 配置文件目录(需要包含 elasticsearch.yml,jvm.options 和 log4j2.properties 文件); 默认为 /etc/elasticsearch

  • ES_JAVA_OPTS 你可能想要应用的任何其他JVM系统属性。

  • RESTART_ON_UPGRADE 在软件包升级时配置重启,默认为false。 这意味着您必须在手动安装包后重新启动Elasticsearch实例。 其原因是为了确保集群中的升级不会导致连续的碎片重新分配,从而导致高网络流量并缩短集群的响应时间。

主要修改 MAX_OPEN_FILES  MAX_LOCKED_MEMORY  bootstrap.memory_lock  MAX_MAP_COUNT



Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/57140
 
228 次点击