cluster.name: website-application
node.name: node-1-master-175-9200
node.master: true
#node.attr.rack: r1
node.data: true
path.data: /usr/local/elasticsearch/elasticsearch-5.5.2/data
path.logs: /usr/local/elasticsearch/elasticsearch-5.5.2/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.1.175
http.port: 9200
transport.tcp.port: 9300
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点。
discovery.zen.ping.unicast.hosts: ["192.168.1.175:9300"]
# 为了避免脑裂,集群节点数最少为 (有master资格节点数/2) + 1
discovery.zen.minimum_master_nodes: 1
#discovery.zen.ping_timeout: 120s
#gateway.recover_after_nodes: 2
#gateway.recover_after_time: 5m
#gateway.expected_nodes: 1
#script.engine.groovy.inline.search: on
#script.engine.groovy.inline.aggs: on
#indices.recovery.max_bytes_per_sec: 20mb
node.max_local_storage_nodes: 3
action.destructive_requires_name: false
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题
http.cors.enabled: true
http.cors.allow-origin: "*"
从节点
cluster.name: website-application
node.name: node-2-176-9200
node.master: false
#node.attr.rack: r1
node.data: true
path.data: /usr/local/elasticsearch/elasticsearch-5.5.2/data
path.logs: /usr/local/elasticsearch/elasticsearch-5.5.2/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点。
discovery.zen.ping.unicast.hosts: ["192.168.1.175:9300"]
# 为了避免脑裂,集群节点数最少为 半数+1
discovery.zen.minimum_master_nodes: 1
#discovery.zen.ping_timeout: 120s
#gateway.recover_after_nodes: 2
#gateway.recover_after_time: 5m
#gateway.expected_nodes: 1
#script.engine.groovy.inline.search: on
#script.engine.groovy.inline.aggs: on
#indices.recovery.max_bytes_per_sec: 20mb
node.max_local_storage_nodes: 3
action.destructive_requires_name: false
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题
http.cors.enabled: true
http.cors.allow-origin: "*"
es启动需要在非root账号下,所以需要新建一个用户。新建用户后,需要分配文件权限,否则会报错:
groupadd es
useradd es -g es -p es
chown -R es:es /usr/local/elasticsearch
chmod 775 /usr/local/elasticsearch
可能的报错:
java.nio.file.AccessDeniedException: 或
bash: ./elasticsearch: Permission denied
启动命令 ./bin/elasticsearch
查看日志和报错:
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
原因
每个进程最大打开文件数大小太小,用户拥有的内存权限太小,查看命令如下:
ulimit -Hn
ulimit -Sn
解决
切换到root账户下:
vi /etc/security/limits.conf添加或修改以下配置(用户退出后重新登录生效):
* hard nofile 65536
* soft nofile 65536
注意:65535不行,必须是65536
然后修改内存分配:
sudo sysctl -w vm.max_map_count=262144
#!/bin/sh
NAME=elasticsearch
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
/usr/local/elasticsearch/elasticsearch-5.5.2/bin/elasticsearch -d
tail -300f /usr/local/elasticsearch/elasticsearch-5.5.2/logs/website-application.log
echo "---------------"
下载解压:
wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz
xz -d node-v6.9.2-linux-x64.tar.xz
tar -xvf node-v6.9.2-linux-x64.tar
修改:
vi /etc/profile
增加配置:
export NODE_HOME=/usr/local/elasticsearch/node-v6.9.2-linux-x64
export PATH=$NODE_HOME/bin:$PATH
使之生效:
source /etc/profile
查看版本:
node -v
npm -v
cd /usr/local/elasticsearch/elasticsearch-head-maste
npm install [email protected] --ignore-scripts
可以在elasticsearch-head下使用npm run start启动,可能会报警告:
[root@redis1 elasticsearch-head-master]# npm run start
> [email protected] start /usr/local/elasticsearch/elasticsearch-head-master
> grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
使用命令安装缺失的插件:
npm install grunt-contrib-clean grunt-contrib-concat grunt-contrib-watch grunt-contrib-connect grunt-contrib-copy grunt-contrib-jasmine
使用grunt server命令启动报错处理:
[root@redis1 elasticsearch-head-master]# grunt server
-bash: grunt: 未找到命令
安装grunt快捷命令:
npm install -g grunt-cli
此后可以在elasticsearch-head下使用grunt server 命令启动
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题
http.cors.enabled: true
http.cors.allow-origin: "*"
# http.cors.allow-headers: "Authorization"
wget https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v5.5.2/elasticsearch-analysis-pinyin-5.5.2.zip
unzip elasticsearch-analysis-pinyin-5.5.2.zip
mv elasticsearch ./elasticsearch-5.5.2/plugins/pinyin
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.url: "http://192.168.2.41:9200"
kibana.index: ".kibana"
启动:./bin/kibana
后台启动:nohup ./bin/kibana &