Elasticsearch——安装与运行

1、下载
官网:

https://www.elastic.co/cn/downloads/past-releases#elasticsearch

选择6.8.4版本

https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-6-1

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.1.tar.gz

2、解压安装


tar -xvzf elasticsearch-6.6.1.tar.gz
#elasticsearch不能用root用户启动,需创建新用户
#创建用户组:
groupadd elasticsearch
#创建用户,设定密码
useradd elasticsearch -g elasticsearch -p 123456
#修改elasticsearch目录权限
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch

3、修改配置
vi config/elasticsearch.yml

#集群名
cluster.name: es-sfboss
#数据、日志目录
path.data: /run/data/es
path.logs: /run/data/es/logs
#ip访问限制
#network.bind_host: 
#是否运行跨主机交互
#network.publish_host: 
network.host: 0.0.0.0
#端口
http.port: 9102
transport.tcp.port: 9103
#跨域
http.cors.enabled: true
http.cors.allow-origin: "*"

问题1:

 bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

以上问题,需要修改系统配置
vi /etc/sysctl.conf

vm.max_map_count=655360
#保存后,执行如下命令:
sysctl -p

问题2:

max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

修改:

vi /etc/security/limits.conf
#esuser  为运行 elasticsearch的用户
* soft nofile 65536
* hard nofile 65536
esuser  soft nproc 65536
esuser  hard nproc 65536

然后重新elasticsearch即可。

4、Elasticsearch Head安装
a、首先安装node
选择Linux Binaries (x64) 包,解压版,head适用次node版本,高版本不适用。

https://nodejs.org/en/download/
#下载
wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz
#安装xz
yum -y install xz
#解压 
mv node-v10.16.0-linux-x64.tar.xz /usr/local/
cd /usr/local/
xz -d node-v10.16.0-linux-x64.tar.xz
tar -xvf node-v10.16.0-linux-x64.tar
ln -s node-v10.16.0-linux-x64 nodejs
rm -fr node-v10.16.0-linux-x64.tar
#配置到系统环境
#vi /etc/profile 
export NODE_HOME=/usr/local/nodejs
export PATH=$NODE_HOME/bin:$PATH
#source /etc/profile 

b、head插件安装

https://github.com/mobz/elasticsearch-head
wget https://github.com/mobz/elasticsearch-head/archive/master.zip

解压,安装

cd /soft/app/elasticsearch-head-master
#安装 ,使用淘宝镜像安装更容易成功
#npm install
#npm install cnpm -g --registry=https://registry.npm.taobao.org
npm install  --registry=https://registry.npm.taobao.org
#启动
npm run start

c、修改elasticsearch head 端口
vi Gruntfile.js
修改port

connect: {
  server: {
    options: {
      port: 9101,
      base: '.',
      keepalive: true
    }
  }
}

启动elasticsearch

./bin/elasticsearch -d

启动 elasticsearch head

cd 
npm run start &

分词

https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v7.1.0

5、解锁es只读

PUT方法


http://ip:9200/_all/_settings

json参数

{
  "index.blocks.read_only_allow_delete": null
}

** 6、elasticdump导入导出**

安装

npm install elasticdump -g

导出

elasticdump  --limit 10000  --input=http://localhost:9200/demo --output=D:/ES/date/demo.json

本地导入

elasticdump --limit 10000  --input=D:/ES/date/demo.json --output=http://localhost:9200/demo

远程导入

elasticdump  --limit 10000 --input=http://192.168.1.2:9200/demo --output=http://127.0.0.1:9200/demo

#导入新索引,换index名称,type名称
elasticdump  --limit 10000 --input=http://192.168.1.2:9200/demo --output=http://192.168.1.2:9200/ --output-index test/doc

** 7、reindex**

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值