kong and postgrep sql

来源:互联网 发布:北京养老金算法 编辑:程序博客网 时间:2024/06/03 20:52

https://wenku.baidu.com/view/699e89a46429647d27284b73f242336c1eb93092.html

https://wenku.baidu.com/view/699e89a46429647d27284b73f242336c1eb93092.html


 1 
 
基于xAPI的学习行为大数据研究与实现 
沈伟 
摘要: 在线教育和大数据为教育的发展带来了创新,教育大数据的最佳实现首先依赖于对来源广泛的学习行为数据获取,而来源广泛的学习行为存在于多种在线教育应用中,其多种在线教育应用的独立性、复杂性、多样性等特点阻碍了学习行为数据获取。由美国“高级分布式学习”组织发布的Experience API(xAPI)规范为破解这一难题提供了可行途径,可基于xAPI规范实现学习行为大数据的获取、整合和共享,为进一步的分析与挖掘奠定基础。基于SCORM、xAPI与LRS实现LMS平台是进行学习行为大数据研究与实现的一种有效实践探索。


Knewton(目前全球范围内拥有学习数据最多的公司之一

培训和学习体系架构TLA 的顶层架构包括四个部分:学习行为跟踪(Experience Tracking)、学习者档案(Learner Profile)、内容代理(Content Brokering)、能力认证(Competency Infrastructure)。学习行为跟踪部分包含两个项目, 一个是接口规范xAPI;另一个是学习行为库(Learning Record Store,LRS)。两个项目时紧密相关的,接口规范xAPI所产生的学习行为记录入LRS(学习行为库)中。

培训和学习体系架构TLA 的顶层架构包括四个部分:学习行为跟踪(Experience Tracking)、学习者档案(Learner Profile)、内容代理(Content Brokering)、能力认证(Competency Infrastructure)。学习行为跟踪部分包含两个项目, 一个是接口规范xAPI;另一个是学习行为库(Learning Record Store,LRS)。两个项目时紧密相关的,接口规范xAPI所产生的学习行为记录入LRS(学习行为库)中。


sudo -u postgres psql


ALTER USER postgres WITH PASSWORD 'postgres';


ALTER USER kong WITH PASSWORD 'kong';
ALTER ROLE
退出PostgreSQL psql客户端
         postgres=# \q
         \l   列出数据库
         \h:查看SQL命令的解释,比如\h select。
\?:查看psql命令列表。
\l:列出所有数据库。
\c [database_name]:连接其他数据库。
\d:列出当前数据库的所有表格。
\d [table_name]:列出某一张表格的结构。
\du:列出所有用户。
\e:打开文本编辑器。
\conninfo:列出当前数据库和连接的信息。


访问页面
$ curl -i http://localhost:8001/
http://192.168.1.197:8001/
API转发  http://192.168.1.197:8000/
{"message":"no API found with those values"}


https://getkong.org/docs/0.11.x/getting-started/quickstart/




kong stop
kong reload


Kong is now aware of your API and ready to proxy requests.  最基本就是作为一个api gateway


curl -i -X POST \
  --url http://localhost:8001/apis/ \
  --data 'name=example-api' \
  --data 'hosts=qjy.qpedu.cn' \
  --data 'upstream_url=http://qjy.qpedu.cn/qjy/edu_qiandao_login_huiyi.jsp'
  
  
应答===》 kong本身也是通过管理APi来提供注册,免费版本不提供UI界面
HTTP/1.1 201 Created
Date: Wed, 11 Oct 2017 09:28:49 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/0.11.0


{"created_at":1507714129000,"strip_uri":true,"id":"75e6e3e3-3f3b-4689-828b-d2216eba6684","hosts":["qjy.qpedu.cn"],"name":"example-api","http_if_terminated":false,"preserve_host":false,"upstream_url":"http:\/\/qjy.qpedu.cn\/qjy\/edu_qiandao_login_huiyi.jsp","upstream_connect_timeout":60000,"upstream_send_timeout":60000,"upstream_read_timeout":60000,"retries":5,"https_only":false}


====》模拟请求接口---通过header传递 host参数《====
curl -i -X GET \
  --url http://localhost:8000/ \
  --header 'Host: qjy.qpedu.cn'
  
Kong knows to do this through the header defined in the above cURL request:
Host: <given host>  
curl -i -X GET \
  --url http://localhost:8000/ \
  --header 'name: example-api'
  
通过GEt查询下接口信息  
http://192.168.1.197:8001/apis/example-api  
{"created_at":1507714129000,"strip_uri":true,"id":"75e6e3e3-3f3b-4689-828b-d2216eba6684","hosts":["qjy.qpedu.cn"],"name":"example-api","http_if_terminated":false,"https_only":false,"retries":5,"preserve_host":false,"upstream_connect_timeout":60000,"upstream_read_timeout":60000,"upstream_send_timeout":60000,"upstream_url":"http:\/\/qjy.qpedu.cn\/qjy\/edu_qiandao_login_huiyi.jsp"}




增加授权插件后,再次请求会提示401
HTTP/1.1 401 Unauthorized
Date: Wed, 11 Oct 2017 09:36:34 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
WWW-Authenticate: Key realm="kong"




http://192.168.1.197:8001/consumers/
{"total":0,"data":[]}


https://getkong.org/docs/0.11.x/getting-started/adding-consumers/


原创粉丝点击