LInux:
查看centos版本:lsb_release -a
CentOS release 6.5 (Final)
准备:
java安装
yum list installed | grep java
yum -y list java*
yum install java-1.8.0-openjdk.x86_64
安装:
cd /data
mkdir eshome
cd eshome
wget
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz
tar -xzvf
elasticsearch-5.6.3.tar.gz
mv elasticsearch-5.6.3 elasticsearch
useradd es
# 设置 es 用户的密码
passwd es
# 将 /data/eshome/elasticsearch 的拥有者设置为 es
chown -R es:es /data/eshome/elasticsearch
编辑配置文件vi config/elasticsearch.yml
network.host: 你自己的服务器iphttp.port: 9200
切换到es用户,启动 es
su es
前台启动:./bin/elasticsearch
后台启动:./bin/elasticsearch -d
ps -ef | grep elasticsearch kill -9
jps | grep Elasticsearch kill -9
如果启动报错请跳到后面看:
启动Elasticsearch常见问题
Head插件安装
安装nodejs
sudo yum install nodejs
npm安装:
sudo yum install npm
安装head插件:
cd elasticsearch
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
grunt安装:
sudo npm install -g grunt-cli --registry=
https://registry.npm.taobao.org
(如果慢可用淘宝镜像资源)
sudo npm install grunt --registry=
https://registry.npm.taobao.org
grunt -version
npm install grunt-contrib-clean
npm install grunt-contrib-concat
npm install grunt-contrib-watch
npm install grunt-contrib-connect
npm install grunt-contrib-copy
npm install grunt-contrib-jasmine --registry=
https://registry.npm.taobao.org
(有个下载比较慢,失败可以重试)
以下来源网上未验证
在elasticsearch-head目录下node_modules/grunt下如果没有grunt二进制程序,需要执行:
cd elasticsearch-head
npm install grunt --save
cluster.name: xuedasearch
node.name: node-1
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["ip2","ip3"]
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
修改Gruntfile.js
打开vim elasticsearch-head/Gruntfile.js,找到下面connect属性,新增hostname: '0.0.0.0',
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
启动elasticsearch-head
在elasticsearch-head目录下,运行启动命令:
cd elasticsearch-head
前台启动:grunt server
后台启动:nohup grunt server &
访问:http://127.0.0.1:9100
ps aux|grep head
kill -9
启动Elasticsearch常见问题:
问题:
max file descriptors [4096] for elasticsearch process is too low,increase to at least [65536]
解决方法:
ulimit -Hn65536
问题:
max virtual memory areas vm.max_map_count [65530] is too low,increase to at least [262144]
解决方法: 提高vm.max_map_count 的大小
在阿里云上可能出现的问题:
system call filters Failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解决方法:在es配置中加入下面命令即可vim config/elasticsearch.yml
bootstrap.system_call_filter: false
问题:max number of threads [1024] for user [es] is too low,increase to at least [2048]
*softnproc1024
修改为:
*softnproc2048
问题:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000,2060255232,0) Failed; error='Cannot allocate memory' (errno=12)
解决方法:
# 由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配# 如果使用虚拟机安装,内存最好不小于2G# vim config/jvm.options -Xms512m-Xmx512m
运维API:
1. 集群状态:
http://host:9200/_cluster/health?pretty
2. 节点状态:
http://host:9200/_nodes/process?pretty
3. 分片状态:
http://host:9200/_cat/shards
4. 索引分片存储信息:
http://host:9200/index/_shard_stores?pretty
5. 索引状态:
http://host:9200/index/_stats?pretty
6. 索引元数据:
http://host:9200/index?pretty