Cách 1
Ubuntu - User
- sudo adduser cardano
- sudo usermod -aG sudo cardano
- sudo su – cardano
- sudo whoami
- Tạo user
- Thêm quyền cho user
- Đăng nhập
- Tra cứu quyền hạn của user
Cài các tool cần thiết cho Ubuntu
- sudo apt-get update -y
- sudo apt-get upgrade -y
- 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
- export LD_LIBRARY_PATH=”/usr/local/lib:$LD_LIBRARY_PATH”
- export PKG_CONFIG_PATH=”/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH”
Cabal - GHC
update packages
- sudo apt-get update -y
- sudo apt-get upgrade -y
- 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.
- mkdir $HOME/git
- cd $HOME/git
- git clone https://github.com/input-output-hk/libsodium
- cd libsodium
git checkout 66f017f1
- ./autogen.sh
- ./configure
- make
- sudo make install
Install Cabal.
- cd
- wget https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
- tar -xf cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
- rm cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz cabal.sig
- mkdir -p $HOME/.local/bin
- mv cabal $HOME/.local/bin/
Install GHC.
- wget https://downloads.haskell.org/~ghc/8.6.5/ghc-8.6.5-x86_64-deb9-linux.tar.xz
- tar -xf ghc-8.6.5-x86_64-deb9-linux.tar.xz
- rm ghc-8.6.5-x86_64-deb9-linux.tar.xz
- cd ghc-8.6.5
- ./configure
- sudo make install
Update PATH to include Cabal and GHC
- echo PATH=”$HOME/.local/bin:$PATH” >> $HOME/.bashrc
- echo export LD_LIBRARY_PATH=”/usr/local/lib:$LD_LIBRARY_PATH” >> $HOME/.bashrc
- echo export NODE_HOME=$HOME/XXXXX >> $HOME/.bashrc
- echo export NODE_CONFIG=mainnet>> $HOME/.bashrc
- echo export NODE_BUILD_NUM=$(curl YYYYY | grep -e “build” | sed ‘s/.*build\/\([0-9]*\)\/download.*/\1/g’) >> $HOME/.bashrc
- 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
- cabal update
- cabal -V
- ghc -V
Build the node from source code
Download source code and switch to the latest tag
- cd $HOME/git
- git clone https://github.com/input-output-hk/cardano-node.git
- cd cardano-node
- git fetch –all
- git checkout tags/1.21.1
Update the cabal config, project settings, and reset build folder.
- echo -e “package cardano-crypto-praos\n flags: -external-libsodium-vrf” > cabal.project.local
- sed -i $HOME/.cabal/config -e “s/overwrite-policy:/overwrite-policy: always/g”
- 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)
- cabal build cardano-cli cardano-node
Copy cardano-cli and cardano-node files into bin directory.
- sudo cp $(find $HOME/git/cardano-node/dist-newstyle/build -type f -name “cardano-cli”) /usr/local/bin/cardano-cli
- 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.
- cardano-node version
- 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.
- mkdir $NODE_HOME
- cd $NODE_HOME
- wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-byron-genesis.json
- wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-topology.json
- wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-shelley-genesis.json
- 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”
- sed -i ${NODE_CONFIG}-config.json \
-e “s/SimpleView/LiveView/g” \
-e “s/TraceBlockFetchDecisions\”: false/TraceBlockFetchDecisions\”: true/g”
Update .bashrc shell variables.
- echo export CARDANO_NODE_SOCKET_PATH=”$NODE_HOME/db/socket” >> $HOME/.bashrc
- 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
- cat > $NODE_HOME/${NODE_CONFIG}-topology.json << EOF
{
“Producers”: [
{
“addr”: “34.69.223.8”,
“port”: 6000,
“valency”: 1
}
]
}
EOF
Create startup scripts
- cat > $NODE_HOME/startBlockProducingNode.sh << EOF
- #!/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
- 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
- sudo adduser cardano
- sudo usermod -aG sudo cardano
- sudo su – cardano
- sudo whoami
Cài đặt cơ bản
- mkdir “$HOME/tmp”; cd “$HOME/tmp”
- sudo apt -y install curl
- curl -sS -o prereqs.sh https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/prereqs.sh
- chmod 755 prereqs.sh
- ./prereqs.sh
- . “${HOME}/.bashrc”
Node and CLI
- cd ~/git
- git clone https://github.com/input-output-hk/cardano-node
- cd cardano-node
Build Cardano Node (Chạy từng dòng riêng rẽ)
- git fetch –tags –all
- git checkout 1.21.1
- $CNODE_HOME/scripts/cabal-build-all.sh -o
(Chạy khá lâu)
Kiểm tra lại
- cardano-cli version
- cardano-node version
Start node
- cd $CNODE_HOME/scripts
- ./cnode.sh
Deploy as a systemd service
- cd $CNODE_HOME/scripts
- ./deploy-as-systemd.sh
Khởi động hoặc dừng
- sudo systemctl start cnode.service
- sudo systemctl stop cnode.service
- sudo systemctl restart cnode.service
CNTool
CNTool
- cd /opt/cardano/cnode/scripts/
- ./cntools.sh
tmux
- sudo apt install tmux
- cd ~/cnode/scripts/
- ./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!
Các bài viết liên quan:
- Cập nhật tiến độ thay đổi các tham số tác động tới mức độ phi tập trung của mạng lưới Cardano.
- IOHK đã ký hợp đồng với Runtime Verification và lộ trình phát hành Goguen vào cuối tháng 10
- Vì sao Marlowe của Cardano sẽ tốt cho DeFi hơn là Solidity của Ethereum?
- Bảng tính thời điểm các Epoch
- Devnets: cầu nối Cardano với cộng đồng các lập trình viên