elasticsearch 7.6 安装部署

操作系统版本:centos 7.6  

版本:elasticsearch 7.6.1

jdk版本 11.0.6


服务器列表:

192.168.0.31

192.168.0.32

192.168.0.33


1、安装jdk 11

具体的步骤省略

2、安装elasticsearch

官网下载elasticsearch-7.6.1-x86_64 rpm安装包

rpm -ivh elasticsearch-7.6.1-x86_64.rpm 


修改配置文件

#cat /etc/elasticsearch/elasticsearch.yml |grep -v "^#"

cluster.name: Hnbd#集群名称

node.name: Es-31#集群节点名称

path.data: /var/lib/elasticsearch#数据文件路径

path.logs: /var/log/elasticsearch#日志文件路径

bootstrap.memory_lock: true#锁定物理内存地址,防止elasticsearch内存被交换出去,也就是避免es使用swap交换分区

network.host: 0.0.0.0#ip地址

http.port: 9200#开放端口号

discovery.seed_hosts: ["192.168.0.31","192.168.0.32", "192.168.0.33"]#设置集群节点地址

cluster.initial_master_nodes: ["Es-31"]#指定主节点列表

http.cors.enabled: true#打开跨域访问,head 插件需要这打开这两个配置

http.cors.allow-origin: "*"


添加开机服务启动

systemctl enable elasticsearch.service


设置JVM堆内存大小,根据服务器内存大小进行设置,最好不要超过总内存的一半

#cat /etc/elasticsearch/jvm.options 

## JVM configuration

# Xms represents the initial size of total heap space

# Xmx represents the maximum size of total heap space

-Xms2g

-Xmx2g


设置elasticsearch的JAVA_HOME

#cat /etc/sysconfig/elasticsearch |grep "JAVA_HOME"

JAVA_HOME=/usr/java/jdk-11.0.6/


centos7需要修改systemd配置,否则启动会报错

/etc/systemd/system.conf

DefaultLimitNOFILE=65536

DefaultLimitNPROC=32000

DefaultLimitMEMLOCK=infinity


ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked

官网说明:

elasticsearch官网建议生产环境需要设置bootstrap.memory_lock: true

官网的解释 

是:发生系统swapping的时候ES节点的性能会非常差,也会影响节点的稳定性。所以要不惜一切代价来避免swapping。swapping会导致Java GC的周期延迟从毫秒级恶化到分钟,更严重的是会引起节点响应延迟甚至脱离集群。所以最好限制住elasticsearch占用的内存情况,可选少用swap

centos7需要修改systemd配置,centos6方式不一样


3、安装elasticsearch-head插件

elasticsearch 7.6是需要单独安装这个插件的,之前的老版本自带插件

安装依赖包

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2X gcc-c++ autoconf bzip2 -y

cd /usr/local/src/

使用git获取源码包

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


安装nodejs

curl -sL https://rpm.nodesource.com/setup_10.x | bash -

yum install -y nodejs

#node -v

v10.19.0

#npm -v

6.13.4


安装grunt客户端程序来控制head插件

npm install -g grunt --registry=https://registry.npm.taobao.org

npm install -g grunt-cli --registry=https://registry.npm.taobao.org

npm install grunt-contrib-clean --registry=https://registry.npm.taobao.org

npm install grunt-contrib-concat --registry=https://registry.npm.taobao.org

npm install grunt-contrib-watch --registry=https://registry.npm.taobao.org

npm install grunt-contrib-connect --registry=https://registry.npm.taobao.org

npm install grunt-contrib-copy --registry=https://registry.npm.taobao.org

npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org


修改Gruntfile.js配置文件,添加hostname字段

                connect: {

                        server: {

                                options: {

                                        port: 9100,

                                        hostname: "*",

                                        base: '.',

                                        keepalive: true

                                }

                        }

                }

修改/usr/local/elasticsearch-head/_site/app.js默认端口号把9200改为9100,此端口是head对外提供的http端口,把localhost改为本机对外访问的地址

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.0.31:9100";


注:前边的elasticsearch.yml配置文件一定要打开跨域访问配置文件(http.cors.enabled: true   http.cors.allow-origin: "*")


启动elasticsearch-head 

#cd /usr/local/elasticsearch-head

#nohup grunt server &


浏览器打开elasticsearch-head   

http://192.168.0.31:9100/


QQ图片20200324161813.png

猜你喜欢

转载自blog.51cto.com/wjlking/2481406
今日推荐