title | categories | tags | date |
---|---|---|---|
Centos6.7安裝ES6.1.3 | fortest | 數據開發 | 2019/08/18 19:21:21 |
the life i want,there is not shortcut.
0x00前知
1,該ES6.1.3需要適配的JDK版本爲1.8+
2,本文安裝前JDK環境已配置好,如無配置,請自行谷歌並配置好JDK環境
3,該ES6.1.3不能使用root用戶啓動,所以需要新建一個elasticsearch用戶執行ES所在目錄,本文使用elsearch
0x01開始安裝
1,解壓 tar -zxf esxxx -C /opt/app
2,chown -R elsearch:elsearch esxxx
3,修改配置文件 cd /esxxx/config vi elasticsearch.yml "[]"內爲提示內容,不是修改的內容,謹記
1,修改cluster.name: cluster.name: my-test-application
2,修改node.name: node-1
3,修改path.data: /data/elsearch6/data [記得創建此目錄,並且修改所屬用戶/組爲elsearch]
4,修改path.logs: /data/elsearch6/logs [記得創建此目錄,並且修改所屬用戶/組爲elsearch]
5,在Memory一欄添加bootstrap.system_call_filter: flase 並將bootstrap.memory_lock: false [ES5之後默認爲true,檢測失敗報錯]
6,修改network.host: 192.168.91.163[本機的ip]
7,末尾添加[head使用,如未有head或者不打算安裝head,可略過此處]
http.cors.enabled: true
http.cors.allow-origin: "*"
8,scp分發後修改各自的node和ip
0x02異常
1,max number of threads [2048] for user [elsearch] is too low, increase to at least [4096]
vi /etc/security/limits.d/90-nproc.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
如果無效,修改 vi /etc/security/limits.conf 修改elsearch的limit
elsearch hard nofile 131072
elsearch soft nproc 4096
elsearch soft nofile 65536
0x03安裝head
1,需要node,去node官網下載node,如果下載的是XZ格式的還需要安裝XZ格式的解壓器[yum install xz]
2,配置node的環境變量
3,安裝npm
npm install -g cnpm --registry=https://registry.npm.taobao.org
4,使用npm安裝grunt
npm install -g grunt
npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy
5,確認是否安裝成功
node -v
v10.16.0
6,下載head插件源碼
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
uzip msater.zip
7,依賴
進入上面解壓後的目錄,執行以下命令
npm install
如果網速過慢失敗--可以使用下面的
npm install -g cnpm --registry=https://registry.npm.taobao.org
8,結合ES
1,先停掉ES
2,修改es的配置文件[前面的那個]
添加--注意":"後面有一個空格
http.cors.enabled: true
http.cors.allow-origin: "*"
2,修改head中的文件 vi Gruntfile.js
找到connect:Server,添加hostname
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
hostname改爲'0.0.0.0'和'*'均可,看應用場景
9,啓動
先啓動ES
bin/elasticsearch -d
然後在head目錄下啓動
nohup npm run start &
10,訪問
打開http://192.168.91.163:9100/
0x04安裝IK
支持兩種形式的安裝
1,以plugin方式安裝
進入ES的bin路徑,執行以下命令:
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.1.3/elasticsearch-analysis-ik-6.1.3.zip
執行完畢,重啓ES,ik安裝完畢
2,手動安裝
:注意版本號要求一致
1,在 https://github.com/medcl/elasticsearch-analysis-ik/releases下載這個版本的IK和Es的版本對應關係一致,本文使用es 6.1.3,下載後
2,解壓到ES_HOME/plugins/ik 目錄下面(直接包含一個conf文件夾和一堆.jar包)
3,重新啓動ES
4,如果 看到try load config ....IK相關信息,說明啓動完成後和安裝IK插件完成。或者訪問http://spark01:9200/_cat/plugins 出現node-1 analysis-ik 6.1.3即爲完成安裝
3,驗證
curl -H "Content-Type: application/json" -XPOST "http://spark01:9200/_analyze?pretty=true" -d'{"text":"helloworld,我是一個粉刷匠"}'
{
"tokens" : [
{
"token" : "helloworld",
"start_offset" : 0,
"end_offset" : 10,
"type" : "<ALPHANUM>",
"position" : 0
},
{
"token" : "我",
"start_offset" : 11,
"end_offset" : 12,
"type" : "<IDEOGRAPHIC>",
"position" : 1
},
{
"token" : "是",
"start_offset" : 12,
"end_offset" : 13,
"type" : "<IDEOGRAPHIC>",
"position" : 2
},
{
"token" : "一",
"start_offset" : 13,
"end_offset" : 14,
"type" : "<IDEOGRAPHIC>",
"position" : 3
},
{
"token" : "個",
"start_offset" : 14,
"end_offset" : 15,
"type" : "<IDEOGRAPHIC>",
"position" : 4
},
{
"token" : "粉",
"start_offset" : 15,
"end_offset" : 16,
"type" : "<IDEOGRAPHIC>",
"position" : 5
},
{
"token" : "刷",
"start_offset" : 16,
"end_offset" : 17,
"type" : "<IDEOGRAPHIC>",
"position" : 6
},
{
"token" : "匠",
"start_offset" : 17,
"end_offset" : 18,
"type" : "<IDEOGRAPHIC>",
"position" : 7
}
]
}