ES搭建

2020-11-25  本文已影响0人  Lolipiza

本次搭建的为两台ES,一主一从,环境为CentOS  7.6.1810;java version 1.8.0_181;elasticsearch 6.8.0


那么开始


非docker搭建:

需要java环境,没有下载java的先下载配置一下:

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

查看需要的java版本然后:

wget xxxxxx(下载tar.gz的地址)

mkdir /usr/local/java/

tar -zxvf xxxxx(下载的名称).tar.gz -C /usr/local/java/

vim /etc/profile 在最后添加:

export JAVA_HOME=/usr/local/java/jdk1.8.0_171

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH

保存,环境变量刷新:

source /etc/profile

建立软连接

ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java

权限设置:

chmod +x /usr/local/java/jdk1.8.0_181/bin/java

查看是否安装成功:

java -version


先下载es1.6.8,解压到文件夹,本文elasticsearch文件夹放置在/usr/local/

1.配置文件的配置

master:

cluster.name: esCluster

action.auto_create_index: true

node.name: node-1

node.master:  true

path.data: /apprun/elasticsearch-6.8.0/data

network.host: 你的node IP

http.port: 9200

discovery.zen.ping.unicast.hosts: ["master IP","node1 IP","node2 IP",...]

bootstrap.memory_lock: false

bootstrap.system_call_filter: false

node:

cluster.name: esCluster

action.auto_create_index: true

node.name: node-2

node.master:  false

path.data: /apprun/elasticsearch-6.8.0/data

network.host: 你的node IP

http.port: 9200

discovery.zen.ping.unicast.hosts: ["master IP","node1 IP","node2 IP",...]

bootstrap.memory_lock: false

bootstrap.system_call_filter: false

2.创建用户(设此处用户为es)

groupaddes

useraddes -g es -p es

chown-R es:es /usr/local/elasticsearch/

3.配置修改虚拟内存

vi /etc/sysctl.conf

添加vm.max_map_count=655360

4.修改limits.d目录下的配置文件

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

保存,运行

sysctl –p

5.运行ES

进入es的bin文件夹,运行su es,再运行

nohup ./elasticsearch &

6.查看是否运行正常

curl -XGET http://你电脑IP:9200/_cluster/health


PS:如果需要引入xpack用户密码校验,需要:

1.在每一台ES主机的elasticsearch.yml最后加上

xpack.security.enabled: true

xpack.security.transport.ssl.enabled: true

xpack.security.transport.ssl.verification_mode:certificate

xpack.security.transport.ssl.keystore.path:elastic-certificates.p12

xpack.security.transport.ssl.truststore.path:

elastic-certificates.p12

2.任意一台机器的6.8.0 elasticsearch目录下执行:

bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""

3.将config目录下的elastic-certificates.p12拷贝到所有elasticsearch的机器的   config目录下

4.elasticsearch目录下执行,设置xpack账号密码:

bin/elasticsearch-setup-passwords interactive

5.每个节点重启应用,之后使用接口都需要加上账号密码,如:

curl -u username:password http://IP:9200/_cat/indices?pretty

上一篇下一篇

猜你喜欢

热点阅读