-
Notifications
You must be signed in to change notification settings - Fork 0
/
guide
executable file
·209 lines (151 loc) · 5.19 KB
/
guide
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
windows上第一次运行系统的操作步骤
一、安装配置必要的组件
MySQL、Redis、MongoDB、Zookeeper、Kafka
二、执行
1.MySQL
CREATE TABLE `VehicleStatusInfor_tbl` (
`id` INT NOT NULL AUTO_INCREMENT,
`ResidualMileage` INT NOT NULL,
`OdographMeter` INT NOT NULL,
`MaintainMileage` INT NOT NULL,
`Fuel` SMALLINT NOT NULL,
`AverageFuleCut` FLOAT NOT NULL,
`AverageSpeed` INT NOT NULL,
`VehicleInstantaneousSpeed` DOUBLE NOT NULL,
`WheelSpeed_FL` DOUBLE NOT NULL,
`WheelSpeed_FR` DOUBLE NOT NULL,
`WheelSpeed_RL` DOUBLE NOT NULL,
`WheelSpeed_RR` DOUBLE NOT NULL,
`WheelTyrePressure_FL` FLOAT NOT NULL,
`WheelTyrePressure_FR` FLOAT NOT NULL,
`WheelTyrePressure_RL` FLOAT NOT NULL,
`WheelTyrePressure_RR` FLOAT NOT NULL,
`WheelTyreTemperature_FL` FLOAT NOT NULL,
`WheelTyreTemperature_FR` FLOAT NOT NULL,
`WheelTyreTemperature_RL` FLOAT NOT NULL,
`WheelTyreTemperature_RR` FLOAT NOT NULL,
`SteeringAngularSpeed` INT NOT NULL,
`SteeringAngle` INT NOT NULL,
`thing_id` INT NOT NULL,
PRIMARY KEY(`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE VehicleStatusInfor_tbl ADD CONSTRAINT VehicleStatusInfor_FK_ID FOREIGN KEY(thing_id) REFERENCES thingbaseinfo_tbl(id);
Ubuntu上部署:
github.com/harveywangdao/road/
go get github.com/Shopify/sarama
go get github.com/bsm/sarama-cluster
go get github.com/garyburd/redigo/redis
go get github.com/go-sql-driver/mysql
go get github.com/jinzhu/gorm
go get gopkg.in/mgo.v2
一、安装配置必要的组件
MySQL、Redis、MongoDB、Zookeeper、Kafka
二、执行
1.MySQL
1.1 启动MySQL
sudo netstat -tap | grep mysql
mysql -u root -p
123456
增加设备的数据库:
create database thingsdb;
use thingsdb;
CREATE TABLE `thingbaseinfodata_tbl` (
`id` INT NOT NULL AUTO_INCREMENT,
`thingserialno` VARCHAR(29) NOT NULL,
`prethingaes128key` VARCHAR(16) NOT NULL,
`thingid` VARCHAR(17) NOT NULL,
`iccid` VARCHAR(20) NOT NULL,
`imsi` VARCHAR(15) NOT NULL,
`status` TINYINT NOT NULL,
`bid` INT UNSIGNED NOT NULL,
`thingaes128key` VARCHAR(16) NOT NULL,
`eventcreationtime` INT UNSIGNED NOT NULL,
PRIMARY KEY(`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO thingbaseinfodata_tbl (thingserialno,prethingaes128key,thingid,iccid,imsi,status,bid,thingaes128key,eventcreationtime) VALUES (
"12345678901234567890123456789",
"1234567890123456",
"WDDUX52684DFR4582",
"12345678901234567890",
"HGTSN12584UHGTE",
0,
0,
"1234567890123456",
0);
增加iot后台的数据库:
create database iotdb;
use iotdb;
CREATE TABLE `thingbaseinfodata_tbl` (
`id` INT NOT NULL AUTO_INCREMENT,
`thingserialno` VARCHAR(29) NOT NULL,
`prethingaes128key` VARCHAR(16) NOT NULL,
`thingid` VARCHAR(17) NOT NULL,
`iccid` VARCHAR(20) NOT NULL,
`imsi` VARCHAR(15) NOT NULL,
`status` TINYINT NOT NULL,
`bid` INT UNSIGNED NOT NULL,
`thingaes128key` VARCHAR(16) NOT NULL,
`eventcreationtime` INT UNSIGNED NOT NULL,
PRIMARY KEY(`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO thingbaseinfodata_tbl (thingserialno,prethingaes128key,thingid,iccid,imsi,status,bid,thingaes128key,eventcreationtime) VALUES (
"12345678901234567890123456789",
"1234567890123456",
"WDDUX52684DFR4582",
"12345678901234567890",
"HGTSN12584UHGTE",
0,
0,
"1234567890123456",
0);
DBHostIP = "127.0.0.1:3306"
DBUsername = "root"
DBPassword = "123456"
DriverName = "mysql"
cd ~/golang/src/github.com/harveywangdao/road/scripts/
2.Redis
sudo /etc/init.d/redis-server start
sudo netstat -tap | grep redis
#redis-cli -h 127.0.0.1 -p 6379 -a 123456
#KEYS *
#FLUSHALL
#KEYS *
REDIS_ADDR = "localhost:6379"
3.MongoDB
sudo service mongodb start
sudo netstat -tap | grep mongod
MgoAddr = "localhost:27017"
4.Zookeeper
zkServer.sh start
zookeeper.connect=localhost:2181
5.Kafka
cd server/kafka_2.12-1.1.0
bin/kafka-server-start.sh config/server.properties
MQAddr = "localhost:9092"
cd server/kafka_2.12-1.1.0
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 10 --topic WebToGateway
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 10 --topic GatewayToWeb
bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic WebToGateway
#bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic WebToGateway --from-beginning 2>/dev/null
#bin/kafka-console-producer.sh --broker-list localhost:9092 --topic GatewayToWeb
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic GatewayToWeb --from-beginning 2>/dev/null
cd ~/server/kafka_2.12-1.1.0/logs
rm -rf *
cd /tmp/kafka-logs
rm -rf *
zkServer.sh stop
cd ~/server/zookeeper-3.4.10/data
rm -rf *
cd ~/server/zookeeper-3.4.10/logs
rm -rf *
6.iot
cd golang/src/github.com/harveywangdao/road/iot
监听 6023 端口
7.iot_client
cd golang/src/github.com/harveywangdao/road/iot_client
thing当前连接 127.0.0.1:6023 端口
8.gRPC & Protobuf
cd golang/src/github.com/harveywangdao/road/protobuf
#protoc --go_out=. *.proto
protoc --go_out=plugins=grpc:. *.proto