centos 6.5安装Elasticsearch 5.6.3集群和Head插件
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
es 规定 root 用户不能启动 es,所以需要创建一个用户来启动 es
# 创建用户名为 es 的用户
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
修改配置文件elasticsearch.yml:
vim config/elasticsearch.yml,修改为以下内容:
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
关闭head插件:
ps aux|grep head
kill -9
启动Elasticsearch常见问题:
问题:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方法:
#切换到root用户修改vim /etc/security/limits.conf# 在最后面追加下面内容es hard nofile 65536es soft nofile 65536
修改后重新登录 es 用户,使用如下命令查看是否修改成功
ulimit -Hn65536
问题:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法: 提高vm.max_map_count 的大小
# 切换到root用户vim /etc/sysctl.conf# 在最后面追加下面内容vm.max_map_count=262144# 使用 sysctl -p 查看修改后的结果sysctl -p
在阿里云上可能出现的问题:
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]
解决方法:vi /etc/security/limits.d/90-nproc.conf ,修改配置如下:
* soft nproc 1024
修改为:
* soft nproc 2048
问题:
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.