elastic安装过程-Ubuntu
elastic安装过程-Ubuntu
直接下载jdk压缩包方式安装(这里只介绍jdk7的,jdk8 的原理完全一致)
分为下面5个步骤
官网下载JDK
地址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html , 选择相应的 .gz包下载
解压缩,放到指定目录(以jdk-7u60-linux-x64.gz为例)
创建目录:
sudo mkdir /usr/lib/jvm
解压缩到该目录:
sudo tar -zxvf jdk-7u60-linux-x64.gz -C /usr/lib/jvm
修改环境变量
sudo vim ~/.bashrc
文件的末尾追加下面内容:
1
2
3
4
5#set oracle jdk environment
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_60 ## 这里要注意目录要换成自己解压的jdk 目录
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH使环境变量马上生效
source ~/.bashrc
设置系统默认jdk 版本
1 | sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_60/bin/java 300 |
然后执行:sudo update-alternatives --config java
若是初次安装jdk,会有下面的提示
1 | There is only one alternative in link group java (providing /usr/bin/java): |
否则,选择合适的jdk
测试jdk
1 | java -version |
jdk 安装成功
下载elasticsearch
1 | wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz |
启动elasticsearch
1 | # Running Elasticsearch from the command line |
安装错误
max file descriptors [4096] for elasticsearch process is too low
解决办法:
1
2
3
4
5sudo vim /etc/security/limits.conf
# 在最后面追加下面内容
*** - nofile 65536
*** 是启动ES的用户Ubuntu ignores the limits.conf file for processes started by init.d. To enable the limits.conf file, edit /etc/pam.d/su and uncomment the following line:
#session required pam_limits.so
max virtual memory areas vm.max_count [65530] likely too low,increase to at least [26244]
解决办法
sudo sysctl -w vm.max_map_count=262144
默认情况下,Elastic 只允许本机访问,如果需要远程访问,可以修改 Elastic 安装目录的config/elasticsearch.yml文件,去掉network.host的注释,将它的值改成0.0.0.0,然后重新启动 Elastic。
安装中文分词器
执行命令
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip
配置IK[仅供v5.0以下版本使用]
执行以下CURL
1
2
3
4
5
6
7
8
9
10
11
12curl -XPOST 'http://localhost:9200/_all/_close'
curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
"index.analysis.analyzer.default.type" : "ik_max_word",
"index.analysis.analyzer.ik.alias" : [
"ik_analyzer"
],
"index.analysis.analyzer.ik.type" : "org.elasticsearch.index.analysis.IkAnalyzerProvider",
"index.analysis.analyzer.ik_max_word.type" : "ik_max_word",
"index.analysis.analyzer.ik_max_word.use_smart" : "false",
"index.analysis.analyzer.ik_smart.type" : "ik_max_word",
"index.analysis.analyzer.ik_smart.use_smart" : "true"
}'