文档章节

koding kite如何部署使用?

鱼小
 鱼小
发布于 2015/07/30 12:43
字数 1544
阅读 304
收藏 1

1.下载kite和kontrol代码

git项目里面都有介绍, 这里是下载最新代码,如果是用于生产环境,注意从release下载稳定版本

go get github.com/koding/kite

2.安装Kontrol和初始化

Install Kontrol:

go get github.com/koding/kite/kontrol/kontrol

注意:这里生成的kontrol可执行程序在 $GOPATH/bin/目录下面

Generate keys for the Kite key:

openssl genrsa -out key.pem 2048
openssl rsa -in key.pem -pubout > key_pub.pem

Set environment variables(这里设置基本环境变量,也可以通过kontrol进行修改):  

KONTROL_PORT=6000  
KONTROL_USERNAME="kontrol"
KONTROL_STORAGE="etcd" #注意这里,有个坑,默认是etcd,但是没有注明安装和部署
KONTROL_KONTROLURL="http://127.0.0.1:6000/kite"
KONTROL_PUBLICKEYFILE="$youpath/certs/key_pub.pem"
KONTROL_PRIVATEKEYFILE="$youpath/certs/key.pem"

Generate initial Kite key:

$GOPATH/bin/kontrol -initial
执行结果如下
~/gocode/bin $./kontrol -initial
2015-07-29 09:57:25 [kontrol] WARNING  Key pair storage is not set. Using in memory cache
2015-07-29 09:57:25 [kontrol] INFO     Registered machine on user: kontrol
kite.key is written to ~/.kite/kite.key. You can see it with:
	kitectl showkey

3. 下载运行etcd

从https://github.com/coreos/etcd/releases/tag/v2.1.1 直接下载编译好的二进制

注意:这里只是为了跑通程序,部署单机进行测试

