########1############
下载宝塔:
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh
Congratulations! Install succeeded!
==================================================================
Bt-Panel: http://155.138.211.245:8888/37dfffff
username: dbdiyxmj
password: f2ec3b83
Warning:
If you cannot access the panel,
release the following port (8888|888|80|443|20|21) in the security group
==================================================================
sudo apt update
########2############
sudo apt install libev-dev libjansson-dev libmpdec-dev libmysqlclient-dev libcurl4-gnutls-dev libldap2-dev libgss-dev librtmp-dev libsasl2-dev git default-jdk openssl libssl-dev mysql-server
数据库root 密码:root
########3############
wget http://www.digip.org/jansson/releases/jansson-2.12.tar.gz
tar xzvf jansson-2.12.tar.gz
cd jansson-2.12
./configure --prefix=/usr --disable-static && make && make install
whereis libjansson
cd ..
########4############
wget https://github.com/edenhill/librdkafka/archive/v0.11.3.tar.gz -O librdkafka-0.11.3.tar.gz
tar zxvf librdkafka-0.11.3.tar.gz
cd librdkafka-0.11.3/
./configure && make && make install
whereis libjansson
###########################################################
### Configure failed ###
###########################################################
### Accumulated failures: ###
###########################################################
cxx (WITH_CXX) C++ compiler (c++)
module: cc
action: fail
reason:
command 'c++ --version' failed:
mklove/modules/configure.base: line 1184: c++: command not found
如果出现上面的错误请执行下面的命令
sudo apt-get install g++
########5############
wget ftp://apache.cs.utah.edu/apache.org/kafka/2.2.0/kafka_2.12-2.2.0.tgz
tar zxvf kafka_2.12-2.2.0.tgz
配置kafka
cd kafka/config/
vi server.properties
broker.id=0
port = 9092
host.name = localhost
vi producer.properties
bootstrap.servers=localhost:9092
metadata.broker.listconnect=localhost:9092
vi zookeeper.properties
clientPort=2181
host.name = localhost
vi consumer.properties
zookeeper.connect=localhost:2181
# timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
cd ..
bin/zookeeper-server-start.sh config/zookeeper.properties &
bin/kafka-server-start.sh config/server.properties &
##############
$ wget http://download.redis.io/releases/redis-3.2.8.tar.gz
$ tar xzf redis-3.2.8.tar.gz
###$ mv redis-3.2.8 redis
###$ cd redis
cd redis-3.2.8/
$ make PREFIX=/usr/local/redis install
ln -s /usr/local/redis/bin/redis-cli /usr/local/bin/redis-cli
ln -s /usr/local/redis/bin/redis-sentinel /usr/local/bin/redis-sentinel
ln -s /usr/local/redis/bin/redis-server /usr/local/bin/redis-server
redis-server redis.conf &
redis-sentinel sentinel.conf &
#####
cd ~
git clone https://github.com/viabtc/viabtc_exchange_server.git
cd viabtc_exchange_server
make -C depends/hiredis
make -C network
vi utils/makefile
#modify INCS 此句代码需要删除 INCS = -I ../network
# 添加下面代码
INCS = -I ../network -I ../depends
make -C utils
vi accesshttp/makefile
# modify INCS & LIBS
INCS = -I ../network -I ../utils -I ../depends
LIBS = -L ../utils -lutils -L ../network -lnetwork -L ../depends/hiredis -Wl,-Bstatic -lev -ljansson -lmpdec -lrdkafka -lz -lssl -lcrypto -lhiredis -lcurl -Wl,-Bdynamic -lm -lpthread -ldl -lssl -lldap -llber -lgss -lgnutls -lidn -lnettle -lrtmp -lsasl2 -lmysqlclient
make -C accesshttp
$ vi accessws/makefile
{modify INCS and LIBS like accesshttp/makefile}
$ make -C accessws
vi alertcenter/makefile
{modify INCS and LIBS like accesshttp/makefile}
$ make -C alertcenter
$ vi marketprice/makefile
{modify INCS and LIBS like accesshttp/makefile}
$ make -C marketprice
$ vi matchengine/makefile
{modify INCS and LIBS like accesshttp/makefile}
$ make -C matchengine
$ vi readhistory/makefile
{modify INCS and LIBS like accesshttp/makefile}
$ make -C readhistory
#### create db
cd sql/
vi init_trade_history.sh
修改数据库连接信息
MYSQL_HOST="localhost"
MYSQL_USER="root"
MYSQL_PASS="root"
MYSQL_DB="trade_history"
vim create_trade_history.sh
CREATE DATABASE `trade_history`;
USE `trade_history`;
vim create_trade_log.sh
CREATE DATABASE `trade_log`;
USE `trade_log`;
mysql -u root -p < create_trade_history.sql
mysql -u root -p < create_trade_log.sql
./init_trade_history.sh
#### 配置数据库
## 修改 数据库连接信息
cd /viabtc_exchange_server/blob/master/matchengine
vi config.json
./restart.sh
## redis 负载均衡 修改为26379 不能做一个机器上,目前是一台的
cd /viabtc_exchange_server\alertcenter
vi config.json
./restart.sh
"redis": {
"name": "mymaster",
"addr": [
"127.0.0.1:26379",
"127.0.0.1:26379",
"127.0.0.1:26379"
]
}
### 修改 \readhistory 数据库信息 "user": "root","pass": "root",
cd /viabtc_exchange_server\readhistory
vi config.json
./restart.sh
### https-wss http-ws
## 修改 \marketprice 端口 为26379
vi config.json
./restart.sh
"redis": {
"name": "mymaster",
"addr": [
"127.0.0.1:26379",
"127.0.0.1:26379",
"127.0.0.1:26379"
]
},
创建文件夹 /var/log/trade/matchengine
### 启动 按顺序
cd /matchengine && ./restart.sh && cd ..
alertcenter
readhistory
accesshttp
accessws
marketprice
安装nginx 并配置信息 在etc 目录下
upstream unix_accessws_server {
server unix:/tmp/accessws.sock;
}
server {
listen 8090;
root /root/viabtc_exchange_server/accessws;
#server_name ceshi.baidu.com;
location / {
index index.html;
proxy_pass http://unix_accessws_server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
curl http://127.0.0.7:8080/ -d '{"method": "market.list","params": [],"id": 1516681174}'