• XDAG同步节点部署


    系统环境要求

    JDK : v17
    Maven : v3.9.1-v3.9.5
    MySQL : v8.0系列

    1、MySQL8.0安装

    1)docker-compose安装详情
    MySQL安装
    2)配置数据库账号密码及键表

    # docker exec -it mysql8 /bin/bash
    # root@0286a1fd60e6:/# mysql -uroot -p
    Enter password:
    mysql> CREATE DATABASE xdagj;
    Query OK, 0 rows affected (0.00 sec)
    mysql> use xdagj;
    mysql> CREATE TABLE `t_transaction_history` (
      `fid` int(11) NOT NULL AUTO_INCREMENT,
      `faddress` varchar(64) NOT NULL,
      `faddresstype` tinyint(4) NOT NULL,
      `fhash` varchar(64) NOT NULL,
      `famount` decimal(20,9) unsigned zerofill NOT NULL,
      `ftype` tinyint(4) NOT NULL,
      `fremark` varchar(64) DEFAULT NULL,
      `ftime` datetime(3) NOT NULL,
      PRIMARY KEY (`fid`),
      UNIQUE KEY `id_UNIQUE` (`fid`),
      KEY `faddress_index` (`faddress`)
    ) ENGINE=InnoDB AUTO_INCREMENT=17392050 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
    Query OK, 0 rows affected (0.00 sec)
    mysql> CREATE USER 'xdagj'@'%' IDENTIFIED BY 'xdagj';
    Query OK, 0 rows affected (0.00 sec)
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'xdagj'@'%' WITH GRANT OPTION;
    Query OK, 0 rows affected (0.00 sec)
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    2、准备java编译环境,编译代码

    1)安装jdk17

    # apt-get install openjdk-17-jdk
    
    • 1

    2)安装过maven3.9.5

    # wget https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz
    # tar -xf apache-maven-3.9.5-bin.tar.gz -C /usr/local/
    # vim /etc/profile
    `
    MAVEN_HOME=/usr/local/apache-maven-3.9.5/bin/
    export PATH=$PATH:$MAVEN_HOME
    `
    # source /etc/profile
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    3)拉取代码并编译代码

    # git clone https://github.com/XDagger/xdagj.git
    # cd xdagj
    # mvn clean package -Dmaven.test.skip=true
    # ls dist
    xdag.bat  xdagj-linux.zip  xdagj-macos.zip  xdagj-windows.zip  xdag.sh
    # mkdir bin
    # unzip dist/xdagj-linux.zip -d bin/
    # cd bin
    ls
    druid.properties  log4j2.xml  logs  mainnet  rpc_modules.conf  xdag-devnet.conf  xdagj-0.6.5-shaded.jar  xdag-mainnet.conf  xdag.sh  xdag-testnet.conf
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    3、下载数据快照

    快照地址
    在这里插入图片描述

    # cd bin
    # wget https://storage.xdagpool.com/snapshot-2722283-193b2380000.tar.gz
    # mkdir -p mainnet/rocksdb/xdagdb/
    # tar -xf snapshot-2722283-193b2380000.tar.gz -d mainnet/rocksdb/xdagdb/
    
    • 1
    • 2
    • 3
    • 4

    4、编辑配置文件启动节点

    编辑xdag-mainnet.conf文件

    # cat xdag-mainnet.conf
    # Admin Config
    admin.telnet.ip = 127.0.0.1
    admin.telnet.port = 6001
    admin.telnet.password = root
    
    # Pool Config
    pool.ip = 0.0.0.0
    pool.port = 7001
    pool.tag = XdagJ
    
    # Pool-Reward Config
    pool.poolRation = 5
    pool.rewardRation = 5
    pool.fundRation = 5
    pool.directRation = 5
    pool.fundAddress = FQglVQtb60vQv2DOWEUL7yh3smtj7g1s
    
    # Node config
    node.ip = 0.0.0.0
    node.port = 8001
    node.maxInboundConnectionsPerIp = 8
    # 公共节点IP,要找供应商添加白名单
    node.whiteIPs = ["152.32.219.239:8001"]
    # 同步节点不挖矿,关闭出块
    node.generate.block.enable = false 
    
    # Node transaction history config
    node.transaction.history.enable = true
    
    # Node libp2p Config
    node.libp2p.port = 9001
    node.libp2p.isbootnode = true
    node.libp2p.privkey = 0x0802122074ca7d1380b2c407be6878669ebb5c7a2ee751bb18198f1a0f214bcb93b894b5
    node.libp2p.bootnode = ["enr:-Iu4QPY6bYDC0PaafEwhgg_6yTcx0GAGbSARYqehJKEkyOmxX6SNZMyMMdkmDw9bAvYN9m2LrqIsPSd-bUqff0tsHYABgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQJ2EWgMpl6PtyFKMbbOb82Ob-al9NeE3GYB3-K7n4yWwoN0Y3CCJxGDdWRwgicR"]
    
    # Node RPC Config
    rpc.enabled = true
    rpc.http.host = 0.0.0.0
    rpc.http.port = 10001
    rpc.ws.port = 10002
    
    # Miner Config
    miner.globalMinerLimit = 8192
    miner.globalMinerChannelLimit = 8192
    miner.maxConnectPerIp = 256
    miner.maxMinerPerAccount = 256
    
    # Randomx Config
    randomx.flags.fullmem = false
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    编辑druid.properties文件

    # cat druid.properties 
    driverClassName=com.mysql.cj.jdbc.Driver
    url=jdbc:mysql://localhost:3306/xdagj?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&&serverTimezone=UTC
    username=xdagj
    password=xdagj
    minIdle=5
    initialSize=5
    maxActive=10
    maxWait=100
    testOnBorrow=true
    testOnReturn=true
    testWhileIdle=true
    validationQuery=select 1
    validationQueryTimeout=1
    timeBetweenEvictionRunsMillis=480000
    ConnectionErrorRetryAttempts=3
    NotFullTimeoutRetryCount=3
    #removeAbandonedTimeoutMillis=480000
    #removeAbandoned=true
    numTestsPerEvictionRun=3
    minEvictableIdleTimeMillis=480000
    maxEvictableIdleTimeMillis=600000
    keepAliveBetweenTimeMillis=540000
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    启动节点

    sh xdag.sh --enablesnapshot true 2722283 193b2380000
    enable snapshot:true
    Create New Wallet...
    EnterNewPassword:
    ReEnterNewPassword:
    HdWallet Initializing...
    HdWallet Mnemonic: avcd hfbf host aegterg ajfgh lojfob aeogn aedg aegrg sefge jkne adomm
    HdWallet Mnemonic Repeat:avcd hfbf host aegterg ajfgh lojfob aeogn aedg aegrg sefge jkne adomm quote
    HdWallet Initialized Successfully!
    New Address:2a3e4c487lkd2238a2e7a9ec33767852c9ohgfri
    init snapshot...
    init snapshotJ done
    time:371582ms
    Our balance: 0.000000000
    All amount: 1219994175.999999023
    telnetd is running on 127.0.0.1:6001
    Nov 20, 2023 8:21:47 PM org.jline.builtins.telnet.PortListener run
    INFO: Listening to Port 6,001 with a connectivity queue size of 10.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    5、查询操作节点

    :~# telnet 127.0.0.1 6001
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    Enter Admin password>**** (mainnet配置文件中有)
    xdag> state
    Connected to the main network. Synchronizing from low to high.
    xdag> balance 
    Balance: 0.000000000 XDAG
    xdag> account
    4rN1bDkkv3oXKF8PUpUZjVxi6wNdCTZ3T 0.000000000 XDAG
    
    xdag> xfer
    Lost some param
    xdag> net -l
    /152.32.219.239:8001 2023-11-20 20:58:33 31424 in/16092 out
    /152.32.219.239:34044 2023-11-20 20:59:26 76 in/3 out
    xdag> mainblocks
    ---------------------------------------------------------------------------------------------------------
    height        address                            time                      state     mined by            
    ---------------------------------------------------------------------------------------------------------
    02724441   xUjl48zOvF/52Zb2L5VR0cMWkWg66XtD   2023-08-30 11:49:19.999   Main      HTTPS://XDAG.ORG EQUAL
    02724440   zIUVbTK3mOcA2QAT6TX3TZ1uLkz/8jn8   2023-08-30 11:48:15.999   Main      HTTPS://XDAG.ORG SOLO
    02724439   1oo0o4A5MW302xBvMwD6wQ95O8IwHaJh   2023-08-30 11:47:11.999   Main      https://equal.xdagmine.com
    02724438   HSAFCKZD2Veb1tESbpC+8OnqQ1XRd8dC   2023-08-30 11:46:07.999   Main      HTTPS://XDAG.ORG SOLO
    02724437   x25cLeypUR0+ZWcTJTHD9RYcqjfca1WX   2023-08-30 11:45:03.999   Main      HTTPS://XDAG.ORG SOLO 2
    02724436   rTa41sp/0PKCEHq71X0mRrBv3jHaqejL   2023-08-30 11:43:59.999   Main      HTTPS://XDAG.ORG SOLO
    02724435   oM8wBE3GDnk8SvyDacm+MNc3G2ZvDnwA   2023-08-30 11:42:55.999   Main      HTTPS://XDAG.ORG SOLO
    02724434   4+tE8yaqNWLsnPjCDcR2zBn+GI+YU5MO   2023-08-30 11:41:51.999   Main      https://equal.xdagmine.com
    02724433   XQypGeg0kw0o2N12i/qrqAMBVGnCM187   2023-08-30 11:40:47.999   Main      HTTPS://XDAG.ORG EQUAL 2
    02724432   AoHJ26AHu7uZB/IO8KRhChkiimfEBom6   2023-08-30 11:39:43.999   Main      HTTPS://XDAG.ORG EQUAL
    02724431   nRTHG0EAu0+PA8ebzKPmYG3r7330G/BN   2023-08-30 11:38:39.999   Main      HTTPS://XDAG.ORG SOLO
    02724430   wP/n48EiAPgi6lVgZJPDJeWz8FKei8ds   2023-08-30 11:37:35.999   Main      HTTPS://XDAG.ORG SOLO 2
    02724429   pvGiDjz1y3/+msNhvd+ItuOxz9ljZNwJ   2023-08-30 11:36:31.999   Main      HTTPS://XDAG.ORG SOLO 2
    02724428   YQb2L97G2cfrw3fUFatI0bIVFBqUvgBb   2023-08-30 11:35:27.999   Main      HTTPS://XDAG.ORG EQUAL 2
    02724427   0mYGOhNI9HoaQkSnzNqi1toIH5FIY6PD   2023-08-30 11:34:23.999   Main      HTTPS://XDAG.ORG EQUAL
    02724426   htiEatRcljLQz+5TpkJom8wAWpDUluD4   2023-08-30 11:33:19.999   Main      HTTPS://XDAG.ORG EQUAL
    02724425   +5C/PJnsgX4HPf+hArteuuapj9NYkzDD   2023-08-30 11:32:15.999   Main      HTTPS://XDAG.ORG EQUAL
    02724424   CZGrJgrQz5DAUIcaOcFr/nbH93LGwQvs   2023-08-30 11:31:11.999   Main      HTTPS://XDAG.ORG EQUAL
    02724423   0LD7tYPM/YFvn5bGZrHXb0pQCLWkjs/k   2023-08-30 11:30:07.999   Main      HTTPS://XDAG.ORG EQUAL
    02724422   YLssHNicvfGB7smQSgJR9b99+lJHi86N   2023-08-30 11:29:03.999   Main      HTTPS://XDAG.ORG SOLO 2
    xdag> state
    Connected to the main network. Synchronizing from low to high.(没有同步完)
    xdag> account
    4rN1bDkkv3oXKF8PUpUZjVxi6wNdCTZ3T 20.000000000 XDAG
    xdag> help
        account     print first [SIZE] (20 by default) our addresses with their amounts
        address     address-  print extended info for the account corresponding to the address, page size 100
        balance     print balance of the address [ADDRESS] or total balance for all our addresses
        block       print extended info for the block corresponding to the address or hash [A]
        disconnect  disconnect all connections or specified miners
        exit        exit from app/script
        help        command help
        keygen      generate new private/public key pair and set it by default
        lastblocks  print latest [SIZE] (20 by default, max limit 100) main blocks
        mainblocks  print latest [SIZE] (20 by default, max limit 100) main blocks
        minedblocks print list of [SIZE] (20 by default) main blocks mined by current pool
        miners      for pool, print list of recent connected miners
        net         run transport layer command, try 'net --help'
        oldbalance  print max balance we can transfer
        state       print the program state
        stats       print statistics for loaded and all known blocks
        terminate   terminate both daemon and this program
        ttop        display and update sorted information about threads
        xfer        transfer [AMOUNT] XDAG to the address [ADDRESS]
        xfertonew   transfer the old balance to new address
    xdag> state
    Synchronized with the main network. Normal operation.(同步完成)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68

    curl命令

    # 获取最新高度
    curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[],\"id\":1}"
    {"jsonrpc":"2.0","id":1,"result":"2836571"}
    # 获取钱包地址余额
    curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBalance\",\"params\":[\"4rN1bDkkv3oXKF8PUpUZjVxi6wNdCTZ3T\"],\"id\":1}"
    {"jsonrpc":"2.0","id":1,"result":"20.000000000"}
    # curl判断是否同步完成
    curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_syncing\",\"params\":[],\"id\":1}"
    # 同步没完成
    {"jsonrpc":"2.0","id":1,"result":{"currentBlock":null,"highestBlock":null,"isSyncDone":false}}
    # 同步完成
    {"jsonrpc":"2.0","id":1,"result":{"currentBlock":"2837021","highestBlock":"2837021","isSyncDone":true}}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    更多文档详情

  • 相关阅读:
    LVS+KeepAlived高可用部署实战应用
    【数据结构】模拟实现string
    LeetCode 热题 HOT 100:滑动窗口专题
    LabVIEW开发多速率实时混合仿真
    VSCode搭建Django开发环境
    gitLab server version 13.12.1 is not supported
    Mybatis参数传递
    零基础如何入门渗透测试
    网络知识——局域网和交换机
    RK356x U-Boot研究所(命令篇)3.10 bidram与sysmem相关命令的作用
  • 原文地址:https://blog.csdn.net/baidu_38432732/article/details/134540221