qpzhang@qpzhangdeMac-mini:~/gocode/kitetest/etcd-v2.1.1 $./etcd 
2015/07/29 15:20:28 etcdmain: setting maximum number of CPUs to 1, total number of available CPUs is 8
2015/07/29 15:20:28 etcdmain: no data-dir provided, using default data-dir ./default.etcd
2015/07/29 15:20:28 etcdmain: listening for peers on http://localhost:2380
2015/07/29 15:20:28 etcdmain: listening for peers on http://localhost:7001
2015/07/29 15:20:28 etcdmain: listening for client requests on http://localhost:2379
2015/07/29 15:20:28 etcdmain: listening for client requests on http://localhost:4001
2015/07/29 15:20:28 etcdserver: name = default
2015/07/29 15:20:28 etcdserver: data dir = default.etcd
2015/07/29 15:20:28 etcdserver: member dir = default.etcd/member
2015/07/29 15:20:28 etcdserver: heartbeat = 100ms
2015/07/29 15:20:28 etcdserver: election = 1000ms
2015/07/29 15:20:28 etcdserver: snapshot count = 10000
2015/07/29 15:20:28 etcdserver: advertise client URLs = http://localhost:2379,http://localhost:4001
2015/07/29 15:20:28 etcdserver: initial advertise peer URLs = http://localhost:2380,http://localhost:7001
2015/07/29 15:20:28 etcdserver: initial cluster = default=http://localhost:2380,default=http://localhost:7001
2015/07/29 15:20:28 etcdserver: starting member ce2a822cea30bfca in cluster 7e27652122e8b2ae
2015/07/29 15:20:28 raft: ce2a822cea30bfca became follower at term 0
2015/07/29 15:20:28 raft: newRaft ce2a822cea30bfca [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
2015/07/29 15:20:28 raft: ce2a822cea30bfca became follower at term 1
2015/07/29 15:20:28 etcdserver: starting server... [version: 2.1.1, cluster version: to_be_decided]
2015/07/29 15:20:28 etcdserver: cannot monitor file descriptor usage (cannot get FDUsage on darwin)
2015/07/29 15:20:28 etcdserver: added local member ce2a822cea30bfca [http://localhost:2380 http://localhost:7001] to cluster 7e27652122e8b2ae
2015/07/29 15:20:29 raft: ce2a822cea30bfca is starting a new election at term 1
2015/07/29 15:20:29 raft: ce2a822cea30bfca became candidate at term 2
2015/07/29 15:20:29 raft: ce2a822cea30bfca received vote from ce2a822cea30bfca at term 2
2015/07/29 15:20:29 raft: ce2a822cea30bfca became leader at term 2
2015/07/29 15:20:29 raft: raft.node: ce2a822cea30bfca elected leader ce2a822cea30bfca at term 2
2015/07/29 15:20:29 etcdserver: setting up the initial cluster version to 2.1.0
2015/07/29 15:20:29 etcdserver: published {Name:default ClientURLs:[http://localhost:2379 http://localhost:4001]} to cluster 7e27652122e8b2ae
2015/07/29 15:20:29 etcdserver: set the initial cluster version to 2.1.0



4.启动kontrol

~/gocode/bin $./kontrol -ip=127.0.0.1 -port=6000
2015-07-29 15:23:20 [kontrol] WARNING  Key pair storage is not set. Using in memory cache
2015-07-29 15:23:20 [kontrol] INFO     New listening: 127.0.0.1:6000
2015-07-29 15:23:20 [kontrol] INFO     Serving…



现在能启动了,这里连接etcd是用默认的端口4001,如果在不同机器上部署,需要修改配置。

kontrol的使用方法如下:

Usage of ./kontrol:
  -initial=false: Change value of Initial.
  -ip=: Change value of Ip.
  -kontrolurl=http://127.0.0.1:6000/kite: Change value of KontrolURL.
  -machines=[]: Change value of Machines.
  -port=6000: Change value of Port.
  -postgres-dbname=: Change value of Postgres-DBName.
  -postgres-host=localhost: Change value of Postgres-Host.
  -postgres-password=: Change value of Postgres-Password.
  -postgres-port=5432: Change value of Postgres-Port.
  -postgres-username=: Change value of Postgres-Username.
  -privatekeyfile=/Users/qpzhang/gocode/kitetest/key.pem: Change value of PrivateKeyFile.
  -publickeyfile=/Users/qpzhang/gocode/kitetest/key_pub.pem: Change value of PublicKeyFile.
  -registerurl=: Change value of RegisterUrl.
  -tlscertfile=: Change value of TLSCertFile.
  -tlskeyfile=: Change value of TLSKeyFile.
  -username=kontrol: Change value of Username.
  -version=0.0.1: Change value of Version.



5.启动示例的kite

从 https://github.com/koding/kite/tree/master/examples 下载代码进行测试,这里测试的是

math_register.go 和 exp2-query.go

先启动提供服务者,向kontrol进行注册:

~/gocode/kitetest $./math_register
 2015-07-29 15:29:00 [math] INFO     Dialing 'kontrol' kite: http://127.0.0.1:6000/kite
2015-07-29 15:29:00 [math] DEBUG    Client transport is set to 'WebSocket'
2015-07-29 15:29:00 [math] INFO     Connected to Kontrol 
2015-07-29 15:29:00 [math] INFO     Registering to kontrol with URL: http://localhost:6667/kite
2015-07-29 15:29:00 [math] DEBUG    Telling method [register] on kite [kontrol]
2015-07-29 15:29:00 [math] DEBUG    Sending: {"method":"register","arguments":[{"kite":{"name":"math","username":"kontrol","id":"284df2a9-427f-4a31-7f80-883a2e15d042","environment":"unknown","region":"unknown","version":"1.0.0","hostname":"qpzhangdeMac-mini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JPdGnsXBS5uT-DBBniT76545M-odVqP83RToB45ahp_XRYNzbguVizqRyeKR-XVgAAy5_ckB419-R1d1ZOyCRmnzQjlyZgUk_S_A0F2x_hUfij_GcjYp2Nzy_UeZvNvubFMNdQaeTC56g"},"responseCallback":"[Function]","withArgs":[{"url":"http://localhost:6667/kite"}]}],"callbacks":{"0":[0,"responseCallback"]}}
2015-07-29 15:29:00 [math] DEBUG    Received : {"method":"kite.heartbeat","arguments":[{"kite":{"name":"kontrol","username":"kontrol","id":"b49f6b65-b152-420c-5e0b-4919b0b1825f","environment":"unknown","region":"unknown","version":"0.0.1","hostname":"qpzhangdeMac-mini.local"},"authentication":null,"responseCallback":"[Function]","withArgs":[10,"[Function]"]}],"callbacks":{"0":[0,"responseCallback"],"1":[0,"withArgs",1]}}
2015-07-29 15:29:00 [math] DEBUG    Received : {"method":0,"arguments":[{"error":null,"result":{"url":"http://localhost:6667/kite","heartbeatInterval":0}}],"callbacks":{}}
2015-07-29 15:29:00 [math] INFO     Registered to kontrol with URL: http://localhost:6667/kite and Kite query: /kontrol/unknown/math/1.0.0/unknown/qpzhangdeMac-mini.local/284df2a9-427f-4a31-7f80-883a2e15d042
2015-07-29 15:29:00 [math] INFO     New listening: 0.0.0.0:6667
2015-07-29 15:29:00 [math] INFO     Serving...



然后启动调用者:
~/gocode/kitetest $./exp2-query
2015-07-29 15:29:06 [exp2] INFO     Dialing 'kontrol' kite: http://127.0.0.1:6000/kite
2015-07-29 15:29:06 [exp2] INFO     Connected to Kontrol 
2015-07-29 15:29:07 [exp2] INFO     Dialing 'math' kite: http://localhost:6667/kite
2015-07-29 15:29:08 [exp2] INFO     math: Message from math: "You have requested square of 7"
input: 7  result: 49



然后会看到math_register输出日志:
2015-07-29 15:29:07 [math] DEBUG    New session: yWydSeY8IQKWfs3CkOhh
2015-07-29 15:29:08 [math] DEBUG    Received : {"method":"square","arguments":[{"kite":{"name":"exp2","username":"kontrol","id":"a6a11fab-d476-4275-4770-a42ad6698c3d","environment":"unknown","region":"unknown","version":"1.0.0","hostname":"qpzhangdeMac-mini.local"},"authentication":{"type":"token","key":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIva29udHJvbC91bmtub3duL21hdGgiLCJleHAiOjE0MzgzMjc4MDYsImlhdCI6MTQzODE1NDk0NiwiaXNzIjoia29udHJvbCIsImp0aSI6IjMyMTA4ZWIzLTg5MWItNGExZi03ZjQ3LTQ0MDU4YTczYWIyZSIsIm5iZiI6MTQzODE1NDg4Niwic3ViIjoia29udHJvbCJ9.CrireQe5HvNxbefvyGSaWDpHYEaX7cAkkQJjbWno4f7ki5sLAqJGet65heyiZFMNqJBALQZHkTVjExuwYA8b7ade4Y15ht9yhUdK8hRNbpzgQ5NHCMozJLvpkeijkp02EMSG8wfNbXogld3OkcajpGzN0b6KnRfSmsyNe9MdX5u7VesHo4JXTzlnY9zOTTtgGEjZQvlxI8WQTXge_6O0IMKO2xl5PvokYrnOLmNnKMYKYRYtj2MH58vvkQaqoktiKGRGmSDqBzNDoxX4X1reWdShcPn_1c38sV1aw3CvFbjRyrXHGf25g5dMqX98jC7IpcLCKWTv9rkKuS88LCvNPA"},"responseCallback":"[Function]","withArgs":[7]}],"callbacks":{"0":[0,"responseCallback"]}}
2015-07-29 15:29:08 [math] DEBUG    Session "yWydSeY8IQKWfs3CkOhh" is identified as "/kontrol/unknown/exp2/1.0.0/unknown/qpzhangdeMac-mini.local/a6a11fab-d476-4275-4770-a42ad6698c3d"
Call received, sending result 49 back



至此,这个框架都跑起来了。

但是都是在本机。

【Kite架构是怎么样?】
 
【Kite代码是怎么编写的?】
 
【Kite如何搭建分布式系统?会存在那些问题?】

后续慢慢研究 了。


© 著作权归作者所有

共有 人打赏支持
鱼小
粉丝 5
博文 1
码字总数 1544
作品 0
深圳
私信 提问
加载中

评论(1)

m
marksion08
感谢分享,集群服务已经跑起来。希望客户端,sockjs 那一块也有新的分享~
微服务框架--Koding Kite

【Kite是什么?git项目上的解释】 Kite is a framework for developing micro-services in Go. 一个基于go语言的微服务框架,微服务概念非常火,可以自行google了解。 然后kite也上过gopher,...

鱼小
2015/07/30
1K
0
koding kite如何部署使用?

内容直接贴到这里了 http://my.oschina.net/jackeyzhang/blog/485567

鱼小
2015/07/30
124
0
为什么 Koding 要从容器移植到虚拟机?

在Quora上Devrim Yasar的answer: 为什么Koding要从容器和Docker移植到虚拟机? 我一直想围绕“可扩展的工程”这个主题写一篇博客,直到下面的事情发生: 当我们在2011年底内部测试LXC时,我们...

oschina
2016/02/14
3K
13
现代化 Webmail 平台--Kite Webmail

Kite 是下一代 Webmail 平台,可以说是 Gmail 的克隆。Kite 非常容易在单个服务器上部署。前端使用 AngularJS,后端使用 Python。

叶秀兰
2015/09/11
1K
0
一款让程序员编程更智能的开发工具Kite

  【IT168 技术】最好的产品和想法总是出于识别和解决一般和广泛的需求。对于程序员而言有一项刚需,就是花费时间搜索互联网的相关开发文档和代码示例。   Kite正是为了解决这样需求而诞...

it168网站
2017/04/26
0
0

没有更多内容

加载失败,请刷新页面

加载更多

rabbitmq

灰暗
40分钟前
1
0
Flink

flink HA部署 flink搭建,采用分布式部署方式,分别为A,B,C三个节点。其中A为master;A,B,C为worker。 本文使用的用户是hadoop用户(自己新建) 先决条件 Java 1.8.x or higher scala 自己使用...

-九天-
今天
2
0
数据中台和传统数仓的区别

中台系统把业务层同性的算法能力,服务能力,业务能力高度集成,有效组织 ,动态规划。更好的帮助上层业务。 今天就让我们看看关于数据中台的问答吧。 1 Q : 什么是数据中台? A : 数据中台是...

hblt-j
今天
4
0
Java在什么时候会出现内存泄漏

在Java中,内存泄漏就是存在一些被分配的对象,这些对象有下面两个特点,首先,这些对象是可达的,即在有向图中,存在通路可以与其相连;其次,这些对象是无用的,即程序以后不会再使用这些对...

群星纪元
今天
2
0
android 打开摄像头

private SurfaceHolder mHolder; private SurfaceView mSurfaceView; private Camera mCamera; mSurfaceView = (SurfaceView) this.findViewById(R.id.camsurfaceView1); mHolder = mSurface......

jingshishengxu
今天
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部