Elasticsearch_install

Install Elasticsearch with Debian Package

  • for Debian, Ubuntu, and other Debian-based systems
  • 需要java环境

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

步骤

  • 下载并安装公共签名密钥

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
  • 你可能需要在Debian安装apt-transport-https:

sudo apt-get install apt-transport-https
  • 将 repository 保存到 /etc/apt/sources.list.d/elastic-5.x.list

echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
  • 你可以安装 Debian package Elasticsearch,命令如下:

sudo apt-get update && sudo apt-get install elasticsearch
  • Elasticsearch v5.4.2 Debian 软件包可以从网站上下载并安装:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.2.deb
sha1sum elasticsearch-5.4.2.deb 
sudo dpkg -i elasticsearch-5.4.2.deb
  • 配置Elasticsearch随系统启动,运行下面的命令:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
  • Elasticsearch可以按照如下方式启动和停止:

sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service

当系统启用了日志记录,日志记录的信息都可以用journalctl命令:

  • To tail the journal:

sudo journalctl -f
  • To list journal entries for the elasticsearch service:

sudo journalctl --unit elasticsearch
  • To list journal entries for the elasticsearch service starting from a given time:

sudo journalctl --unit elasticsearch --since  "2016-10-30 18:17:16"
  • 我的机器是阿里云1c 1G的,启动的时候就报出如下错误

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot alloc
 # There is insufficient memory for the Java Runtime Environment to continue.
 # Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
  • 根据机器配置不同可以修改相对应的参数

vi /etc/elasticsearch/jvm.options
  • 将 -Xms 和 -Xmx 参数修改一下就可以正常启动了

-Xms256m
-Xmx256m
  • 默认参数是运行在9200端口下的,可以通过如下命令确认:

curl -XGET 'localhost:9200/?pretty'
  • 返回结果如下

{
  "name" : "0NcYzNP",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "-QmXkqg6T0uVrUAbNZhggA",
  "version" : {
    "number" : "5.4.2",
    "build_hash" : "929b078",
    "build_date" : "2017-06-15T02:29:28.122Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.1"
  },
  "tagline" : "You Know, for Search"
}

配置Elasticsearch

参数注释
ES_USERThe user to run as, defaults to elasticsearch
ES_GROUPThe group to run as, defaults to elasticsearch
JAVA_HOMESet a custom Java path to be used
MAX_OPEN_FILESMaximum number of open files, defaults to 65536
MAX_LOCKED_MEMORYMaximum locked memory size. Set to unlimited if you use the bootstrap.memory_lock option in elasticsearch.yml
MAX_MAP_COUNTMaximum 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 about max_map_count. This is set via sysctl before starting elasticsearch. Defaults to 262144
LOG_DIRLog directory, defaults to /var/log/elasticsearch
DATA_DIRData directory, defaults to /var/lib/elasticsearch
CONF_DIRConfiguration file directory (which needs to include elasticsearch.yml and log4j2.properties files), defaults to /etc/elasticsearch
ES_JAVA_OPTSAny additional JVM system properties you may want to apply
RESTART_ON_UPGRADEConfigure 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
TypeDescriptionDefault LocationSetting
homeElasticsearch home directory or $ES_HOME/usr/share/elasticsearch
binBinary scripts including elasticsearch to start a node and elasticsearch-plugin to install plugins/usr/share/elasticsearch/bin
confConfiguration files including elasticsearch.yml/etc/elasticsearchpath.conf
confEnvironment variables including heap size, file descriptors/etc/default/elasticsearch
dataThe location of the data files of each index / shard allocated on the node. Can hold multiple locations./var/lib/elasticsearchpath.data
logsLog files location./var/log/elasticsearchpath.logs
pluginsPlugin files location. Each plugin will be contained in a subdirectory./usr/share/elasticsearch/plugins
repoShared 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 configuredpath.repo
scriptLocation of script files./etc/elasticsearch/scriptspath.scripts
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值