Reference site
Installing cardano-node and cardano-cli from source | Cardano Developer Portal
# Begin with updating and upgrading the system packages
sudo apt update
sudo apt upgrade -y
# Install necessary software
sudo apt install git jq bc make automake 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
# Cabal
sudo apt-get -y install pkg-config libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev build-essential curl libgmp-dev libffi-dev libncurses-dev libtinfo5
curl --proto '=https' --tlsv1.2 -sSf <https://get-ghcup.haskell.org> | sh
# ghcup(v0.1.19.2)/ghc/cabal
cd $HOME
source .bashrc
ghcup upgrade
ghcup install ghc 8.10.7
ghcup set ghc 8.10.7
ghcup install cabal 3.8.1.0
ghcup set cabal 3.8.1.0
# libsodium
mkdir -p $HOME/cardano-src
cd $HOME/cardano-src
git clone <https://github.com/input-output-hk/libsodium>
cd libsodium
git checkout dbb48cc
./autogen.sh
./configure
make
sudo make install
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
# secp256k1
cd $HOME/cardano-src
git clone <https://github.com/bitcoin-core/secp256k1>
cd secp256k1
git checkout ac83be33
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install
sudo ldconfig
# blst
mkdir -p ~/git && cd ~/git
git clone <https://github.com/supranational/blst>
cd blst
git checkout v0.3.10
./build.sh
cat > libblst.pc << EOF
prefix=/usr/local
exec_prefix=\\${prefix}
libdir=\\${exec_prefix}/lib
includedir=\\${prefix}/include
Name: libblst
Description: Multilingual BLS12-381 signature library
URL: <https://github.com/supranational/blst>
Version: 0.3.10
Cflags: -I\\${includedir}
Libs: -L\\${libdir} -lblst
EOF
sudo cp libblst.pc /usr/local/lib/pkgconfig/
sudo cp bindings/blst_aux.h bindings/blst.h bindings/blst.hpp /usr/local/include/
sudo cp libblst.a /usr/local/lib
sudo chmod u=rw,go=r /usr/local/{lib/{libblst.a,pkgconfig/libblst.pc},include/{blst.{h,hpp},blst_aux.h}}
# Clone the Cardano node repository
cd $HOME/cardano-src
git clone <https://github.com/input-output-hk/cardano-node.git>
cd cardano-node
git fetch --all --recurse-submodules --tags
git checkout tags/8.7.3
#
cabal configure --with-compiler=ghc-8.10.7
#
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.10.4
# Building the node
cabal update
cabal build all
mkdir -p $HOME/.local/bin
cp -p "$(./scripts/bin-path.sh cardano-node)" $HOME/.local/bin/
cp -p "$(./scripts/bin-path.sh cardano-cli)" $HOME/.local/bin/
cardano-cli --version
cardano-node --version
## cardano-cli 8.17.0.0 - linux-x86_64 - ghc-8.10
## git rev a4a8119b59b1fbb9a69c79e1e6900e91292161e7
## cardano-node 8.7.3 - linux-x86_64 - ghc-8.10
## git rev a4a8119b59b1fbb9a69c79e1e6900e91292161e7
# path
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/cardano-my-node >> $HOME/.bashrc
echo export NODE_CONFIG=mainnet>> $HOME/.bashrc
echo export NODE_BUILD_NUM=$(curl <https://hydra.iohk.io/job/Cardano/iohk-nix/cardano-deployment/latest-finished/download/1/index.html> | grep -e "build" | sed 's/.*build\\/\\([0-9]*\\)\\/download.*/\\1/g') >> $HOME/.bashrc
echo export CARDANO_NODE_SOCKET_PATH="$NODE_HOME/db/socket" >> $HOME/.bashrc
source $HOME/.bashrc
# Cardano 노드 설정
mkdir $NODE_HOME
cd $NODE_HOME
curl -o config.json <https://book.world.dev.cardano.org/environments/mainnet/config.json>
curl -o topology.json <https://book.world.dev.cardano.org/environments/mainnet/topology.json>
curl -o byron-genesis.json <https://book.world.dev.cardano.org/environments/mainnet/byron-genesis.json>
curl -o shelley-genesis.json <https://book.world.dev.cardano.org/environments/mainnet/shelley-genesis.json>
curl -o alonzo-genesis.json <https://book.world.dev.cardano.org/environments/mainnet/alonzo-genesis.json>
curl -o conway-genesis.json <https://book.world.dev.cardano.org/environments/mainnet/conway-genesis.json>
sed -i config.json \\
-e "s/TraceBlockFetchDecisions\\": false/TraceBlockFetchDecisions\\": true/g"
# mainnet-topology.json
# Block Node
cat > $NODE_HOME/${NODE_CONFIG}-topology.json << EOF
{
"Producers": [
{
"addr": "my relay public ip",
"port": 6001,
"valency": 1
}
]
}
EOF
# Relay Node
cat > $NODE_HOME/${NODE_CONFIG}-topology.json << EOF
{
"Producers": [
{
"addr": "my block public ip",
"port": 6001,
"valency": 1
},
{
"addr": "relays-new.cardano-mainnet.iohk.io",
"port": 3001,
"valency": 2
}
]
}
EOF
# start up script
# block
cat > $NODE_HOME/startBlockProducingNode.sh << EOF
#!/bin/bash
DIRECTORY=$NODE_HOME
PORT=6001
HOSTADDR=0.0.0.0
TOPOLOGY=\\${DIRECTORY}/${NODE_CONFIG}-topology.json
DB_PATH=\\${DIRECTORY}/db
SOCKET_PATH=\\${DIRECTORY}/db/socket
CONFIG=\\${DIRECTORY}/config.json
/usr/local/bin/cardano-node run --topology \\${TOPOLOGY} --database-path \\${DB_PATH} --socket-path \\${SOCKET_PATH} --host-addr \\${HOSTADDR} --port \\${PORT} --config \\${CONFIG}
EOF
chmod +x $NODE_HOME/startBlockProducingNode.sh
# relay
cat > $NODE_HOME/startRelayNode.sh << EOF
#!/bin/bash
DIRECTORY=$NODE_HOME
PORT=6001
HOSTADDR=0.0.0.0
TOPOLOGY=\\${DIRECTORY}/${NODE_CONFIG}-topology.json
DB_PATH=\\${DIRECTORY}/db
SOCKET_PATH=\\${DIRECTORY}/db/socket
CONFIG=\\${DIRECTORY}/config.json
/usr/local/bin/cardano-node run --topology \\${TOPOLOGY} --database-path \\${DB_PATH} --socket-path \\${SOCKET_PATH} --host-addr \\${HOSTADDR} --port \\${PORT} --config \\${CONFIG}
EOF
chmod +x $NODE_HOME/startRelayNode.sh
# systemd
# block
cat > $NODE_HOME/cardano-node.service << EOF
# The Cardano node service (part of systemd)
# file: /etc/systemd/system/cardano-node.service
[Unit]
Description = Cardano node service
Wants = network-online.target
After = network-online.target
[Service]
User = ${USER}
Type = simple
WorkingDirectory= ${NODE_HOME}
ExecStart = /bin/bash -c '${NODE_HOME}/startBlockProducingNode.sh'
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=2
LimitNOFILE=32768
Restart=always
RestartSec=5
SyslogIdentifier=cardano-node
[Install]
WantedBy = multi-user.target
EOF
# relay
cat > $NODE_HOME/cardano-node.service << EOF
# The Cardano node service (part of systemd)
# file: /etc/systemd/system/cardano-node.service
[Unit]
Description = Cardano node service
Wants = network-online.target
After = network-online.target
[Service]
User = ${USER}
Type = simple
WorkingDirectory= ${NODE_HOME}
ExecStart = /bin/bash -c '${NODE_HOME}/startRelayNode.sh'
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=2
LimitNOFILE=32768
Restart=always
RestartSec=5
SyslogIdentifier=cardano-node
[Install]
WantedBy = multi-user.target
EOF
sudo mv $NODE_HOME/cardano-node.service /etc/systemd/system/cardano-node.service
sudo chmod 644 /etc/systemd/system/cardano-node.service
sudo systemctl daemon-reload
sudo systemctl enable cardano-node
# run
sudo systemctl start cardano