Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
deploy_es_synonym
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpha
deploy_es_synonym
Commits
c95f8678
Commit
c95f8678
authored
Apr 02, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parents
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
0 deletions
+128
-0
disable_cluster_routing_allocation.sh
disable_cluster_routing_allocation.sh
+8
-0
enable_cluster_routing_allocation.sh
enable_cluster_routing_allocation.sh
+8
-0
update_synonyms.sh
update_synonyms.sh
+112
-0
No files found.
disable_cluster_routing_allocation.sh
0 → 100755
View file @
c95f8678
#!/bin/bash
curl
-v
$(
hostname
)
:9200/_cluster/settings
-XPUT
-d
'{
"transient" : {
"cluster.routing.allocation.enable" : "none"
}
}'
echo
enable_cluster_routing_allocation.sh
0 → 100755
View file @
c95f8678
#!/bin/bash
curl
-v
$(
hostname
)
:9200/_cluster/settings
-XPUT
-d
'{
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}'
echo
update_synonyms.sh
0 → 100755
View file @
c95f8678
#!/bin/bash
set
-e
set
-x
ENV
=
$1
if
[[
"
$ENV
"
==
"dev"
||
"
$ENV
"
==
"test"
]]
;
then
MYSQL_USER
=
"work"
MYSQL_PASSWORD
=
"Gengmei123"
MYSQL_HOST
=
"rm-2zeaut61u9sm21m0b.mysql.rds.aliyuncs.com"
MYSQL_DB
=
"alpha"
DINGDING
=
'https://oapi.dingtalk.com/robot/send?access_token=47c7de55db1234c6ee0d8f61abae8bc54591f3cef438a41905a0bf4fa33dd6cf'
else
MYSQL_USER
=
"work"
MYSQL_PASSWORD
=
"oars152!traipseize738"
MYSQL_HOST
=
"172.17.40.144"
MYSQL_DB
=
"alpha"
DINGDING
=
'https://oapi.dingtalk.com/robot/send?access_token=53686301db86625c308a837fd6d26f56629fc69e693d21b0b12499ab54e74805'
fi
function
red
()
{
RED
=
'\033[0;31m'
NC
=
'\033[0m'
# No Color
printf
"
${
RED
}
$1
${
NC
}
\n
"
}
function
ding
()
{
# hostname action
curl
$DINGDING
\
-H
'Content-Type: application/json'
\
-d
"{
'msgtype': 'markdown',
'markdown': {
'title': 'ES同义词全量更新提醒',
'text':
\"
## ES同义词全量更新提醒
\n
> **
$1
$2
** > @ **
`
date
`
**
\"
},
'atMobiles': ['13913000267'],
'isAtAll': false
}"
}
ding
`
hostname
`
"start to upgrade synonym"
# up to date
su
-c
'git pull'
gmuser
CUR
=
`
pwd
`
FILE
=
"from_db.txt"
DICFILE
=
"from_db.dic"
if
[[
-e
$FILE
]]
;
then
rm
$FILE
fi
if
[[
-e
$DICFILE
]]
;
then
rm
$DICFILE
fi
echo
"getting synonym from db..."
linestoskip
=
1
Counter
=
0
SQL
=
"SELECT name,alias FROM community_tag where is_deleted=0 and is_online=1 and alias!='' and name!=''"
mysql
-h
$MYSQL_HOST
-u
$MYSQL_USER
-p
$MYSQL_PASSWORD
$MYSQL_DB
-e
"
$SQL
"
|
while
read
name
alias
do
if
[[
$Counter
-ge
$linestoskip
]]
;
then
echo
"
$name
"",""
$alias
"
>>
$FILE
echo
"
$name
"
>>
$DICFILE
echo
"
$alias
"
>>
$DICFILE
fi
Counter
=
`
expr
$Counter
+ 1
`
done
cat
$FILE
>
./synonym.txt
cp
./synonym.txt /srv/apps/elasticsearch/config/analysis/
cat
$DICFILE
>
./synonym.dic
cp
./synonym.dic /srv/apps/elasticsearch/plugins/analysis-ik/config/ik/custom/
# update es
echo
"update self
`
hostname
`
"
./disable_cluster_routing_allocation.sh
supervisorctl restart elasticsearch
until
nc
-z
$(
hostname
)
9200
;
do
echo
"elasticsearch is starting"
sleep
2
done
./enable_cluster_routing_allocation.sh
until
curl
-v
"
$(
hostname
)
:9200/_cluster/health?wait_for_status=green&timeout=10s"
|
grep
'green'
;
do
echo
"waiting for elastic cluster status to green"
sleep
2
done
echo
"done"
# clean up
git checkout
.
git clean
-f
-d
ding
`
hostname
`
"upgrade synonym successfully!"
exit
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment