elasticsearch-6.0.1安裝java
1
2
|
tar -zxvf elasticsearch-6.0.1.tar.gz
mv elasticsearch-6.0.1.tar.gz /usr/local/elasticsearch
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
cluster.name: cluster-es
node.name: es-node1
path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs
network.host: 172.16.64.137
http.port: 9200
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: ["172.16.64.137", "172.16.64.138", "172.16.64.147"]
node.master: true
node.data: false
discovery.zen.fd.ping_timeout: 180s
discovery.zen.fd.ping_retries: 10
discovery.zen.fd.ping_interval: 30s
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
cluster.name: cluster-es
# 集羣名稱
node.name: es-node1
# 節點名稱,其他兩臺爲es-node二、es-node3
path.data: /usr/local/elasticsearch/data
# 數據目錄
path.logs: /usr/local/elasticsearch/logs
# 日誌目錄
network.host: 172.16.64.137
# 本機IP
http.port: 9200
# 本機http端口
discovery.zen.minimum_master_nodes: 1
# 指定集羣中的節點中有幾個有master資格的節點
discovery.zen.ping.unicast.hosts: ["172.16.64.137", "172.16.64.138", "172.16.64.147"]
# 指定集羣中其餘節點的IP
node.master: true
# 是否爲master
node.data: false
# 是否爲數據節點
discovery.zen.fd.ping_timeout: 180s
# 設置集羣中自動發現其它節點時ping鏈接超時時間
discovery.zen.fd.ping_retries: 10
# 集羣中節點之間ping的次數
discovery.zen.fd.ping_interval: 30s
# 集羣中節點之間ping的時間間隔
|
1
2
3
|
vim /usr/local/elasticsearch/config/jvm.options
-Xms2g
-Xmx2g
|
1
2
3
4
5
6
7
8
9
|
# 建立用戶
useradd ela
# 賦予ela用戶全部者權限
chown -R ela:ela /usr/local/elasticsearch
su - ela
[ela@test1 ~]$/usr/local/elasticsearch/bin/elasticsearch -d # -d參數是後臺運行
# 建議按如下命令啓動
[ela@test1 ~]$ nohup /usr/local/elasticsearch/bin/elasticsearch &
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
{
"name" : "dcV-DRJ",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "N6qGE15TQqq9-RQedQqqEw",
"version" : {
"number" : "6.1.1",
"build_hash" : "bd92e7f",
"build_date" : "2017-12-17T20:23:25.338Z",
"build_snapshot" : false,
"lucene_version" : "7.1.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
|
1
2
3
4
5
6
7
|
vi /etc/security/limits.conf
#添加以下內容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
|
1
2
3
4
5
|
vim /etc/sysctl.conf 添加一行
vm.max_map_count=655360
# 執行命令:
sysctl -p
|
1
2
3
4
5
|
tar node-v8.9.3.tar.gz
cd node-v8.9.3
./configure --prefix=/usr/local/node/
make # make時間較長
make install
|
1
2
3
4
5
6
|
vim /etc/profile
export NODEJS_HOME=/usr/local/node/
export PATH=$PATH:$NODEJS_HOME/bin
# 使變量生效
source /etc/profile
|
1
2
|
[root@test1 bin]# node -v
v8.9.3
|
1
2
|
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
|
1
|
npm install
|
1
2
3
4
5
|
#安裝國內鏡像
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 安裝插件(在elasticsearch-head目錄下)
cnpm install
|
1
2
3
4
5
6
7
8
9
10
11
|
vi Gruntfile.js
connect: {
server: {
options: {
hostname: "0.0.0.0", #新增的一行
port: 9100,
base: '.',
keepalive: true
}
}
}
|
1
2
3
4
|
# 搜索
http://localhost:9200
# 修改成本機IP
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.1.138:9200";
|
1
2
3
4
5
6
7
|
# 在配置文件的最後加上運行head插件跨域訪問rest接口
vim /usr/local/elasticsearch/config/elasticsearch.yml
# 添加以下內容:
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true
|
1
|
npm run start &
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@test1 elasticsearch-head]# npm run start
> elasticsearch-head@0.0.0 start /usr/local/elasticsearch-head
> grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
(node:16304) ExperimentalWarning: The http2 module is an experimental API.
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
|
最簡單的方法就是使用nohup。先按Ctrl + C,中止當前運行的Elasticsearch,改用下面的命令運行Elasticsearchnode
1
|
nohup ./bin/elasticsearch &
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/sh
#chkconfig: 2345 80 05
#description: es
export JAVA_HOME=/usr/local/jdk1.8.0_151
export JAVA_BIN=/usr/local/jdk1.8.0_151/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
case $1 in
start)
su ela<<!
cd /usr/local/elasticsearch
./bin/elasticsearch -d
exit
!
echo "es startup"
;;
stop)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "es stopup"
;;
restart)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "es stopup"
su ela<<!
cd /usr/local/elasticsearch
./bin/elasticsearch -d
!
echo "es startup"
;;
*)
echo "start|stop|restart"
;;
esac
|