elasticsearch-5.6.1集群搭建/ik插件/head工具/传输数据

环境信息:

linux,CentOS Linux release 7.5.1804 (Core)

在Linux下执行命令:java -version,检查Jar包是否安装,安装java版本至少是1.8以上。

集群安装:

下载地址:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.1.tar.gz

集群形式:在三台虚拟机下都要执行所说步骤/命令。

一:解压到当前文件夹:

cd /usr/local

tar -xzvf elasticsearch-5.6.1.tar.gz

二:添加用户组权限:

groupadd elasticsearch

##添加elasticsearch组

 

useradd elasticsearch -g elasticsearch -p elasticsearch

##useradd  elasticsearch(用户名) -g elasticsearch(组名) -p elasticsearch(密码)

 

chown -R elasticsearch:elasticsearch elasticsearch-5.6.1

##更改elasticsearch文件夹以及内部文件的所属用户以及组为elasticsearch

完成后如图:

三:修改配置文件:

cd /usr/local/elasticsearch-5.6.1/config

vim elasticsearch.yml

集群配置信息:

示例为集群主节点的配置,集群机器都要按照搭建意向修改(node-1,node-2,node-3):

cluster.name: "cluster456"    #集群名字,三台机器需要一致

node.name: "node-1"              #节点名字,node-1,node-2,node-3

node.master: true                   #表示节点有争取做主节点的权限

node.data: true                       #表示节点有争取能够存放数据的权限

http.cors.enabled: true
http.cors.allow-origin: "*"

bootstrap.system_call_filter: false

network.host: 10.6.5.54       #改为本机ip
 
transport.tcp.port: 9300

http.port: 9200

discovery.zen.ping.unicast.hosts: ["10.6.5.54:9300","10.6.5.57:9300","10.6.5.58:9300"]     #写入集群机器的ip 

四:启动elasticsearch服务:

需要先切换至elasticsearch用户

su elasticsearch

cd /usr/local/elasticsearch-5.6.1/bin

./elasticsearch

或者后台运行, nohup ./elasticsearch(路径) & (常用)

tail nohup -f,可查看启动日志  

ps -ef | grep elasticsearch,kill -9 进程号,可杀掉进程。

三台机器同时启动,集群环境搭建成功。

五:常见问题警告:

问题一:警告提示

要求配置文件的格式正确 " "。

[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter: 

java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]

通常会出现报错信息:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]


问题二:ERROR: bootstrap checks failed

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]

解决:切换到root用户,编辑limits.conf 添加类似如下内容

vi /etc/security/limits.conf 

添加如下内容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

 

问题三:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

解决:切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf 

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 2048

 

问题四:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

解决:切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl -p


然后,重新启动elasticsearch,即可启动成功。

 

安装ik插件
elasticsearch-analysis-ik

离线安装:

下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases

下载到elasticsearch/plugins/目录下,解压并重启。

在线安装:

使用elasticsearch-plugin来安装(version> v5.5.1;使用elasticsearch用户):

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.1/elasticsearch-analysis-ik-5.6.1.zip

成功安装后重启。

验证:

创建index:

curl -XPUT http://localhost:9200/index
curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word"
            }
        }
}'

 

安装head工具

安装node并配置环境变量

下载:

wget https://nodejs.org/dist/v8.9.2/node-v8.9.2-linux-x64.tar.xz

解压:

tar.xz文件,先 xz -d xxx.tar.xz 将 xxx.tar.xz解压成 xxx.tar 然后,再用 tar xvf xxx.tar来解包。

然后配置环境变量。

 git clone https://github.com/mobz/elasticsearch-head.git

cd elasticsearch-head

npm install

npm install grunt-cli

npm run start    #npm run start &(后台启动)

####

vi Gruntfile.js

connect: {
    server: {
        options: {
            port: 9100,
            hostname: '*',
            base: '.',
               keepalive: true
            }
        }
    }

#修改 vim _site/app.js 文件:修改head的连接地址:localhost->本机ip

若连接有问题,解决方案是修改 cd 命令进入到elasticsearch-5.6.4 /config 文件中 vi elasticsearch.yml文件下添加 :

        http.cors.enabled: true
        http.cors.allow-origin: "*"

 

传输工具:elasticsearch-dump

下载:yum install nodejs npm

下载:npm install elasticdump

进入目录:cd node_modules/elasticdump/bin

举例:

elasticsearch数据库索引操作:

./elasticdump --input=http://127.0.0.1:9200/ --output=http://127.0.0.2:9200/ --all=true  ##(复制全部索引与数据)
                                                                                 
复制索引:
./elasticdump --input=http://127.0.0.1:9200/index01 --output=http://127.0.0.2:9200/index02 --type=mapping

##注解:

127.0.0.1:源es的ip;

index01:需要迁移的索引名;

127.0.0.2:目的es的ip;

index02:新索引名;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值