linux-安装elasticSearch-6.6.2

丶灬走出姿态 提交于 2020-05-04 10:44:40
环境
操作系统:ubuntu16.04
软件版本:elasticsearch-oss-6.6.2
 
步骤
 
官网
 
下载
 
解压
tar -zxf elasticsearch-6.6.2.tar.gz
 
移动文件
mv elasticsearch-6.6.2 /opt/
 
更改配置
cd /opt/elasticsearch-6.6.2/config
vim elasticsearch.yml
# 开放以下配置
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
 
在elasticsearch配置文件中授权(elasticsearch-head查询集群用)
vim /elasticsearch/elasticsearch.yml
# elasticsearch中启用CORS
http.cors.enabled: true
# 允许访问的IP地址段,* 为所有IP都可以访问
http.cors.allow-origin: "*"
 
更改JVM运行内存大小
vim jvm.options
# 修改最小3G,最大3G
-Xms3g
-Xmx3g
 
启动(需要用非root账户运行)
bin/elasticsearch
#后台运行
bin/elasticsearch -d
 
访问:
http://localhost:9200
 
安装elasticsearch-head控制台插件
下载
wget https://codeload.github.com/mobz/elasticsearch-head/zip/master
 
变更名称,并移动目录
mv master /opt/elasticsearch-head-master.zip
 
安装(依赖nodejs,nodejs安装略)
npm install
 
运行
npm run start
 
后台运行(关闭,则ps查找进程再kill)
./node_modules/grunt/bin/grunt server &
 
修改Gruntfile.js文件中的connect.server.options节点,添加如下
hostname: ‘*’
 
访问:
http://localhost:9100
 
增加集群配置

在两台机器上分别安装elasticsearch-6.6.2 ,IP分别为:"172.16.10.3", "172.16.10.4",其中172.16.10.4为主slave节点

服务一:
cd /opt/elasticsearch-6.6.2/config
vim elasticsearch.yml
# 当前master为主,加入其它slave(从节点主机)
cluster.name: rise-elk-cluster
node.name: node-1
node.master: true
network.host: 172.16.10.4
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.16.10.3", "172.16.10.4"]
gateway.recover_after_nodes: 2
 
服务二:
cd /opt/elasticsearch-6.6.2/config
vim elasticsearch.yml
# 当前slave为主
cluster.name: rise-elk-cluster
node.name: node-2
node.master: false
network.host: 172.16.10.3
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.16.10.3", "172.16.10.4"]
gateway.recover_after_nodes: 2
 
查看集群
curl http://172.16.65.4:9200/_cat/health?v
 
X-Pack认证(CA证书+密码)
 
6.3.X后默认带的license是basic的,不支持security这类商业特性。 你可以将license改为trial,但是只有30天的试用期;
6.4版本不需要安装x-pack,默认已内置安装组件
 
# 在/bin目录执行如下命令来生成CA证书。
./elasticsearch-certutil ca --ca-dn "CN=WolfBolin Elatic CA" --out /opt/elasticsearch-6.6.2/config/wolfbolin-elastic-ca.p12
 
# 在/bin目录执行如下命令来生成cert证书
./elasticsearch-certutil cert -ca /opt/elasticsearch-6.6.2/config/wolfbolin-elastic-ca.p12 --out /opt/elasticsearch-6.6.2/config/wolfbolin-elastic-certificates.p12
 
# 编辑vim elasticsearch.yml配置,重启elasticsearch服务
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /opt/elasticsearch-6.6.2/config/wolfbolin-elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /opt/elasticsearch-6.6.2/config/wolfbolin-elastic-certificates.p12
 
# 进入/bin/目录执行如下命令来生成密码
./elasticsearch-setup-passwords auto(自动生成)
./elasticsearch-setup-passwords interactive(手动设置)
 
问题
 
原因
1.(centos7)在【启动】bin>./elasticsearch 的时候
【报错】max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案
sudo vi /etc/sysctl.conf 文件最后添加一行
vm.max_map_count=262144
sudo sysctl -p
 
原因
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
解决方案
#修改
vim elasticsearch.yml
#取消注释保留一个节点
cluster.initial_master_nodes: ["node-1"]
 
原因
由于ES新节点的数据目录data存储空间不足,导致从master主节点接收同步数据的时候失败,此时ES集群为了保护数据,会自动把索引分片index置为只读read-only;
修改Eleastisearch索引name对应的配置,取消单个索引只读状态,或修改了所有的索引只读状态(_all表示所有索引)
Elasticsearch exception [type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];]
解决方案
1 磁盘扩容,可在配置文件中修改ES数据存储目录,重启ES
2 放开索引只读设置,在服务器上通过curl工具发起PUT请求
采用第二种,在服务器上执行如下请求:
curl -XPUT -H "Content-Type: applica0tion/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
 
原因
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
# elasticsearch用户拥有的内存权限太小,至少需要262144
解决方案
在/etc/sysctl.conf文件最后添加一行
vi /etc/sysctl.conf
vm.max_map_count=262144
# 保存后执行
sysctl -p
 
 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!