当前环境:Linux liuns 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
- Elashticseach依赖java,所有需要先安装java。
[root@liuns ~]# yum install java [root@liuns ~]# java -version openjdk version "1.8.0_232" OpenJDK Runtime Environment (build 1.8.0_232-b09) OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode) //源码安装参考:https://www.java.com/en/download/help/linux_x64_install.xml
- 导入Elasticsearch PGP Key。
[root@liuns ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
-
在/etc/yum.repos.d/目录下新建elasticsearch.repo源文件。
[root@liuns ~]# vim /etc/yum.repos.d/elasticsearch.repo 插入如下内容: [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
-
执行安装即启动
//执行安装 [root@liuns ~]# yum install --enablerepo=elasticsearch elasticsearch -y //加入系统自启动 [root@liuns ~]# sudo systemctl daemon-reload [root@liuns ~]# sudo systemctl enable elasticsearch.service //启动/关闭服务 [root@liuns ~]# sudo service elasticsearch start [root@liuns ~]# sudo service elasticsearch stop //如果启动失败可以通过以下命令查看系统日志定位问题 [root@liuns ~]# sudo journalctl -f
-
可通过访问http://localhost:9200检查Elasticsearch是否正常运行访问
[root@liuns ~]# curl http://localhost:9200 { "name" : "liuns", "cluster_name" : "elasticsearch", "cluster_uuid" : "r49F7tEOTXugFfRgAbLmYw", "version" : { "number" : "7.5.0", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "e9ccaed468e2fac2275a3761849cbee64b39519f", "build_date" : "2019-11-26T01:06:52.518245Z", "build_snapshot" : false, "lucene_version" : "8.3.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
-
Elasticsearch相关目录结构布局。
Type Description Default Location Setting home
Elasticsearch home directory or
$ES_HOME
/usr/share/elasticsearch
bin
Binary scripts including
elasticsearch
to start a node andelasticsearch-plugin
to install plugins/usr/share/elasticsearch/bin
conf
Configuration files including
elasticsearch.yml
/etc/elasticsearch
conf
Environment variables including heap size, file descriptors.
/etc/sysconfig/elasticsearch
data
The location of the data files of each index / shard allocated on the node. Can hold multiple locations.
/var/lib/elasticsearch
path.data
jdk
The bundled Java Development Kit used to run Elasticsearch. Can be overriden by setting the
JAVA_HOME
environment variable in/etc/sysconfig/elasticsearch
./usr/share/elasticsearch/jdk
logs
Log files location.
/var/log/elasticsearch
path.logs
plugins
Plugin files location. Each plugin will be contained in a subdirectory.
/usr/share/elasticsearch/plugins
repo
Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.
Not configured
path.repo
- 系统配置文件 /etc/sysconfig/elasticsearch 运行时相关配置项。
JAVA_HOME
Set a custom Java path to be used.
MAX_OPEN_FILES
Maximum number of open files, defaults to
65535
.MAX_LOCKED_MEMORY
Maximum locked memory size. Set to
unlimited
if you use thebootstrap.memory_lock
option in elasticsearch.yml.MAX_MAP_COUNT
Maximum number of memory map areas a process may have. If you use
mmapfs
as index store type, make sure this is set to a high value. For more information, check the linux kernel documentation aboutmax_map_count
. This is set viasysctl
before starting Elasticsearch. Defaults to262144
.ES_PATH_CONF
Configuration file directory (which needs to include
elasticsearch.yml
,jvm.options
, andlog4j2.properties
files); defaults to/etc/elasticsearch
.ES_JAVA_OPTS
Any additional JVM system properties you may want to apply.
RESTART_ON_UPGRADE
Configure restart on package upgrade, defaults to
false
. This means you will have to restart your Elasticsearch instance after installing a package manually. The reason for this is to ensure, that upgrades in a cluster do not result in a continuous shard reallocation resulting in high network traffic and reducing the response times of your cluster. - Elasticsearch的3个主要配置文件。
elasticsearch.yml
for configuring Elasticsearch.
jvm.options
for configuring Elasticsearch JVM settings.
log4j2.properties
for configuring Elasticsearch logging.
参考资料:
https://www.elastic.co/guide/en/elasticsearch/reference/7.5/rpm.html
https://www.elastic.co/guide/en/elasticsearch/reference/7.5/settings.html