2、 在root目录下新建一个名叫seer的目录,复制v0.0.5版本的程序包到此目录,并更名为seer.tar.gz。(此处注意,若有了更新的程序包版本,则到SEER软件发布页https://github.com/seer-project/seer-core-package/releases 复制最新的ubuntu版本程序包链接替换掉此下载链接。)
mkdir seer curl -Lo seer/seer.tar.gz https://github.com/seer-project/seer-core-package/releases/download/v0.05/witness_node-ubuntu-0.0.5.tar.gz3、 切换到seer目录,解压此软件包。
cd seer tar xzvf seer.tar.gz4、 带参数启动witness_node,其中./data是指定区块链数据的存放目录,127.0.0.1:9090是设置是节点对外的Websocket RPC服务地址和端口。
./witness_node --data-dir ./data --rpc-endpoint=127.0.0.1:90905、 观察节点运行正常,显示3秒一个出块后,ctrl+A d隐藏screen,之后要再打开运行有节点的Sreeen,则使用 screen -R ,或 screen -r seer。
6、 在服务器上安装使用wscat测试ws。
安装:
apt install node-ws测试:
wscat -c ws://127.0.0.1:9090 > {"jsonrpc": "2.0", "method": "get_block", "params": [1], "id": 1} < {"id":1,"jsonrpc":"2.0","result":{"previous":"0000000000000000000000000000000000000000","timestamp":"2018-05-18T12:00:03","witness":"1.5.2","transaction_merkle_root":"5fbe404a5640f6f070884d7a7e480ce2ae686f3d","extensions":[],"witness_signature":"1f722606de6dc7fcdd258744e9f2c42983fdbbfecabe8e597fb9c90b6e2298e51a79f19b3fef34a9706b2fe186f6a5174c081538d750b92ae9842c89ea75079ec7","transactions":[{"ref_block_num":0,"ref_block_prefix":0,"expiration":"2018-05-18T12:00:30","operations":[[33,{"fee":{"amount":0,"asset_id":"1.3.0"},"deposit_to_account":"1.2.13","balance_to_claim":"1.12.1","balance_owner_key":"SEER71d7yHA7KgW8qkHYv4hX2WT4X1FariKbjWCqAfegjGr8B2LowE","total_claimed":{"amount":"100000000000","asset_id":"1.3.0"}}]],"extensions":[],"signatures":["2034bffb272ed20e482cb647685ae30f1a4b8b5cf6814495f3bc730aba83af7f771a72ae1e129f8e92419c0028177d837503226c67b35a3d818a7aabbfa9b19965","204a2219d727e097b1159e9d85db13d6dcfc98d9d9741866b2b4f4b3da28382245036282dd7fc504e50a4872aef215d7009cd6a190739d61545eee0b67bf00120d"],"operation_results":[[0,{}]]},{"ref_block_num":0,"ref_block_prefix":0,"expiration":"2018-05-18T12:00:30","operations":[[4,{"fee":{"amount":514453,"asset_id":"1.3.0"},"registrar":"1.2.13","referrer":"1.2.13","referrer_percent":0,"name":"test001","owner":{"weight_threshold":1,"account_auths":[],"key_auths":[["SEER5YaXn6iaZ14RuzmGQkbVQwU6VS4A9wWzA5P4JpkhiYdNah3KnF",1]],"address_auths":[]},"active":{"weight_threshold":1,"account_auths":[],"key_auths":[["SEER7pGpLgPDAKtvEPx9gTnNcFvKaWyKWSHCiysn2fyryCtVaRBBTJ",1]],"address_auths":[]},"options":{"memo_key":"SEER7pGpLgPDAKtvEPx9gTnNcFvKaWyKWSHCiysn2fyryCtVaRBBTJ","voting_account":"1.2.5","num_committee":0,"num_authenticator":0,"num_supervisor":0,"votes":[],"extensions":[]},"extensions":{}}]],"extensions":[],"signatures":["1f7be5f6dc2c6fffab9841491a3fe729293d7f8d57fb7c0e62a368a88977ad3f35384498b846eb1c0215a76608760f54e496aada7673e1b6f2969985987c722bf5"],"operation_results":[[1,"1.2.14"]]}]}}正常的话,会返回SEER的区块#1的信息,现在和此节点同一台设备上的命令行钱包和轻钱包都能用ws://127.0.0.1:9090这个API和区块链交互了,下面我们将配置nginx,让此API能通过公网访问。
配置服务器nginxnginx在服务器上负责反向代理、SSL等服务,如果要配置多节点负载均衡也是对nginx进行配置。
安装nginx sudo apt update sudo apt install nginx出现Do you want to continue? [Y/n]的时候Y就可以了。
配置nginx1、 在/etc/nginx/sites-available/目录新建一个名为apifile的nginx配置文件
sudo nano /etc/nginx/sites-available/apifile2、 打开文件后,以下面内容为例,写入配置文件:
# WebSocket 配置 map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream nodeapi { # 127.0.0.1:9090 是节点启动时配置的rpc服务地址和端口,修改为你的 server 127.0.0.1:9090 fail_timeout=0; } server { # 监听80端口 listen 80; root /var/www/html; index index.html index.htm index.nginx-debian.html; # api.seerchain.org 修改为你的域名 server_name api.seerchain.org; location / { proxy_set_header Host $http_host; proxy_redirect off; proxy_http_version 1.1; proxy_pass ; # WebSocket 配置 proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }3、 修改完成后,使用nano的写入和退出快捷键,即control+O-ENTER,control+X。
4、 将apifile软链接到配置目录
sudo ln -s /etc/nginx/sites-available/apifile /etc/nginx/sites-enabled/5、 测试nginx配置是否有错,如果有错根据提示修改
sudo nginx -t6、 重新载入nginx
sudo systemctl reload nginx