-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathAnalyticDB-and-Bailian-system.yml
More file actions
425 lines (415 loc) · 11.4 KB
/
AnalyticDB-and-Bailian-system.yml
File metadata and controls
425 lines (415 loc) · 11.4 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: Build an intelligent question-and-answer system using AnalyticDB and Bailian.
zh-cn: AnalyticDB与百炼搭建智能问答系统。
Parameters:
ZoneId:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
AutoSelectFirst: true
Label:
en: Availability Zone
zh-cn: 可用区
DASHSCOPE_API_KEY:
NoEcho: true
Type: String
AssociationProperty: ALIYUN::Bailian::ApiKey::ApiKeyInfo
AssociationPropertyMetadata:
OnlyKey: true
Label:
en: Bailian application API-KEY
zh-cn: 百炼应用的API-KEY
APP_ID:
Type: String
Label:
en: Application ID of Bailian application
zh-cn: 百炼应用的应用ID
InstanceType:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: Instance Type
zh-cn: 实例规格
InstancePassword:
NoEcho: true
Type: String
Description:
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
zh-cn: >-
服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符号)
Label:
en: ECS Instance Password
zh-cn: ECS实例密码
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号)'
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
CommonName:
Type: String
Default: RAG
Resources:
Vpc:
Type: 'ALIYUN::ECS::VPC'
Properties:
CidrBlock: 192.168.0.0/16
VpcName:
Fn::Sub: vpc_${CommonName}
VSwitch:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.0.0/24
ZoneId:
Ref: ZoneId
VSwitchName:
Fn::Sub: vsw_${CommonName}
SecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Sub: ${CommonName}-sg
SecurityGroupIngress:
- PortRange: 5000/5000
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
EcsInstance:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_x64_20G_alibase_
InstanceName:
Fn::Sub: ${CommonName}-ecs_adb
InstanceType:
Ref: InstanceType
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 100
Password:
Ref: InstancePassword
AnalyticDB:
Type: ALIYUN::GPDB::DBInstance
Properties:
EngineVersion: '6.0'
InstanceSpec: 4C16G
ZoneId:
Ref: ZoneId
VSwitchId:
Ref: VSwitch
SegNodeNum: 2
SegStorageType: cloud_essd
SegDiskPerformanceLevel: pl1
StorageSize: 50
VPCId:
Ref: Vpc
SecurityIPList: 192.168.0.0/24
DBInstanceDescription:
Fn::Sub: ${CommonName}-adb
PayType: Postpaid
DBInstanceCategory: Basic
DBInstanceMode: StorageElastic
VectorConfigurationStatus: true
WaitConditionHandle:
Type: 'ALIYUN::ROS::WaitConditionHandle'
Properties: { }
RosWaitCondition:
Type: 'ALIYUN::ROS::WaitCondition'
Properties:
Count: 1
Handle:
Ref: WaitConditionHandle
Timeout: 7200
RunCommand:
Type: 'ALIYUN::ECS::RunCommand'
Properties:
InstanceIds:
Fn::GetAtt:
- EcsInstance
- InstanceIds
Type: RunShellScript
Sync: true
Timeout: 7200
CommandContent:
'Fn::Sub':
- >-
#!/bin/bash
if [ ! -f .ros.provision ]; then
echo "Name: 手动搭建AnalyticDB与百炼搭建智能问答系统" > .ros.provision
fi
name=$(grep "^Name:" .ros.provision | awk -F':' '{print $2}' | sed
-e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ "$name" != "手动搭建AnalyticDB与百炼搭建智能问答系统" ]]; then
echo "当前实例已使用过\"$name\"教程的一键配置,不能再使用本教程的一键配置"
${WaitConditionHandle.CurlCli} --data-binary "{\"status\": \"FAILURE\", \"reason\": \"The current instance has already applied the configuration of the \\\"$name\\\" tutorial, and the configuration of this tutorial can no longer be applied.\"}"
exit 0
fi
if ! grep -q "^Step1: Prepare Environment$" .ros.provision; then
echo "#########################"
echo "# Prepare Environment "
echo "#########################"
# 安装Python-3.9.7,建议Python版本为3.9及以上。
sudo yum update -y && \
sudo yum groupinstall "Development Tools" -y && \
sudo yum install openssl-devel bzip2-devel libffi-devel -y
cd /usr/src && \
sudo curl -O https://help-static-aliyun-doc.aliyuncs.com/software/Python-3.9.0.tgz && \
sudo tar xzf Python-3.9.0.tgz && \
cd Python-3.9.0 && \
sudo ./configure --enable-optimizations && \
sudo make altinstall
python3.9 --version && \
python3.9 -m ensurepip && \
python3.9 -m pip install --upgrade pip
echo 'export SOCKET_ENDPOINT="${ECS_NETWORK_IP}:5000"' >> ~/.bashrc
echo 'export APP_ID="${APP_ID}"' >> ~/.bashrc
echo 'export DASHSCOPE_API_KEY="${DASHSCOPE_API_KEY}"' >> ~/.bashrc
source ~/.bashrc
echo "Step1: Prepare Environment" >> .ros.provision
else
echo "#########################"
echo "# Environment has been ready"
echo "#########################"
fi
if ! grep -q "^Step2: Deployment service$" .ros.provision; then
echo "#########################"
echo "# Deployment service "
echo "#########################"
cd /root
wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20240729/unpfxr/demo.zip
sudo yum install -y unzip
unzip demo.zip
cd demo
python3.9 -m venv $(pwd)/venv
source $(pwd)/venv/bin/activate
pip3 install aiohttp==3.8.6
pip3 install -r requirements.txt
sed "s/socketio.run(app, debug=True, host='0.0.0.0')/socketio.run(app, debug=True, host='0.0.0.0', allow_unsafe_werkzeug=True)/" app-stream.py > temp_app_stream.py
mv temp_app_stream.py app-stream.py
rm -rf temp_app_stream.py
nohup python3.9 app-stream.py > app-stream.log 2>&1 &
echo "Step2: Deployment service" >> .ros.provision
else
echo "#########################"
echo "# Service deployed"
echo "#########################"
fi
${WaitConditionHandle.CurlCli} --data-binary '{"status": "SUCCESS"}'
- ECS_NETWORK_IP:
Fn::Select:
- 0
- Fn::GetAtt:
- EcsInstance
- PublicIps
APP_ID:
Ref:
APP_ID
DASHSCOPE_API_KEY:
Ref:
DASHSCOPE_API_KEY
Outputs:
WebUrl:
Description:
zh-cn: Web 访问地址。
en: Web addresses
Value:
'Fn::Sub':
- 'http://${ServerAddress}:5000/home'
- ServerAddress:
'Fn::Select':
- 0
- 'Fn::GetAtt':
- EcsInstance
- PublicIps
EcsLoginAddress:
Description:
zh-cn: ECS登录地址。
en: ECS login address
Value:
'Fn::Sub':
- >-
https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${Region}&instanceId=${InstanceId}
- InstanceId:
'Fn::Select':
- 0
- 'Fn::GetAtt':
- EcsInstance
- InstanceIds
Region:
Ref: 'ALIYUN::Region'
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId
- InstanceType
- InstancePassword
Label:
default:
en: ECS Configuration
zh-cn: ECS 实例配置
- Parameters:
- APP_ID
- DASHSCOPE_API_KEY
Label:
default:
en: Bailian Application Configuration
zh-cn: 百炼应用配置
Hidden:
- CommonName
TemplateTags:
- acs:technical-solution:ai:AnalyticDB与百炼搭建智能问答系统-tech_solu_150
- acs:public_template:Solution:AnalyticDB-and-Bailian-system
ALIYUN::ROS::Composer:
d94d7a23:
Rect:
- 537
- 566
- -35
- 45
- 1
- 0
ResT: Composer::ROSParameter::AlibabaCloud
df8b4d07:
Parent: d94d7a23
Rect:
- 493
- 486
- -13
- 85
- 2
- 0
ResT: Composer::ROSParameter::Region
af6238f8:
Res:
- Vpc
Parent: df8b4d07
Rect:
- 382
- 351
- 67
- 134
- 3
- 0
725f562b:
Res:
- RosWaitCondition
Parent: df8b4d07
Rect:
- 40
- 40
- 7
- 394
- 3
- 0
74dee865:
Res:
- WaitConditionHandle
Parent: df8b4d07
Rect:
- 40
- 40
- 7
- 299
- 3
- 0
461f4628:
Res:
- RunCommand
Parent: df8b4d07
Rect:
- 40
- 40
- 168
- 494
- 3
- 0
6581d00d:
Res:
- ZoneId
Parent: af6238f8
Rect:
- 338
- 278
- 87
- 185
- 4
- 0
ResT: Composer::ROSParameter::Zone
664b2ecd:
Res:
- VSwitch
Parent: 6581d00d
Rect:
- 286
- 205
- 113
- 229
- 5
- 0
b20d9a5b:
Res:
- AnalyticDB
Parent: 664b2ecd
Rect:
- 40
- 40
- 322
- 327
- 6
- 0
8f03e09f:
Res:
- SecurityGroup
Parent: af6238f8
Rect:
- 110
- 136
- 127
- 284
- 10
- 0
c7d0d931:
Parent: df8b4d07
Edge:
- 725f562b
- 74dee865
Line: 0:0:0:gray:0
65f0c661:
Parent: df8b4d07
Edge:
- 461f4628
- b20ca74e
Line: 0:0:0:gray:0
b20ca74e:
Res:
- EcsInstance
Parent: 664b2ecd
Rect:
- 40
- 40
- 168
- 327
- 11
- 0
Layer:
- 8f03e09f