elasticsearch安装head插件

当我们安装elasticsearch时,需要注意一下问题

  1. 优化配置
    以下是如何通过jvm.options文件设置堆大小的示例:
-Xms2g 
-Xmx2g

将最小堆大小(Xms)和最大堆大小(Xmx)设置为彼此相等
设置Xmx为不超过物理RAM的50%,以确保有足够的物理RAM用于内核文件系统缓存 但是不能超过32g,超过32g java指针将不是压缩的,反而会慢
锁住swap,这会影响es性能(或者修改elasticsearch.yml 添加配置bootstrap.memory.lock)

  1. 当开启 bootstrap.memory.lock: TURE
    启动报错:
memory locking requested for elasticsearch process but memory is not locked

之后重启,还是报上面的错误。以为没配好,之后又改了n次。还是不行。
然后查资料,果然,配置文件不一样了。。
limits.conf这里的配置,只适用于通过PAM认证登录用户的资源限制,它对systemd的service的资源限制不生效。登录用户的限制,通过 /etc/security/limits.conf 来配置
对于systemd service的资源限制,现在放在 /etc/systemd/system.conf 和 /etc/systemd/user.conf
这两个文件里面了。
主要就是/etc/systemd/system.conf这个文件

然后修改下面几项:

DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity

注意把注释行去掉

安装elasticsearch5.0

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.tar.gz
tar xf elasticsearch-5.0.0.tar.gz
mv elasticsearch-5.0.0 /usr/local/elasticsearch
mkdir -pv /data/elasticsearch/{data,logs}
useradd elasticsearch
chown -R elasticsearch.elasticsearch /data/elasticsearch
chown -R elasticsearch.elasticsearch /usr/local/elasticsearch/

修改配置文件

cat /usr/local/elasticsearch/config/elasticsearch.yml |grep -v "^#" |grep -v "^$"
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"

修改系统参数

cat /etc/security/limits.conf |grep -v "^#" |grep -v "^$"
*              soft    nproc          65536
*              hard    nproc          65536
*              soft    nofile          65536
*              hard    nofile          65536

启动es

su - elasticsearch -c "/usr/local/elasticsearch/bin/elasticsearch &"

安装elasticsearch-head插件

下载

wget https://github.com/mobz/elasticsearch-head/archive/master.zip

安装node环境

wget https://nodejs.org/dist/v10.15.0/node-v10.15.0-linux-x64.tar.xz
mv node-v10.15.0-linux-x64 /usr/local/node

添加node环境变量

vim /etc/profile

添加:

export NODE_HOME=/usr/local/node
export PATH=$PATH:$NODE_HOME/bin
source /etc/profile
[root@elas src]# node -v
v10.15.0

[root@elas src]# npm -v
6.4.1

安装grunt(grunt是基于Node.js的项目构建工具,可以进行打包压缩、测试、执行等等工作,elasticsearch-head插件就是通过grunt启动的)

[root@elas src]# cd elasticsearch-head-master/
[root@elas elasticsearch-head-master]# npm install -g grunt-cli
/usr/local/node/bin/grunt -> /usr/local/node/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli@1.3.2
added 152 packages from 122 contributors in 22.183s

[root@elas elasticsearch-head-master]# grunt -version
grunt-cli v1.3.2

修改elasticsearch-head-master下Gruntfile.js配置文件,添加hostname: '*',
                connect: {
                        server: {
                                options: {
                                        hostname: '*',
                                        port: 9100,
                                        base: '.',
                                        keepalive: true
                                }

安装cnpm

[root@elas elasticsearch-head-master]# npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
/usr/local/node/bin/cnpm -> /usr/local/node/lib/node_modules/cnpm/bin/cnpm
+ cnpm@6.0.0
added 679 packages from 898 contributors in 16.873s

继续执行

yum install bzip2 -y
cnpm install

修改 elasticsearch.yml

添加以下几行

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

重启elasticsearch

安装完成后没有报错的话启动elasticsearch-head-master

grunt server &

当执行 cnpm install时候报错解决:

Get /binary-mirror-config/latest from https://registry.npm.taobao.org error: ConnectionTimeoutError: Connect timeout for 5000ms, GET https://registry.npmjs.com/binary-mirror-config/latest -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":4,"createSocketErrorCount":0,"closeSocketCount":4,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{},"requests":{}}, socketHandledRequests: 1, socketHandledResponses: 0)……

然后找到报错根源:
/nodejs/lib/node_modules/cnpm/node_modules/urllib/lib/urllib.js
修改掉文件里面的常量 TIMEOUT、TIMEOUTS 的 5s 为 10s

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值