您的位置:首页 > 其它

elasticsearch系列-elasticsearch及插件安装

2017-12-18 15:16 435 查看
elasticsearch及插件安装
一、elasticsearch安装(所有节点)
1、下载
下载地址:https://www.elastic.co/cn/downloads/elasticsearch
下载后放在 /opt 目录下

2、解压
cd /opt
tar -zxvf elasticsearch-5.4.1.tar.gz
mv elasticsearch-5.4.1 elasticsearch

3、修改配置
vim /opt/elasticsearch/config/elasticsearch.yml

cluster.name: es-cluster
node.name: elastic-master26
path.data: /data/es/datafile
path.logs: /data/es/logs
bootstrap.memory_lock: true
network.host: 10.4.4.26
http.port: 9200
discovery.zen.ping.unicast.hosts: ["elastic-master26","elastic-node27","elastic-node28","elastic-node29","elastic-node30"]
discovery.zen.minimum_master_nodes: 3
gateway.recover_after_nodes: 3

4、添加elasticsearch-head配置和优化配置
#elasticsearch-head 配置
http.cors.enabled: true
http.cors.allow-origin: "*"

#开启Script查询功能
script.engine.groovy.inline.aggs: on
script.engine.groovy.inline.search: on

#内存优化
indices.fielddata.cache.size: 5gb

jvm内存优化
vim /opt/elasticsearch/config/jvm.options

-Xms16g
-Xmx16g

5、切换用户
elasticsearch不允许以root用户来启动

注意:因为elasticsearch有远程执行脚本的功能所以容易中木马病毒,所以不允许用root用户启动,root用户是起不来的,赋权限,用一般的用户启动

添加es用户
useradd -d /usr/elastic -m elastic
passwd elastic

root用户下
chown -R elastic:elastic /opt/elasticsearch

6、启动服务
su elastic
cd /opt/elasticsearch
./bin/elasticsearch 1>/log/elastic 2>&1 &

7、修改系统配置(没异常可以忽略)
下面为启动elasticsearch常见的两个问题
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

vim /etc/security/limit.conf
es soft nofile 70000
es hard nofile 100000 #大于65530

vim /etc/sysctl.conf
fs.file-max = 110000 #这个数值应大于hard limit
vm.max_map_count=300000 #这个值要大于262144

8、防脑裂配置(可以忽略)
#不主动广播
discovery.zen.ping.multicast.enabled: false
#延长集群中机子启动通讯的时间
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
#集群的机子
discovery.zen.ping.unicast.hosts: ["192.168.57.4","192.168.57.5", "192.168.57.6"]

二、elasticsearch-head安装(单节点)
1、安装nodejs
下载:
下载地址为 http://nodejs.cn/download/ 下载好了放在 /opt目录下

解压:
cd /opt
xz -d node-v8.9.3-linux-x64.tar.xz
tar -xvf node-v8.9.3-linux-x64.tar
mv node-v8.9.3-linux-x64 nodejs
rm -rf node-v8.9.3-linux-x64.tar

安装:
添加环境变量
vim /etc/profile

在文件末添加下面代码,然后保存退出
export PATH=/opt/nodejs/bin:$PATH

使环境变量生效
source /etc/profile

查看nodejs是否安装完成,能显示版本号则表示成功
node -v

2、安装phantomjs
下载:
下载地址为 https://npm.taobao.org/dist/phantomjs/ 下载好了放在 /opt目录下

解压:
cd /opt
tar -jvxf phantomjs-2.1.1-linux-x86_64.tar.bz2
mv phantomjs-2.1.1-linux-x86_64 phantomjs

安装:
添加环境变量
source /etc/profile

在文件末添加下面代码,然后保存退出
export PATH=/opt/phantomjs/bin:$PATH

使环境变量生效
source /etc/profile

查看phantomjs是否安装完成,能显示版本号则表示成功
phantomjs -v

3、安装elasticsearch-head
安装 grunt-cli
npm install -g grunt-cli --registry=https://registry.npm.taobao.org
查看是否安装成功,能显示版本号则表示成功
grunt -version

下载:
下载地址为https://github.com/mobz/elasticsearch-head
下载好了放在 /opt目录下

解压:
yum install zip unzip -y
cd /opt
unzip elasticsearch-head-master.zip
mv elasticsearch-head-master elasticsearch-head
cd elasticsearch-head
npm install
这里会报错,可以忽略

4、启动
启动命令:
cd /opt/elasticsearch-head
grunt server 1>/log/elastic-head 2>&1 &

然后访问 http://host:9100,然后在界面上连接es的urlhttp://host:9200/
三、Kibana安装(单节点)
1、下载
下载地址为 https://www.elastic.co/cn/downloads/kibana 下载后放到 /opt 目录下
注意:版本要和elasticsearch的版本对应

2、解压
cd /opt
tar -zxvf kibana-5.4.1-linux-x86_64.tar.gz
mv kibana-5.4.1-linux-x86_64 kibana

3、修改配置
vim /etc/kibana/config/kibana.yml

server.port: 5601
server.host: "elastic-master26"
elasticsearch.url: "http://elastic-master26:9200"

4、启动
cd /opt/kibana
./bin/kibana 1>/log/elastic-head 2>&1 &

访问地址:
http://elastic-master26:5601

5、停止
fuser -n tcp 5601
kill -9

四、x-pack安装
1、elasticsearch安装x-pack(所有节点)
cd /opt/elasticsearch
bin/elasticsearch-plugin install x-pack

2、kibana安装x-pack(单节点)
cd /opt/kibana
bin/kibana-plugin install x-pack

3、配置
cd /opt/kibana
vim config/kibana.yml
添加以下内容
xpack.security.enabled: false

cd /opt/kibana
vim config/elasticsearch.yml
添加以下内容
xpack.security.enabled: false

4、重启es和kibana

五、ik分词安装
下载地址:
https://github.com/medcl/elasticsearch-analysis-ik

下载对应版本的ik分词器
copy and unzip target/releases/elasticsearch-analysis-ik-{version}.zip to your-es-root/plugins/ik
解压放到es-root/plugins/ik目录下即可,创建type时指定ik分词器
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: