Cách 1
Ubuntu - User
  1. sudo adduser cardano
  2. sudo usermod -aG sudo cardano
  3. sudo su – cardano
  4. sudo whoami

  1. Tạo user
  2. Thêm quyền cho user
  3. Đăng nhập
  4. Tra cứu quyền hạn của user

Cài các tool cần thiết cho Ubuntu

  1. sudo apt-get update -y
  2. sudo apt-get upgrade -y
  3. sudo apt-get -y install python3 build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev systemd libsystemd-dev libsodium-dev zlib1g-dev yarn make g++ jq libncursesw5 libtool autoconf git tmux htop nload curl unzip
  4. export LD_LIBRARY_PATH=”/usr/local/lib:$LD_LIBRARY_PATH”
  5. export PKG_CONFIG_PATH=”/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH”
Cabal - GHC

update packages

  1. sudo apt-get update -y
  2. sudo apt-get upgrade -y
  3. sudo apt-get install git make tmux rsync htop curl build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf -y

Install Libsodium.

  1. mkdir $HOME/git
  2. cd $HOME/git
  3. git clone https://github.com/input-output-hk/libsodium
  4. cd libsodium
    git checkout 66f017f1
  5. ./autogen.sh
  6. ./configure
  7. make
  8. sudo make install

Install Cabal.

  1. cd
  2. wget https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
  3. tar -xf cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
  4. rm cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz cabal.sig
  5. mkdir -p $HOME/.local/bin
  6. mv cabal $HOME/.local/bin/

Install GHC.

  1. wget https://downloads.haskell.org/~ghc/8.6.5/ghc-8.6.5-x86_64-deb9-linux.tar.xz
  2. tar -xf ghc-8.6.5-x86_64-deb9-linux.tar.xz
  3. rm ghc-8.6.5-x86_64-deb9-linux.tar.xz
  4. cd ghc-8.6.5
  5. ./configure
  6. sudo make install

Update PATH to include Cabal and GHC

  1. echo PATH=”$HOME/.local/bin:$PATH” >> $HOME/.bashrc
  2. echo export LD_LIBRARY_PATH=”/usr/local/lib:$LD_LIBRARY_PATH” >> $HOME/.bashrc
  3. echo export NODE_HOME=$HOME/XXXXX >> $HOME/.bashrc
  4. echo export NODE_CONFIG=mainnet>> $HOME/.bashrc
  5. echo export NODE_BUILD_NUM=$(curl YYYYY | grep -e “build” | sed ‘s/.*build\/\([0-9]*\)\/download.*/\1/g’) >> $HOME/.bashrc
  6. source $HOME/.bashrc

Ghi chú thêm, đây là những dữ liệu sẽ phải thay đổi

  • XXXX chính là đường dẫn đến thư mục chính cài note: /cardano-node
  • YYYY là đường link chính thức tại https://hydra.iohk.io/job/Cardano/iohk-nix/cardano-deployment/latest-finished/download/1/index.html

Update cabal and verify

  1. cabal update
  2. cabal -V
  3. ghc -V

 

Build the node from source code

Download source code and switch to the latest tag

  1. cd $HOME/git
  2. git clone https://github.com/input-output-hk/cardano-node.git
  3. cd cardano-node
  4. git fetch –all
  5. git checkout tags/1.21.1

Update the cabal config, project settings, and reset build folder.

  1. echo -e “package cardano-crypto-praos\n flags: -external-libsodium-vrf” > cabal.project.local
  2. sed -i $HOME/.cabal/config -e “s/overwrite-policy:/overwrite-policy: always/g”
  3. rm -rf $HOME/git/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.6.5

Build the cardano-node from source code (mất thời gian nhiều)

  1. cabal build cardano-cli cardano-node

Copy cardano-cli and cardano-node files into bin directory.

  1. sudo cp $(find $HOME/git/cardano-node/dist-newstyle/build -type f -name “cardano-cli”) /usr/local/bin/cardano-cli
  2. sudo cp $(find $HOME/git/cardano-node/dist-newstyle/build -type f -name “cardano-node”) /usr/local/bin/cardano-node

 

Verify your cardano-cli and cardano-node are the expected versions.

  1. cardano-node version
  2. cardano-cli version

