当前位置:网站首页>graph-node部署
graph-node部署
2022-07-27 05:04:00 【我不想头秃阿】
前言
最近在学习github上的开源项目graph-node,本地部署的过程中遇到了很多问题,几经波折最后总算跑起来了…由于源码还没怎么看懂,就整理了一下完整的过程和碰到的部分问题。
部分环境配置
1.安装rust
安装curl
sudo apt install curl
安装rust
curl https://sh.rustup.rs -sSf | sh
环境变量生效一下
source $HOME/.cargo/env
输入以下命令能查看到版本,安装成功
rustc -V
2.安装PostgreSQL
安装
sudo apt install postgresql postgresql-contrib
查看运行状态
sudo service postgresql status
进入sql命令行
sudo su postgres
psql
创建数据库
postgres=# create database test;
CREATE DATABASE
修改访问IP,允许远程访问
// 修改 postgresql.conf
// 默认是127.0.0.1,只能在本地访问
sudo gedit /etc/postgresql/12/main/postgresql.conf
设置一下参数
## 允许本机的任务一个ip地址访问postgresql
listen_addresses = '*'
修改pg_hba.conf
sudo gedit /etc/postgresql/12/main/pg_hba.conf
在文件中加入这一行,允许远程访问:
host all all 0.0.0.0/0 md5
备注:如果pgadmin连接server的时候出现password authentication failed for user,可能的解决方法有①修改postgresql的用户密码;②将pg_hba.conf里的md5都修改成trust。
重启服务
sudo service postgresql restart
3.安装ipfs
先安装go
wget https://golang.google.cn/dl/go1.16.3.linux-amd64.tar.gz
tar -xvf go1.16.3.linux-amd64.tar.gz
sudo gedit /etc/profile
// 添加
export PATH=$PATH:/usr/local/go/bin
// 生效
source /etc/profile
// 查看版本
go version
然后去ipfs官网下载一个go-ipfs_v0.9.0_linux-amd64.tar.gz,解压
tar -xvf go-ipfs_v0.9.0_linux-amd64.tar.gz
安装
./install.sh
初始化
ipfs init
ipfs cat /ipfs/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/readme
4.项目
在终端中,克隆https://github.com/graphprotocol/example-subgraph,并安装依赖项并为合约 ABI 生成类型:
yarn
yarn codegen
备注1:如果事先没有安装yarn,需要安装一下:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
yarn --version
备注2:运行yarn的过程中,可能会提示无法连接到github,如果外部连接了vp嗯的话,可以通过配置代理解决:
git config --gloabl http.proxy 本地ip地址:端口
// 取消代理
git config --gloabl unset http.proxy
备注3:nodejs版本太低可能会导致yarn codegen报错(unexpected token的错误困扰了我很久),一种解决方案是下载最新版本的nodejs
## 第一步,下载安装包
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
## 第二步, 执行安装命令
sudo apt-get install -y nodejs
在终端中,克隆https://github.com/graphprotocol/graph-node,然后运行
cargo build
中间可能会因为内存不足、缺少部分包等原因报错,解决之后重新运行cargo build即可。
5.安装ganache
// 安装pip3
sudo apt install python3-pip -y
// 使用pip3安装web3 python包
pip3 install web3
// 安装ipython3
sudo apt install ipython3 -y
// 下载并安装ganache之后,运行
./ganache-2.5.4-linux-x86_64.AppImage &
// 点击 QUICKSTART 快速启动一个以太坊测试链
运行本地图节点
运行ganache并点击 QUICKSTART 快速启动一个以太坊测试链
./ganache-2.5.4-linux-x86_64.AppImage &
运行ipfs
ipfs daemon
在graph-node文件夹下输入以下命令(以ganache为例),运行graph-node:
cargo run -p graph-node --release -- \
--postgres-url postgresql://username:[email protected]:5432/graphnode \
--ethereum-rpc mainnet:http://127.0.0.1:7545 \
--ipfs 127.0.0.1:5001 --debug
使用这个 Gravatar 示例,要让子图在本地运行,在subgraph文件夹下运行:
yarn create-local
然后可以部署子图
yarn deploy-local
这将构建子图并将其部署到图节点。它应该立即开始索引子图。子图部署完成之后,graph-node会间隔打印信息:
END
边栏推荐
猜你喜欢

Initial C language -- the function of keyword static

Construction of layout and display of weather forecast
![[NPUCTF2020]ReadlezPHP 1](/img/d9/590446b45f917be3f077a9ea739c20.png)
[NPUCTF2020]ReadlezPHP 1

初识C语言——字符串+转义字符+注释

Source code of document type full-text retrieval knowledge base management system

努力进化中_我的第一篇csdn博客

一本通1201——斐波那契数列

一本通1353——表达式括号匹配(栈)

初识C语言——常见的数据类型

Program environment and preprocessing (Part 1): how does a program run successfully?
随机推荐
qsort — c语言中自带的排序函数(附带void*、回调函数知识点
First knowledge of C language - why does every C program have a main function
Native token generation encryption and decryption
==,===,Object.is
First knowledge of C language -- common data types
努力进化中_我的第一篇csdn博客
beef-xss安装与使用
软件测试面试题(重点)
Share a multiple-choice question about the process of program compilation (including a brief discussion on the compilation process, the formation and merging process of symbol tables)
布局的搭建及天气预报的显示
C语言做一个小迷宫
广(宽)度优先搜索
一本通1201——斐波那契数列
分享一道关于#define的选择题(内含#define在预编译时的替换规则,程序环境和预处理相关知识)
使用vertical-align不能让图片和文字垂直居中对齐
JS中for...of和for...in的区别
[C language switch branch statement and loop statement]
块,行内块元素之间存在间隙
First acquaintance with C language - first acquaintance with pointer
Sharing force buckle-189. Three solutions of rotation array