elasticsearch集群部署

Elasticsearch是一个分布式搜索服务,提供Restful API,底层基于Lucene,采用多shard的方式保证数据安全,并且提供自动resharding的功能,github等大型的站点也都采用Elasticsearch作为其搜索服务。废话在此就不多赘述了,下面记录下CentOS7下Elasticsearch集群部署过程:

创新互联公司公司2013年成立,是专业互联网技术服务公司,拥有项目成都网站建设、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元三都做网站,已为上家服务,为三都各地企业和个人服务,联系电话:028-86922220

 

1)基础信息

elk-es01.kevin.cn    192.168.10.44

elk-es02.kevin.cn    192.168.10.45

elk-es03.kevin.cn    192.168.10.46

下面操作在三个节点机上都要操作

[root@elk-es01 ~]# systemctl stop firewalld.service

[root@elk-es01 ~]# systemctl disable firewalld.service

[root@elk-es01 ~]# firewall-cmd --state

not running

 

[root@elk-es01 ~]# setenforce 0

setenforce: SELinux is disabled

[root@elk-es01 ~]# getenforce

Disabled

[root@elk-es01 ~]# vim /etc/sysconfig/selinux

......

SELINUX=disabled

 

[root@elk-es01 ~]# cat /etc/hosts

.....

192.168.10.44 elk-es01.kevin.cn

192.168.10.45 elk-es02.kevin.cn

192.168.10.46 elk-es03.kevin.cn

 

[root@elk-es01 ~]# /usr/sbin/ntpdate ntp1.aliyun.com

 

2)安装java8环境,官方建议5.4版本最至少Java 8或以上(三个节点机都要操作)

解压文件到/opt/

jdk-8u121-linux-x64.tar.gz

配置环境变量

#vim /etc/profile

#**************DMP JAVA ENV********************

export JAVA_HOME=/opt/jdk1.8.0_121

export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 

 

 

3)安装elasticsearch(三个节点机都要操作)

 

创建用户,用户组

#groupadd  es

#useradd es –g es –p 123456

#chown –R es:es /opt/els-node1

#chown –R es:es /opt/els-node2

#chown –R es:es /opt/els-node3

 

创建数据目录和日志目录

#mkdir -p /opt/els-data/{data1,log1}

#mkdir -p /opt/els-data/{data2,log2}

#mkdir -p /opt/els-data/{data3,log3}

#chown -R es:es /opt/els-node*

 

优化系统

1,

# cd /etc [root@localhost etc]

# cp sysctl.conf sysctl.conf.bak

# vim sysctl.conf

# elasticsearch config start

vm.max_map_count=262144

# elasticsearch config end

#sysctl -p

2,

# cd /etc/security/

cp limits.conf limits.conf.bak

然后编辑limits.conf增加如下配置:

# elasticsearch config start

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

# elasticsearch config end

 

下载安装包

#wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.zip

 

配置els

 

 

 

Node-1

node.name: node-1

path.data: /opt/els-data/data1

path.logs: /opt/els-data/logs1

network.host: 192.168.15.143

transport.tcp.port: 9301

http.port: 9201

discovery.zen.ping.unicast.hosts: ["192.168.15.143:9301", "192.168.15.143:9302", "192.168.15.143:9303"]

http.cors.enabled: true

http.cors.allow-origin: "*"

 

Node-2

node.name: node-2

path.data: /opt/els-data/data2

path.logs: /opt/els-data/logs2

network.host: 192.168.15.143

transport.tcp.port: 9302

http.port: 9202

discovery.zen.ping.unicast.hosts: ["192.168.15.143:9301", "192.168.15.143:9302", "192.168.15.143:9303"]

http.cors.enabled: true

http.cors.allow-origin: "*"

 

Node-3

node.name: node-3

path.data: /opt/els-data/data3

path.logs: /opt/els-data/logs3

network.host: 192.168.15.143

transport.tcp.port: 9303

http.port: 9203

discovery.zen.ping.unicast.hosts: ["192.168.15.143:9301", "192.168.15.143:9302", "192.168.15.143:9303"]

http.cors.enabled: true

http.cors.allow-origin: "*"

 

启动服务

./bin/elasticsearch -d

测试:

curl "192.168.15.143:9203"

{

  "name" : "node-3",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "5HJLIt_5Ra26HHs4vNRQuA",

  "version" : {

    "number" : "6.3.0",

    "build_flavor" : "default",

    "build_type" : "zip",

    "build_hash" : "424e937",

    "build_date" : "2018-06-11T23:38:03.357887Z",

    "build_snapshot" : false,

    "lucene_version" : "7.3.1",

    "minimum_wire_compatibility_version" : "5.6.0",

    "minimum_index_compatibility_version" : "5.0.0"

  },

  "tagline" : "You Know, for Search"

}

 


分享标题:elasticsearch集群部署
URL网址:http://ybzwz.com/article/pjeejj.html