Centos7.4 安装elasticsearch6.1.3集群部署

前端之家收集整理的这篇文章主要介绍了Centos7.4 安装elasticsearch6.1.3集群部署前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Centos7.4 安装elasticsearch6.1.3集群部署


安装elasticsearch


1.依赖环境安装

这里使用的java 是1.8.0_77的版本.使用的是rpm 安装包的形式进行部署安装 。

配置环境变量


[root@node1 ~]# cat .bash_profile
export JAVA_HOME=/usr/java/jdk1.8.0_77/ # JAVA_HOME变两个路径
export JAVA_BIN=/usr/java/jdk1.8.0_77/bin
export PATH=${JAVA_HOME}bin:$PATH

检测java环境安装是否正常


[root@node1 ~]# java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03,mixed mode)

2.elasticsearch使用的是6.1.3版本。elasticsearch-6.1.3.tar.gz


[root@node1 local]# tar -zxvf elasticsearch-6.1.3.tar.gz
[root@node1 local]# ls
bin elasticsearch-6.1.3 elasticsearch-6.1.3.tar.gz etc games include lib lib64 libexec sbin share src

修改配置文件


node1
[root@node1 local]# cd node1/config/
[root@node1 config]# cat elasticsearch.yml | grep -v "^#"
cluster.name: elasticsearch #集群的名称
node.name: node1 #节点的名称
bootstrap.memory_lock: false #另一种选择是在Linux / Unix系统上使用mlockall或在Windows上使用 VirtualLock,以尝试将进程地址空间锁定到RAM中,防止任何Elasticsearch 内存被换出。
bootstrap.system_call_filter: false #为禁用系统调用过滤器false
network.host: 133.1.11.39 #绑定到回送地址

http.port: 9200 #设置对外服务的http端口,默认为9200
discovery.zen.ping.unicast.hosts: ["133.1.11.39","133.1.11.39:9202","133.1.11.39:9203"]
discovery.zen.minimum_master_nodes: 2


node2
cluster.name: elasticsearch
node.name: node2
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 133.1.11.39

http.port: 9202
discovery.zen.ping.unicast.hosts: ["133.1.11.39","133.1.11.39:9203"]
discovery.zen.minimum_master_nodes: 2

node3
cluster.name: elasticsearch
node.name: node3
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 133.1.11.39

http.port: 9203
discovery.zen.ping.unicast.hosts: ["133.1.11.39","133.1.11.39:9203"]
discovery.zen.minimum_master_nodes: 2


[root@node1 config]# vim jvm.options 
-Xms512m
-Xmx512m

3.需要修改的配置参数

vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

vim /etc/security/limits.d/90-nproc.conf
* soft nproc 2048

vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p

4.启动elasticsearch 不能使用root 用户需要进行创建用户

[root@node1 ~]# groupadd es
[root@node1 ~]# useradd es -g es -p es
[root@node1 ~]# chown -R es:es /usr/local/node1


启动elasticsearch


[root@node1 bin]# ./elasticsearch -d

5.进行访问测试


