CentOS7安装Elasticsearch7
下载地址:https://www.elastic.co/cn/downloads/elasticsearch
使用YUM安装
# 下载并安装公共签名密钥
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
# 配置RPM仓库
vim /etc/yum.repos.d/elasticsearch.repo [elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
# Apache 2.0 license
#baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
yum install -y elasticsearch
配置服务
启动服务之前一定要先配置/etc/elasticsearch/elasticsearch.yml的network.host、http.port和cluster.initial_master_nodes。
#防火墙开放9200端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service # 启动停止服务
#不允许root启动。
sudo systemctl start elasticsearch
sudo systemctl stop elasticsearch # 后台运行
./bin/elasticsearch -d
测试服务
curl http://127.0.0.1:9200/
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Pxdp0Z24SJ-MIBH_2oMe2A",
"version" : {
"number" : "7.1.1",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "7a013de",
"build_date" : "2019-05-23T14:04:00.380842Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
常用文件
# 配置文件
vim /etc/elasticsearch/elasticsearch.yml # JVM配置
vim /etc/elasticsearch/jvm.options # 启动日志
tail -n 10 -f /var/log/elasticsearch/elasticsearch.log
问题处理
绑定IP和跨域
vim /etc/elasshellticsearch/elasticsearch.yml # 允许任意IP访问
network.host: 0.0.0.0 # 修改开放的端口
http.port: 9200 # 最后添加跨域
http.cors.enabled: true
http.cors.allow-origin: "*" # 注意,: 后面必须有一个英文空格
启动失败
启动报错信息如下:
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
vim /etc/elasticsearch/elasticsearch.yml # 修改【#cluster.initial_master_nodes: ["node-1", "node-2"] 】
cluster.initial_master_nodes: ["node-1"]
进程虚拟内存不足
vim /etc/sysctl.conf # 添加
vm.max_map_count=262144 # 保存后执行
sysctl -p
目录简介
| 类型 | 描述 | 默认位置 | 设置 |
|---|---|---|---|
| home | Elasticsearch主目录或 $ES_HOME |
/usr/share/elasticsearch |
|
| bin | 二进制脚本,包括elasticsearch启动节点和elasticsearch-plugin安装插件 |
/usr/share/elasticsearch/bin |
|
| conf | 配置文件elasticsearch.yml |
/etc/elasticsearch |
ES_PATH_CONF |
| conf | 环境变量,包括堆大小,文件描述符 | /etc/sysconfig/elasticsearc |
|
| data | 节点上分配的每个索引、分片的数据文件的位置。可以容纳多个位置。 | /var/lib/elasticsearch |
path.data |
| logs | 日志文件位置 | /var/log/elasticsearch |
path.logs |
| plugins | 插件文件位置。每个插件都将包含在一个子目录中。 | /usr/share/elasticsearch/plugins |
|
| repo | 共享文件系统存储库位置。可以容纳多个位置。文件系统存储库可以放在此处指定的任何目录的任何子目录中。 | Not configured | path.repo |
配置Elasticsearch
Elasticsearch默认使用/etc/elasticsearch运行时配置。此目录的所有权以及此目录中的所有文件在安装时都设置为root:elasticsearch,并且目录设置了setgid标志,以便在/etc/elasticsearch下创建的所有文件和子目录,例如使用密钥库创建密钥库工具等。
Elasticsearch默认读取配置文件/etc/elasticsearch/elasticsearch.yml,详细说明。
RPM还有一个系统配置文件(/etc/sysconfig/elasticsearch),允许设置以下参数。
| 参数 | 说明 |
|---|---|
| JAVA_HOME | 设置要使用的自定义Java路径。 |
| MAX_OPEN_FILES | 最大打开文件数,默认为65535。 |
| MAX_LOCKED_MEMORY | 最大锁定内存大小。如果需要通过elasticsearch.yml中的选项bootstrap.memory_lock来控制,就设置为unlimited。 |
| MAX_MAP_COUNT | 进程可能具有的最大内存映射区域数。如果您使用mmapfs 索引存储类型,请确保将其设置为较高的值。默认为262144。 |
| ES_PATH_CONF | 配置文件目录(其中必须包括elasticsearch.yml, jvm.options和log4j2.properties); 默认目录 /etc/elasticsearch。 |
| ES_JAVA_OPTS | 其他JVM系统属性 |
| RESTART_ON_UPGRADE | 在程序包升级时配置重新启动,默认为false。这意味着您必须在手动安装软件包后重新启动Elasticsearch实例。这样做的原因是为了确保群集中的升级不会导致连续的分片重新分配,从而导致高网络流量并缩短群集的响应时间。 |
附录:完整的elasticsearch.yml文件
vim /etc/elasticsearch/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ 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", "node-2"]
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 http.cors.enabled: true
http.cors.allow-origin: "*"
附录:完整的elasticsearch.service文件
vim /lib/systemd/system/elasticsearch.service
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target [Service]
RuntimeDirectory=elasticsearch
PrivateTmp=true
Environment=ES_HOME=/usr/share/elasticsearch
Environment=ES_PATH_CONF=/etc/elasticsearch
Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=-/etc/sysconfig/elasticsearch WorkingDirectory=/usr/share/elasticsearch User=elasticsearch
Group=elasticsearch ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet # StandardOutput is configured to redirect to journalctl since
# some error messages may be logged in standard output before
# elasticsearch logging system is initialized. Elasticsearch
# stores its logs in /var/log/elasticsearch and does not use
# journalctl by default. If you also want to enable journalctl
# logging, you can simply remove the "quiet" option from ExecStart.
StandardOutput=journal
StandardError=inherit # Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65535 # Specifies the maximum number of processes
LimitNPROC=4096 # Specifies the maximum size of virtual memory
LimitAS=infinity # Specifies the maximum file size
LimitFSIZE=infinity # Disable timeout logic and wait until process is stopped
TimeoutStopSec=0 # SIGTERM signal is used to stop the Java process
KillSignal=SIGTERM # Send the signal only to the JVM rather than its control group
KillMode=process # Java process is never killed
SendSIGKILL=no # When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143 [Install]
WantedBy=multi-user.target # Built for packages-7.1.1 (packages)
CentOS7安装Elasticsearch7的更多相关文章
- CentOS7安装ElasticSearch7.9.2
1:下载 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar. ...
- HP服务器 hp 360g5 centos7安装问题
HP服务器 hp 360g5 centos7安装问题 一 :启动盘无法识别硬盘 1.进入安装光盘,用上下键选择安装centos--Install Centos7(注意不可按Enter键),如图: 2 ...
- CentOS7 安装Mono及Jexus
CentOS7安装Mono及Juxes 1 安装Mono 1.1 安装yum-utils 因为安装要用到yum-config-manager,默认是没有安装的,所以要先安装yum-utils包.命令如 ...
- CentOS7安装mysql提示“No package mysql-server available.”
针对centos7安装mysql,提示"No package mysql-server available."错误,解决方法如下: Centos 7 comes with Mari ...
- CentOS7安装Oracle 11gR2 安装
概述 Oracle 在Linux和window上的安装不太一样,公司又是Linux系统上的Oracle,实在没辙,研究下Linux下Oracle的使用,oracle默认不支持CentOS系统安装,所以 ...
- Centos7安装完毕后重启提示Initial setup of CentOS Linux 7 (core)的解决方法
问题: CentOS7安装完毕,重新开机启动后显示: Initial setup of CentOS Linux 7 (core) 1) [x] Creat user 2) [!] License i ...
- centos7安装eclipse
centos7安装eclipse Eclipse是一个集成开发环境(IDE),包含一个基工作区和定制环境的可扩展插件系统.大部分使用 Java 编写,Eclipse 可以用来开发应用程序.通过各种插件 ...
- CentOS7安装mongoDB数据库
CentOS7安装mongoDB数据库 时间:2015-03-03 16:45来源:blog.csdn.net 作者:进击的木偶 举报 点击:8795次 mongoDB是目前发展比较好的NOSQL数据 ...
- CentOS7安装Ambari
环境: CentOS7安装两个节点:master.slave1.并配置ssh无密码登录. 步骤: 获取 Ambari 的公共库文件(public repository): wget http://pu ...
随机推荐
- 《高并发下的.NET》第2季 - 故障公告:高并发下全线崩溃
大家好,非常抱歉,在昨天下午(12月3日)的访问高峰,园子迎来更高的并发,在这样的高并发下,突发的数据库连接故障造成博客站点全线崩溃,由此给您带来很大的麻烦,请您谅解. 最近,我们一边在忙于AWS合作 ...
- PyQt学习随笔:重写setData方法截获Model/View中视图数据项编辑的注意事项
根据<PyQt学习随笔:Model/View中视图数据项编辑变动实时获取变动数据的方法>可以重写从PyQt的Model类继承的setData方法来实时截获View中对数据的更改,但需要注意 ...
- 公司只提供签名服务,不提供证书文件,如何打包Electron应用
需求 稍微正规点的公司,都要为自己开发的软件做代码签名,如下图所示 代码签名的主要目的是为了确保软件的来源(这个软件是由谁生产的)和软件的内容不被篡改 一个软件公司可能有很多团队,很多开发者,开发不同 ...
- 老男孩培训作业day1
作业一:博客(开通博客园) 作业二:编写登录接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定 作业三:多级菜单 三级菜单 可依次选择进入各子菜单 所需新知识点:列表.字典(列表和字典的相互 ...
- 国际关注,Panda 交易所获悉美银监机构批准特许银行托管加密资产
近期,Panda 交易所注意到,根据此前与Cointelegraph分享的一份声明,美国货币监理署(OCC)正在授予联邦特许银行托管加密货币的权限. 鉴于加密钱包与其他种类资产的托管要求不同,这一问题 ...
- nginx学习之——CentOS6.0下安装nginx
1.下载对应nginx版本 #注:下载地址:http://nginx.org/download/ wget -c http://nginx.org/download/nginx-1.10.3.tar. ...
- Greenplum 性能优化之路 --(一)分区表
一.什么是分区表 分区表就是将一个大表在物理上分割成若干小表,并且整个过程对用户是透明的,也就是用户的所有操作仍然是作用在大表上,不需要关心数据实际上落在哪张小表里面.Greenplum 中分区表的原 ...
- 事件修饰符 阻止冒泡 .stop 阻止默认事件 .prevent
stop修饰符 阻止冒泡行为 可以在函数中利用$event传参通过stopPropagation()阻止冒泡 通过直接在元素中的指令中添加 .stop prevent修饰符 阻止默认行为 可以在函数中 ...
- C++ 中使用 PRId64
同一份代码,Ubuntu 14.04.1 编译没有问题,centos 7 上编译提示错误: error: expected ')' before 'PRId64' 这里两个地址说得很清楚了: http ...
- 浅谈 FHQ-Treap
关于FHQ-Treap --作者:BiuBiu_Miku 可能需要的前置知识: 一.树形结构的了解: 树形,顾名思义,就是像树一样有很多分叉口,而这里以二叉 ...