插件配置 功能,常用的 Elasticsearch 插件都带了,勾选下即可安装。也支持上传安装。vim ~/elasticsearch-5.6.8-docker.ymldocker-compose -f ~/elasticsearch-5.6.8-docker.yml -p elasticsearch_5.6.8 up -dversion: '3'
services:
elasticsearch1:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.8
container_name: elasticsearch-5.6.8
environment:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "cluster.name=elasticsearch"
- "network.host=0.0.0.0"
- "http.host=0.0.0.0"
- "xpack.security.enabled=false"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
ports:
- 9200:9200
- 9300:9300
volumes:
- /data/docker/elasticsearch/data:/usr/share/elasticsearch/data
vim ~/elasticsearch-6.7.2-docker.ymldocker-compose -f ~/elasticsearch-6.7.2-docker.yml -p elasticsearch_6.7.2 up -dmkdir -p /data/docker/elasticsearch-6.7.2/dataregistry.cn-hangzhou.aliyuncs.com/elasticsearch/elasticsearch:6.7.2version: '3'
services:
elasticsearch1:
image: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
container_name: elasticsearch-6.7.2
environment:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "cluster.name=elasticsearch"
- "network.host=0.0.0.0"
- "http.host=0.0.0.0"
- "xpack.security.enabled=false"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
ports:
- 9200:9200
- 9300:9300
volumes:
- /data/docker/elasticsearch-6.7.2/data:/usr/share/elasticsearch/data
- /data/docker/ik:/usr/share/elasticsearch/plugins/ik
http://localhost:9200/
_analyze?pretty POST
{"analyzer":"ik_smart","text":"安徽省长江流域"}
ik_max_word: 会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合,适合 Term Query;
ik_smart: 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”,适合 Phrase 查询。
systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动vim /etc/sysctl.conffs.file-max=65535
vm.max_map_count=262144
vim /etc/security/limits.confelasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
* soft nofile 262144
* hard nofile 262144
rpm -qa | grep elasticrpm -e --nodeps elasticsearchrpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearchvim /etc/yum.repos.d/elasticsearch.repo[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
yum install -y elasticsearch,预计文件有 108M 左右,国内网络安装可能会很慢,慢慢等
ln -s /usr/local/jdk1.8.0_181/jre/bin/java /usr/local/sbin/javasystemctl start elasticsearch.servicesystemctl status elasticsearch.servicesystemctl stop elasticsearch.servicesystemctl restart elasticsearch.service/bin/systemctl daemon-reload/bin/systemctl enable elasticsearch.servicecurl -X GET "localhost:9200/"/usr/share/elasticsearch/etc/sysconfig/elasticsearch/etc/elasticsearch/elasticsearch.yml/var/log/elasticsearch//var/lib/elasticsearch/usr/share/elasticsearch/plugins/etc/elasticsearch/scriptsvim /etc/elasticsearch/elasticsearch.yml打开这个注释:#cluster.name: my-application
集群名称最好是自己给定,不然有些 client 端会连不上,或者要求填写
打开这个注释:#network.host: 192.168.0.1
改为:network.host: 0.0.0.0
cd /usr/share/elasticsearch && bin/elasticsearch-plugin install x-packcurl -XPUT 'http://127.0.0.1:9200/grafanadb' -H 'Content-Type: application/json' -d'
{
"settings": {
"refresh_interval": "5s",
"number_of_shards": 5,
"number_of_replicas": 0
},
"mappings": {
"radar": {
"properties": {
"request_num": {
"type": "long"
},
"post_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
}
}
}
}
}
'
curl -X POST "http://127.0.0.1:9200/_bulk" -H 'Content-Type: application/json' -d'
{ "index" : { "_index" : "grafanadb", "_type" : "radar", "_id" : "100001" } }
{ "post_date" : "2018-12-01 10:00:00", "request_num" : 1 }
{ "index" : { "_index" : "grafanadb", "_type" : "radar", "_id" : "100002" } }
{ "post_date" : "2018-12-01 10:00:05", "request_num" : 2 }
{ "index" : { "_index" : "grafanadb", "_type" : "radar", "_id" : "100003" } }
{ "post_date" : "2018-12-01 10:00:10", "request_num" : 3 }
{ "index" : { "_index" : "grafanadb", "_type" : "radar", "_id" : "100004" } }
{ "post_date" : "2018-12-01 10:00:15", "request_num" : 4 }
{ "index" : { "_index" : "grafanadb", "_type" : "radar", "_id" : "100005" } }
{ "post_date" : "2018-12-01 10:00:20", "request_num" : 5 }
'
curl -X POST "http://127.0.0.1:9200/_bulk" -H 'Content-Type: application/json' -d'
{ "delete": { "_index": "grafanadb", "_type": "radar", "_id": "100001" } }
{ "delete": { "_index": "grafanadb", "_type": "radar", "_id": "100002" } }
'
curl -X POST "http://127.0.0.1:9200/索引名称/类型名称/_delete_by_query?refresh&slices=5&pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"match_all": {}
}
}
'
systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动/usr/program,解压包名:elasticsearch-5.2.0.zipcd /usr/program ; unzip elasticsearch-5.2.0.ziprm -rf elasticsearch-5.2.0.zipuseradd elasticsearch -p 123456,添加一个名为 elasticsearch 的用户,还有一个同名的组mkdir -p /opt/elasticsearch/data /opt/elasticsearch/logchown -R elasticsearch:elasticsearch /usr/program/elasticsearch-5.2.0 /opt/elasticsearchvim /usr/program/elasticsearch-5.2.0/config/elasticsearch.yml,打开下面注释,并修改cluster.name: youmeek-cluster
node.name: youmeek-node-1
path.data: /opt/elasticsearch/data
path.logs: /opt/elasticsearch/log
bootstrap.memory_lock: true
network.host: 0.0.0.0 # 也可以是本机 IP
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.1.127"] #如果有多个机子集群,这里就写上这些机子的 IP,格式:["192.168.1.127","192.168.1.126"]
vim /etc/security/limits.conf# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
* soft nofile 262144
* hard nofile 262144
vim /etc/sysctl.conf,添加下面配置vm.max_map_count=262144
reboot。su elasticsearchcd /usr/program/elasticsearch-5.2.0 ; ./bin/elasticsearchcd /usr/program/elasticsearch-5.2.0 ; ./bin/elasticsearch -d -p 自定义pid值curl -XGET 'http://192.168.1.127:9200',(也可以用浏览器访问:http://192.168.1.127:9200/)如果能得到如下结果,则表示启动成功:{
"name" : "youmeek-node-1",
"cluster_name" : "youmeek-cluster",
"cluster_uuid" : "c8RxQdOHQJq-Tg8rrPi_UA",
"version" : {
"number" : "5.2.0",
"build_hash" : "24e05b9",
"build_date" : "2017-01-24T19:52:35.800Z",
"build_snapshot" : false,
"lucene_version" : "6.4.0"
},
"tagline" : "You Know, for Search"
}
cd /usr/program ; tar zxvf kibana-5.2.0-linux-x86_64.tar.gzrm -rf kibana-5.2.0-linux-x86_64.tar.gzmv kibana-5.2.0-linux-x86_64 kibana-5.2.0vim /usr/program/kibana-5.2.0/config/kibana.yml,默认配置都是注释的,我们这里打开这些注释:server.port: 5601
server.host: "0.0.0.0" # 请将这里改为 0.0.0.0 或是当前本机 IP,不然可能会访问不了
erver.name: "youmeek-kibana"
elasticsearch.url: "http://192.168.1.127:9200"
elasticsearch.username: "elasticsearch"
elasticsearch.password: "123456"
cd /usr/program/kibana-5.2.0 ; ./bin/kibanaConfigure an index pattern 界面/usr/share/elasticsearch/bin/elasticsearch-plugin install x-packwget https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-5.2.2.zip/usr/share/elasticsearch/bin/elasticsearch-plugin install file:///opt/x-pack-5.2.2.zip/usr/share/elasticsearch/bin/elasticsearch-plugin remove x-packxpack.security.enabled: falsewget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.1.tar.gzwget https://download.elastic.co/logstash/logstash/logstash-2.4.1.tar.gzwget https://download.elastic.co/kibana/kibana/kibana-4.6.1-linux-x86_64.tar.gzmkdir -p /opt/elasticsearch/data /opt/elasticsearch/loguseradd elasticsearch -p 123456,添加一个名为 elasticsearch 的用户,还有一个同名的组cd /usr/program/elktar zxvf elasticsearch-2.4.1.tar.gzchown -R elasticsearch:elasticsearch /usr/program/elk /opt/elasticsearch/usr/program/elk/elasticsearch-2.4.1/usr/program/elk/elasticsearch-2.4.1/bin/usr/program/elk/elasticsearch-2.4.1/config/elasticsearch.yml/usr/program/elk/elasticsearch-2.4.1/plugins/usr/program/elk/elasticsearch-2.4.1/scripts/opt/elasticsearch/data/opt/elasticsearch/log/集群名称.logvim /usr/program/elk/elasticsearch-2.4.1/config/elasticsearch.yml,打开下面注释,并修改cluster.name: gitnavi-cluster
node.name: gitnavi-node-1
path.data: /opt/elasticsearch/data
path.logs: /opt/elasticsearch/log
bootstrap.memory_lock: true
network.host: 0.0.0.0 # 也可以是本机 IP
http.port: 9200
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.1.127", "192.168.1.126"] #这个为两台机子的 IP 地址
vim /etc/security/limits.conf# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
* soft nofile 262144
* hard nofile 262144
systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动su elasticsearch/usr/program/elk/elasticsearch-2.4.1/bin/elasticsearch
[2017-03-13 18:42:51,170][INFO ][node ] [gitnavi-node-1] version[2.4.1], pid[21156], build[c67dc32/2016-09-27T18:57:55Z]
[2017-03-13 18:42:51,177][INFO ][node ] [gitnavi-node-1] initializing ...
[2017-03-13 18:42:51,821][INFO ][plugins ] [gitnavi-node-1] modules [reindex, lang-expression, lang-groovy], plugins [head, kopf], sites [head, kopf]
[2017-03-13 18:42:51,852][INFO ][env ] [gitnavi-node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [12.4gb], net total_space [17.4gb], spins? [unknown], types [rootfs]
[2017-03-13 18:42:51,852][INFO ][env ] [gitnavi-node-1] heap size [1015.6mb], compressed ordinary object pointers [true]
[2017-03-13 18:42:54,094][INFO ][node ] [gitnavi-node-1] initialized
[2017-03-13 18:42:54,094][INFO ][node ] [gitnavi-node-1] starting ...
[2017-03-13 18:42:54,175][INFO ][transport ] [gitnavi-node-1] publish_address {192.168.1.127:9300}, bound_addresses {[::]:9300}
[2017-03-13 18:42:54,178][INFO ][discovery ] [gitnavi-node-1] gitnavi-cluster/-XywT60EScO-9lgzjfnsgg
[2017-03-13 18:42:57,344][INFO ][cluster.service ] [gitnavi-node-1] new_master {gitnavi-node-1}{-XywT60EScO-9lgzjfnsgg}{192.168.1.127}{192.168.1.127:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2017-03-13 18:42:57,410][INFO ][gateway ] [gitnavi-node-1] recovered [0] indices into cluster_state
[2017-03-13 18:42:57,414][INFO ][http ] [gitnavi-node-1] publish_address {192.168.1.127:9200}, bound_addresses {[::]:9200}
[2017-03-13 18:42:57,414][INFO ][node ] [gitnavi-node-1] started
/usr/program/elk/elasticsearch-2.4.1/bin/elasticsearch -dps -ef|grep elasticsearc,只能通过 kill pid 来结束http://192.168.1.127:9200/,可以看到如下内容:{
"name" : "gitnavi-node-1",
"cluster_name" : "gitnavi-cluster",
"cluster_uuid" : "0b66dYpnTd-hh7x4Phfm1A",
"version" : {
"number" : "2.4.1",
"build_hash" : "c67dc32e24162035d18d6fe1e952c4cbcbe79d16",
"build_timestamp" : "2016-09-27T18:57:55Z",
"build_snapshot" : false,
"lucene_version" : "5.5.2"
},
"tagline" : "You Know, for Search"
}
/usr/program/elk/elasticsearch-2.4.1/bin/plugin install mobz/elasticsearch-head
http://192.168.1.127:9200/_plugin/head/usr/program/elk/elasticsearch-2.4.1/bin/plugin install lmenezes/elasticsearch-kopf
http://192.168.1.127:9200/_plugin/kopf/usr/program/elk/elasticsearch-2.4.1/bin/plugin install hlstudio/bigdesk
http://192.168.1.127:9200/_plugin/bigdesk/usr/share/elasticsearch/bin/elasticsearch-plugin remove 插件名称cd /usr/program/elk/elasticsearch-2.4.1/pluginsmkdir ikunzip elasticsearch-analysis-ik-1.10.1.ziprm -rf elasticsearch-analysis-ik-1.10.1.zipvim /usr/program/elk/elasticsearch-2.4.1/config/elasticsearch.yml
index.analysis.analyzer.default.tokenizer : "ik_max_word"
index.analysis.analyzer.default.type: "ik"
[
{
"token": "这是",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 0
},
{
"token": "一个",
"start_offset": 2,
"end_offset": 4,
"type": "CN_WORD",
"position": 1
},
{
"token": "一",
"start_offset": 2,
"end_offset": 3,
"type": "TYPE_CNUM",
"position": 2
},
{
"token": "个",
"start_offset": 3,
"end_offset": 4,
"type": "COUNT",
"position": 3
},
{
"token": "针对",
"start_offset": 4,
"end_offset": 6,
"type": "CN_WORD",
"position": 4
},
{
"token": "程序员",
"start_offset": 6,
"end_offset": 9,
"type": "CN_WORD",
"position": 5
},
{
"token": "程序",
"start_offset": 6,
"end_offset": 8,
"type": "CN_WORD",
"position": 6
},
{
"token": "序",
"start_offset": 7,
"end_offset": 8,
"type": "CN_WORD",
"position": 7
},
{
"token": "员",
"start_offset": 8,
"end_offset": 9,
"type": "CN_CHAR",
"position": 8
},
{
"token": "优化",
"start_offset": 9,
"end_offset": 11,
"type": "CN_WORD",
"position": 9
},
{
"token": "导航",
"start_offset": 12,
"end_offset": 14,
"type": "CN_WORD",
"position": 10
},
{
"token": "航",
"start_offset": 13,
"end_offset": 14,
"type": "CN_WORD",
"position": 11
},
{
"token": "gitnavi.com",
"start_offset": 14,
"end_offset": 25,
"type": "LETTER",
"position": 12
},
{
"token": "gitnavi",
"start_offset": 14,
"end_offset": 21,
"type": "ENGLISH",
"position": 13
},
{
"token": "com",
"start_offset": 22,
"end_offset": 25,
"type": "ENGLISH",
"position": 14
}
]
/usr/program/elk/elasticsearch-2.4.1/config/elasticsearch.yml,直接解压 zip 后,直接可以启动使用。可以访问这个进行测试:http://192.168.1.127:9200/_analyze?analyzer=ik_max_word&pretty=true&text=这是一个针对程序员优化的导航GitNavi.com/usr/program/elk/elasticsearch-2.4.1/config/elasticsearch.yml