[root@node1 bin]# curl http://133.1.11.39:9200
{
"name" : "node1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "dJo2cKFfSO-M-qwMF9upjg",
"version" : {
"number" : "6.1.3",
"build_hash" : "af51318",
"build_date" : "2018-01-26T18:22:55.523Z",
"build_snapshot" : false,
"lucene_version" : "7.1.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know,for Search"
}



安装head 插件

1.安装NodeJS


[root@node1 ~]# wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.5.0-linux-x64.tar.gz
[root@node1 ~]#tar -zxvf node-v4.5.0-linux-x64.tar.gz -C /usr/local

配置环境变量
export NODE_HOME=/usr/local/node-v4.5.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin/
export NODE_PATH=$NODE_HOME/lib/node_modules
[root@node1 ~]#source /etc/profile

2.安装npm


[root@node1 ~]# npm install -g cnpm --registry=https://registry.npm.taobao.org

3.使用npm安装grunt


/usr/local/node-v4.5.0-linux-x64/bin/grunt -> /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt/bin/grunt
grunt@1.0.2 /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt
├── path-is-absolute@1.0.1
├── eventemitter2@0.4.14
├── grunt-known-options@1.1.0
├── rimraf@2.2.8
├── exit@0.1.2
├── iconv-lite@0.4.19
├── coffeescript@1.10.0
├── nopt@3.0.6 (abbrev@1.1.1)
├── glob@7.0.6 (inherits@2.0.3,fs.realpath@1.0.0,once@1.4.0,inflight@1.0.6)
├── findup-sync@0.3.0 (glob@5.0.15)
├── minimatch@3.0.4 (brace-expansion@1.1.11)
├── grunt-cli@1.2.0 (resolve@1.1.7)
├── js-yaml@3.5.5 (esprima@2.7.3,argparse@1.0.10)
├── grunt-legacy-util@1.0.0 (getobject@0.1.0,async@1.5.2,hooker@0.2.3,underscore.string@3.2.3,which@1.2.14,lodash@4.3.0)
├── grunt-legacy-log@1.0.1 (hooker@0.2.3,colors@1.1.2,underscore.string@3.3.4,grunt-legacy-log-utils@1.0.0,lodash@4.17.5)
└── dateformat@1.0.12 (get-stdin@4.0.1,meow@3.7.0)

[root@node1 ~]# npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy
/usr/local/node-v4.5.0-linux-x64/bin/grunt -> /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@1.2.0 /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli
├── grunt-known-options@1.1.0
├── nopt@3.0.6 (abbrev@1.1.1)
├── resolve@1.1.7
└── findup-sync@0.3.0 (glob@5.0.15

4.版本确认


[root@node1 ~]# node -v
v4.5.0
[root@node1 ~]# npm -v
2.15.9
[root@node1 ~]# grunt -version
grunt-cli v1.2.0

5.下载head插件源码


[root@node1 ~]# wget https://github.com/mobz/elasticsearch-head/archive/master.zip
[root@node1 ~]# unzip master.zip -d /usr/local/

6.下载依赖

[root@node1 elasticsearch-head-master]# npm install -g grunt-cli 
/usr/local/node-v4.5.0-linux-x64/bin/grunt -> /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@1.2.0 /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli
├── grunt-known-options@1.1.0
├── resolve@1.1.7
├── nopt@3.0.6 (abbrev@1.1.1)
└── findup-sync@0.3.0 (glob@5.0.15)


[root@node1 elasticsearch-head-master]# grunt -version
grunt-cli v1.2.0
[root@node1 elasticsearch-head-master]# npm install

二. 配置ElasticSearch

停止ElasticSearch


[root@node1 local]# jps
28516 Jps
12072 Elasticsearch

1.配置 ElasticSearch,使得HTTP对外提供服务

node1 上面配置
[root@node1 ]# vim config/elasticsearch.yml
# 增加新的参数,这样head插件可以访问es。设置参数的时候:后面要有空格
http.cors.enabled: true
http.cors.allow-origin: "*"

2.修改head插件配置文件


[root@node1 elasticsearch-head-master]# vim Gruntfile.js
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
修改修改连接地址:_site/app.js
[root@node1 elasticsearch-head-master]# vim _site/app.js
_node_handler: function(data) {
if(data) {
// this.prefs.set("app-base_uri",this.cluster.base_uri);
this.prefs.set("app-base_uri" )|| "http://133.1.11.39:9200";
if(data.version && data.version.number)
this.cluster.setVersion(data.version.number);

3.启动elasticsearch,head


[root@node1 bin]# ./elasticsearch -d #分别启动3个节点
[root@node1 elasticsearch-head-master]# nohup grunt server &

4.注意坑


如果出现集群无法链接
请注意删除node1 下面/usr/local/node1/data 下面的目录,不然造成数据不统一 不能呢链接head 插件
原文链接:https://www.f2er.com/centos/374610.html

猜你在找的CentOS相关文章