• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

ubuntu20.04 搭建门罗币节点

开发技术 开发技术 6小时前 6次浏览
第一步更新:
sudo apt update && sudo apt-get upgrade
第二步安装git:
sudo apt install git 如果已安装git请跳过
第三步安装依赖:
sudo apt install build-essential cmake doxygen graphviz miniupnpc pkg-config libboost-all-dev libcurl4-openssl-dev libgtest-dev libminiupnpc-dev libreadline-dev libssl-dev libunbound-dev libunwind8-dev libzmq3-dev libzmq3-dev libpgm-dev libsodium-dev
如果在安装依赖时发生错误,参考:
https://blog.csdn.net/otter1010/article/details/105431417
https://blog.csdn.net/u010426270/article/details/52028620

第四步: libgtest-dev 在 Ubuntu 上不是二进制的,所以你必须编译

cd /usr/src/gtest 
sudo cmake . 
sudo make -j2
sudo mv libg* /usr/lib/
第五步,克隆github上的门罗币源码,这个看网络情况,网不好会git clone 以及make可能会失败: 
cd ~
git clone --recursive https://github.com/monero-project/monero
cd monero
make -j2 release # -j4 for 4 threads etc
第六步: 把编译后的文件拷贝:
sudo cp build/Linux/master/release/bin/* /usr/local/bin/
设置防火墙:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh

sudo ufw allow 22
sudo ufw allow 18080 
sudo ufw allow 18081 
sudo ufw allow 18082 
 
sudo ufw enable
第七步: set up service: 
cd /lib/systemd/system
sudo wget https://gist.githubusercontent.com/mariodian/b8bb62de8f5aa5466cccb17f280f439e/raw/db0a98573e0a8cc871781d8d43f03437ca159e22/monerod.service
sudo chmod 644 monerod.service
修改一下monerod.service文件内容, 如果报"monerod.service: Changing to the requested working directory failed: Permiss"错误,修改一下root/monero文件夹的权限: 
[Unit]
Description=Monero Full Node
After=network.target

[Service]
User=xsk
Group=xsk
WorkingDirectory=~
RuntimeDirectory=monero

# Clearnet config
#
Type=forking
PIDFile=/run/monero/monerod.pid
ExecStart=/usr/local/bin/monerod --restricted-rpc --block-sync-size 3 --confirm-external-bind --config-file /root/.bitmonero/monerod.conf 
    --detach --pidfile /run/monero/monerod.pid

# Tor config
#
## We have to use simple, not forking, because we cannot pass --detach
## because stderr/stdout is not available when detached, but torsocks
## attempts to write to it, and fails with 'invalid argument', causing
## monerod to fail.
#Type=simple
#Environment=DNS_PUBLIC=tcp
## The following is needed only when accessing wallet from a different
## host in the LAN, VPN, etc, the RPC must bind to 0.0.0.0, but
## by default torsocks only allows binding to localhost.
#Environment=TORSOCKS_ALLOW_INBOUND=1
#ExecStart=/usr/bin/torsocks /usr/bin/monerod --config-file /etc/monerod.conf 
#    --non-interactive

Restart=always

[Install]
WantedBy=multi-user.target
第八步Next, create a config file:
mkdir ~/.bitmonero
cd ~/.bitmonero
touch monerod.conf
第九步命令行输入:
echo "data-dir=/home/satoshi/.bitmonero" >> monerod.conf
echo "log-file=/home/satoshi/.bitmonero/monero.log" >> monerod.conf
echo "log-level=0" >> monerod.conf
如果要连接rpc远程节点,做一下设置,用户名和密码自己修改
echo "rpc-bind-ip=0.0.0.0" >> monerod.conf
echo "rpc-bind-port=18081" >> monerod.conf
echo "rpc-login=testUser:testPassword" >> monerod.conf
第十步Run the service, Enable the systemd config and start the daemon:
sudo systemctl enable monerod
sudo service monerod start
查看门罗币日志:
tail -f monero.log
或者 using a simpler output:
monerod --config-file /home/satoshi/.bitmonero/monerod.conf status
第十一步, 设置Allow incoming connections :
For the P2P connection run this command:
sudo iptables -I INPUT -p tcp --dport 18080 -j ACCEPT

For the RPC:
sudo iptables -I INPUT -p tcp --dport 18081 -j ACCEPT
保存设置Save the rules permanently:
sudo iptables-save

连接自己的钱包,下载monero-wallet-gui钱包的可视化界面: 
https://www.getmonero.org/downloads/


程序员灯塔
转载请注明原文链接:ubuntu20.04 搭建门罗币节点
喜欢 (0)