一、 安装ElasticSearch
1、安装jdk
下载安装包jdk-8u261-linux-x64.tar.gz:
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
# cd /app
# tar xf jdk-8u261-linux-x64.tar.gz
# vim /etc/profile
添加:
#set java environment
export JAVA_HOME=/app/jdk1.8.0_261
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
# source /etc/profile
测试:
# java -version
2、创建ES用户
# useradd es -p es
3、配置运行ES需要的系统环境变量
# vim /etc/security/limits.conf
添加:
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
# vim /etc/sysctl.conf
添加:
vm.max_map_count=262144
# sysctl -p
4、安装elasticsearch
# cd /app
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
# tar xf elasticsearch-6.2.4.tar.gz
# chown -R es.es /app/elasticsearch-6.2.4
# su - es
$ /app/elasticsearch-6.2.4/bin//elasticsearch -d
测试:
$ curl 127.0.0.1:9200
如果要实现远程访问:
修改配置文件elasticsearch.yml的配置项network.host,然后重启elasticsearch:
例:
$ vim /app/elasticsearch-6.2.4/config/elasticsearch.yml
network.host: 192.168.125.135
测试:
二、安装ElasticSearch-head插件
1、安装nodejs
# cd /app
# wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.gz
# tar xf node-v10.9.0-linux-x64.tar.gz
# mv node-v10.9.0-linux-x64 nodejs
# ln -s /app/nodejs/bin/node /usr/bin/node
# ln -s /app/nodejs/bin/npm /usr/bin/npm
2、安装git
# yum -y install git
3、安装ElasticSearch-head
# git clone https://github.com/mobz/elasticsearch-head.git
# npm install -g grunt-cli
# cd elasticsearch-head
# npm install -g cnpm --registry=https://registry.npm.taobao.org #因为npm安装非常非常慢,所以在这里先安装淘宝源地址
# ln -s /app/nodejs/lib/node_modules/cnpm/bin/cnpm /usr/bin/cnpm #创建cnpm软链接,不然执行下面执行命令会报错
# cnpm install #使用cnpm命令下载安装项目所需要的插件
# vim _site/app.js #修改app.js 搜索localhost,将localhost修改为安装ElasticSearch服务器的ip
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.125.135:9200";
# vim Gruntfile.js #Gruntfile.js,在connect.server.options中添加host: '*',
connect: {
server: {
options: {
host: '*',
port: 9100,
base: '.',
keepalive: true
}
}
}
# su - es
在elasticsearch.yml末尾添加以下两行:
$ http.cors.enabled: true
$ http.cors.allow-origin: '*'
4、重启ElasticSearch及启动ElasticSearch-head
# su - es
$ /app/elasticsearch-6.2.4/bin/elasticsearch -d
$ exit
# cd /app/elasticsearch-head/node_modules/grunt/bin/ #进入启动目录
# nohup ./grunt server & #使用nohup启动 日志会输出在当前文件夹nohup.out里面,启动端口默认为9100
三、安装kibana
# wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.4-linux-x86_64.tar.gz
# tar xf kibana-6.2.4-linux-x86_64.tar.gz
# cd kibana-6.2.4-linux-x86_64
# vim /app/kibana-6.2.4-linux-x86_64/config/kibana.yml
修改以下配置项:
server.host: "192.168.125.135"
elasticsearch.url: "http://192.168.125.135:9200"
# nohup /app/kibana-6.2.4-linux-x86_64/bin/kibana &
测试:
三、安装ik中文分词器
下载对应的版本:
# wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip
移动至es目录下的plugins:
# mv /usr/local/src/elasticsearch-analysis-ik-6.2.4.zip /app/elasticsearch-6.2.4/plugins/
解压,并重启:
# cd /app/elasticsearch-6.2.4/plugins/
# unzip elasticsearch-analysis-ik-6.2.4.zip
# rm elasticsearch-analysis-ik-6.2.4.zip
重启日志中出现以下信息时,说明安装成功:
[INFO ][o.e.p.PluginsService ] [xkp7gTe] loaded plugin [analysis-ik]