Cài đặt Cardano nodes

Configure the nodes

Here you’ll grab the config.json, genesis.json, and topology.json files needed to configure your node.

  1. mkdir $NODE_HOME
  2. cd $NODE_HOME
  3. wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-byron-genesis.json
  4. wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-topology.json
  5. wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-shelley-genesis.json
  6. wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-config.json

Run the following to modify config.json and
• update ViewMode to “LiveView”
• update TraceBlockFetchDecisions to “true”

  1. sed -i ${NODE_CONFIG}-config.json \
    -e “s/SimpleView/LiveView/g” \
    -e “s/TraceBlockFetchDecisions\”: false/TraceBlockFetchDecisions\”: true/g”

Update .bashrc shell variables.

  1. echo export CARDANO_NODE_SOCKET_PATH=”$NODE_HOME/db/socket” >> $HOME/.bashrc
  2. source $HOME/.bashrc

 

Block-producer node

A block producer node will be configured with various key-pairs needed for block generation (cold keys, KES hot keys and VRF hot keys). It can only connect to its relay nodes.
A relay node will not be in possession of any keys and will therefore be unable to produce blocks. It will be connected to its block-producing node, other relays and external nodes.


Configure the block-producer node

  1. cat > $NODE_HOME/${NODE_CONFIG}-topology.json << EOF
    {
    “Producers”: [
    {
    “addr”: “34.69.223.8”,
    “port”: 6000,
    “valency”: 1
    }
    ]
    }
    EOF

Create startup scripts

  1. cat > $NODE_HOME/startBlockProducingNode.sh << EOF
  2. #!/bin/bash
    DIRECTORY=\$NODE_HOME
    PORT=6000
    HOSTADDR=0.0.0.0
    TOPOLOGY=\${DIRECTORY}/${NODE_CONFIG}-topology.json
    DB_PATH=\${DIRECTORY}/db
    SOCKET_PATH=\${DIRECTORY}/db/socket
    CONFIG=\${DIRECTORY}/${NODE_CONFIG}-config.json
    cardano-node run –topology \${TOPOLOGY} –database-path \${DB_PATH} –socket-path \${SOCKET_PATH} –host-addr \${HOSTADDR} –port \${PORT} –config \${CONFIG}
    EOF

  1. Start the nodes
    cd $NODE_HOME
    chmod +x startBlockProducingNode.sh
    ./startBlockProducingNode.sh
Cách 2
Ubuntu - User

Tạo và phân quyền User

  1. sudo adduser cardano
  2. sudo usermod -aG sudo cardano
  3. sudo su – cardano
  4. sudo whoami

Cài đặt cơ bản

  1. mkdir “$HOME/tmp”; cd “$HOME/tmp”
  2. sudo apt -y install curl
  3. curl -sS -o prereqs.sh https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/prereqs.sh
  4. chmod 755 prereqs.sh
  5. ./prereqs.sh
  6. . ${HOME}/.bashrc”
Node and CLI
  1. cd ~/git
  2. git clone https://github.com/input-output-hk/cardano-node
  3. cd cardano-node

Build Cardano Node (Chạy từng dòng riêng rẽ)

  1. git fetch –tags –all
  2. git checkout 1.21.1
  3. $CNODE_HOME/scripts/cabal-build-all.sh -o

(Chạy khá lâu)


Kiểm tra lại

  1. cardano-cli version 
  2. cardano-node version

Start node

  1. cd $CNODE_HOME/scripts
  2. ./cnode.sh

Deploy as a systemd service

  1. cd $CNODE_HOME/scripts
  2. ./deploy-as-systemd.sh

Khởi động hoặc dừng

  1. sudo systemctl start cnode.service
  2. sudo systemctl stop cnode.service
  3. sudo systemctl restart cnode.service
CNTool

CNTool

  1. cd /opt/cardano/cnode/scripts/
  2. ./cntools.sh

tmux

  1. sudo apt install tmux
  2. cd ~/cnode/scripts/
  3. ./start_all.sh
Bổ trợ thêm
Bảo mật
CNTool

Hãy chọn pool FIMI để ủng hộ nguồn lực cho chúng tôi tiếp tục phục vụ cộng đồng!