ubuntu20.04 搭建門羅幣節點


第一步更新:
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可能會失敗: 
創建/root/source
cd /root/source
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=./source/monero
# StateDirectory=./.bitmonero
# LogsDirectory=./.bitmonero

Type=forking
PIDFile=/root/.bitmonero/monerod.pid

ExecStart=/usr/local/bin/monerod --restricted-rpc --block-sync-size 3 --confirm-external-bind --config-file  /root/.bitmonero/monerod.conf  --detach --pidfile  /root/.bitmonero/monerod.pid
StandardOutput=null
StandardError=null

Restart=always

[Install]
WantedBy=multi-user.target
第八步Next, create a config file:
mkdir ~/.bitmonero
cd ~/.bitmonero
touch monerod.conf
第九步命令行輸入:
echo "data-dir=~/.bitmonero" >> monerod.conf
echo "log-file=~/.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
或者
monerod --config-file ~/.bitmonero/monerod.conf status
查看門羅幣服務狀態:
systemctl status monerod.service

服務跑起來如下:

第十一步, 設置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/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM