Skip to content

Commit

Permalink
updates for 9/22/2019
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Sep 13, 2019
1 parent d3014a1 commit 1b1c878
Show file tree
Hide file tree
Showing 18 changed files with 9,076 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,25 @@
## 第 14 章:探索 X-Pack 套件
1. 用 Monitoring 和 Alerting 监控 Elasticsearch 集群
2. 用 APM 进行程序性能监控
3. 用机器学习实现时序数据的异常检测
4. 用 ELK 进行日志管理
5.Canvas 做数据演示
6.Graph 进行数据分析
7. 用 Timelion 分析时序型数据
3. 用机器学习实现时序数据的异常检测(上)
4. 用机器学习实现时序数据的异常检测(下)
5.ELK 进行日志管理
6.Canvas 做数据演示

## 第五部分:应用实战工作坊
### 实战 1:电影搜索服务
1. 项目需求分析及架构设计
2. 将音乐数据导入 Elasticsearch
3. 搭建你的电影搜索服务
3. 搭建你的电影搜索服务
4. 基于 Java 和 Elasticsearch 构建应用
### 实战 2:Stackoverflow 用户调查问卷分析
1. 需求分析及架构设计
2. 数据 Extract & Enrichment
3. 构建 Insights Dashboard
### 备战:Elastic 认证
1. Elastic 认证介绍
2. 考点梳理
3. 集群的数据备份

# ELK 相关下载资源
1. ELK 7.x 推荐官网直接下载,如网速低,可使用以下链接 - 百度网盘下载(https://pan.baidu.com/s/1CRT3W4wEESglCBDnslk2AA)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir server_metrics
cd server_metrics
wget https://download.elasticsearch.org/demos/machine_learning/gettingstarted/server_metrics.tar.gz
tar -xvf server_metrics.tar.gz
Binary file not shown.

Large diffs are not rendered by default.

2,737 changes: 2,737 additions & 0 deletions part-4/14.6-用Canvas做数据演示/elasticcoffee-data.bulk

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions part-5/备战Elastic认证/backup_restore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 集群Backup & Restore
## 课程demo
```
PUT /_snapshot/my_fs_backup
{
"type": "fs",
"settings": {
"location": "/Users/yiruan/geektime/mount/my_backup",
"compress": true
}
}
PUT /_snapshot/my_fs_backup/snapshot_5?wait_for_completion=true
DELETE /_snapshot/my_fs_backup/snapshot_2
GET /_snapshot/my_fs_backup/_all
GET /_snapshot/my_fs_backup/_current
POST /_snapshot/my_fs_backup/snapshot_1/_restore
{
"indices": "testxxx",
"index_settings": {
"index.number_of_replicas": 5
},
"ignore_index_settings": [
"index.refresh_interval"
]
}
GET testxxx/_settings
DELETE testxxx
GET testxxx
PUT /_snapshot/my_fs_backup/snapshot_3?wait_for_completion=true
{
"indices": "testxxx",
"ignore_unavailable": true,
"include_global_state": false,
"metadata": {
"taken_by": "yiming",
"taken_because": "backup before upgrading"
}
}
```
4 changes: 4 additions & 0 deletions part-5/实战1-电影搜索服务/java-es/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 用 Java 和 Elasticsearch 开发应用
# 课程demo
```
```
11 changes: 11 additions & 0 deletions part-5/实战1-电影搜索服务/movie-search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
课程demo
```
安装配置
app-search.yml:
allow_es_settings_modification: true
#Allow Elasticsearch to create indexes automatically: Add the following line #within either Elasticsearch cluster settings or elasticsearch.yml:
action.auto_create_index: ".app-search-*-logs-*,-.app-search-*,+*"
```
61 changes: 61 additions & 0 deletions part-5/实战1-电影搜索服务/movie-search/query_tmdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import requests
import json
import os
import sys

indexName ="tmdb"
queryFolder ="./query"
headers={"Content-Type":"application/json","Accept":"application/json"}

def search(query, printHighlight):
print query
url = "http://localhost:9200/%s/_search" %indexName
resp = requests.get(url,headers=headers,data=json.dumps(query))
hits = json.loads(resp.text)["hits"]
print "\r\n######################## Results ################################\r\n"
print "No\tScore\t\t\tTitle"
for idx, hit in enumerate(hits["hits"]):
print "%s\t%s\t\t\t%s" %(idx+1, hit["_score"], hit["_source"]["title"])
print "---------------------------------------------------------------"
if printHighlight:
if (("highlight" in hit.keys()) and ("title" in hit["highlight"].keys())):
hl = ";".join(hit["highlight"]["title"]).replace("<em>","\033[1;31;40m").replace("</em>","\033[0m")
print "title: \033[0;32;40m%d hit(s)\033[0m \r\n%s\r\n--" %(len(hit["highlight"]["title"]) ,hl)
if (("highlight" in hit) and ("overview" in hit["highlight"])):
hl = ";".join(hit["highlight"]["overview"]).replace("<em>","\033[1;31;40m").replace("</em>","\033[0m")
print "overview: \033[0;32;40m%d hit(s)\033[0m \r\n%s\r\n--" %( len(hit["highlight"]["overview"]), hl)


def select_query():
print "\r\n>> Please select the query file.\r\n"
queryList=os.listdir(queryFolder)
for idx, queryItem in enumerate(queryList):
print "[%d] %s" %(idx,queryItem)
userInput = raw_input()
try:
selectIndex = int(userInput)
except ValueError:
selectIndex =-1
if(selectIndex==-1 or selectIndex > len(queryList)):
print '\033[31mPlease provide a valid integer \033[0m'
msg = "from 0 to %d." %(len(queryList))
print msg
exit()
queryName = queryList[selectIndex]
fileName="%s/%s" %(queryFolder,queryName)
f = open(fileName)
query = {}
if f:
query = json.loads(f.read());
return query

def main():
highlight = False
for arg in sys.argv:
if arg == "h" or arg == "hl" or arg == "highlight":
highlight = True
query = select_query()
search(query, highlight)

if __name__== "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests==2.20.0
File renamed without changes.

0 comments on commit 1b1c878

Please sign in to comment.