Build a Mainnet node for Debian, Ubuntu, or MacOS
These directions are for a quick build of a mainnet server. Nothing is done here to harden the security of the server. Since the tezos code is complex and communicating with potentially malicious peers, consider that anything on the server could be exposed or exploited.
This procedure is thoroughly tested on Debian 9.4. It is reported to work on Ubuntu 18.04 and 16.04 as well; look for special notes below though. It also works on MacOS 10.13.5 if you skip directly to the step for installing opam.
These steps are reported to work on Raspberry Pi 3B and 3B+ running Ubuntu 18.04 as well. An external hard drive is required.
2018-08-31: Added libhidapi-dev as a system package dependency.
Login to new Debian or Ubuntu system and update its base packages. (In the following, replace "192.155.xxx.xxx" with the actual IP address of your server).
ssh firstname.lastname@example.org apt-get update apt-get dist-upgrade -y
Create a user account for building and running tezos. The
tezos is name is arbitrary; pick your favorite -- just don't build and run services as root. If you already have a user account you can use that instead. Note that the
make build-deps step requires sudo rights when it first runs, to install some system packages via apt-get.
adduser tezos adduser tezos sudo reboot ssh email@example.com
If you are on Ubuntu 16, do this to be able to install bubblewrap and latest version of git. Everyone else, ignore this.
sudo add-apt-repository ppa:ansible/bubblewrap sudo add-apt-repository ppa:git-core/ppa sudo apt-get update
Similarly, if you are on Debian 9, do this to upgrade git to version 2.18.0. You need the debian "stretch-backports" source enabled to do this. If the following command fails, see the "Add backports to your sources.list" section at https://backports.debian.org/Instructions/ and follow the steps there; then try this again.
sudo apt-get -t stretch-backports install git
If you are on Centos 7.5 some of the system package names are different. Use this instead of the
apt-get just below:
sudo yum install epel-release sudo yum install bzip2 screen wget rsync gcc m4 make unzip patch libev-devel libev hidapi-devel gmp-devel bubblewrap git
Install the system packages needed to start building tezos binaries. The actual build scripts will install more packages.
sudo apt-get install -y patch unzip make gcc m4 git g++ aspcud bubblewrap curl bzip2 rsync libev-dev libgmp-dev pkg-config libhidapi-dev
(If you're on MacOS, you can start here.)
Install OPAM utility needed to build the OCaml code. Version 2.0.0 or later of opam is required. See https://opam.ocaml.org/doc/Install.html for alternative installation steps.
Opam installation method 1:
If asked, just accept the default of installing to /usr/local/bin. Installing there depends on the 'tezos' user having sudo rights as we arranged above.
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
Opam installation method 2:
wget https://github.com/ocaml/opam/releases/download/2.0.0/opam-2.0.0-x86_64-linux sudo mv opam-2.0.0-x86_64-linux /usr/local/bin/opam sudo chmod a+x /usr/local/bin/opam
Opam installation method (Mac OS):
wget https://github.com/ocaml/opam/releases/download/2.0.0/opam-2.0.0-x86_64-darwin sudo mv opam-2.0.0-x86_64-darwin /usr/local/bin/opam sudo chmod a+x /usr/local/bin/opam echo "f25a98ff5a45bd2ad7ce1b9496503c505ca8cd38525dcd11be04b9203e54cbff /usr/local/bin/opam"|shasum -a 256 -c
Now that opam is installed, initialize it. When the following runs, allow it to update your .profile and, if asked, also allow to "add a hook to opam's init scripts".
opam init --bare eval $(opam env)
If you are running in the Windows 10 Linux Subsystem you may need to add
--disable-sandboxing to the call to
opam init above. Otherwise you may be blocked by
brwap errors as bubblewrap does not currently work in that environment.
Note that the
make build-deps step below builds a local opam environment within the build directory, so we no longer need to set up a switch as we did before.
Get the mainnet source code.
git clone -b mainnet https://gitlab.com/tezos/tezos.git cd tezos
Install OCaml dependencies (and some system package dependencies too). If prompted about installing the
depext package, agree. If this fails, see the Workaround section below. An error message about "No repository tezos found" is normal when running this step for the first time; you can ignore that error. If you see an error like "Could not update repository "tezos": Commit found, but unreachable: enable uploadpack.allowReachableSHA1InWant on server" then you need to start over and install a newer version of git. See above about upgrading git in Ubuntu 16 and Debian 9.
Compile the binaries. Since the build-deps step above created an _opam directory with an opam switch for tezos, update the environment again before compiling to be sure we've got the right opam configuration.
eval $(opam env) make
Configure the node identity. In the mainnet the "difficulty" used in generating the node identity must be at least 26. That is the default now in the
identity generate command.
./tezos-node identity generate 26.
Run the node. (I also like to run the node inside a
screen(1) session (without
&) so that the process persists in the foreground and I can detach and come back to it later in another ssh session.)\
nohup ./tezos-node run --rpc-addr 127.0.0.1:8732 &
The node will take a while to sync, bringing in the blockchain data from the peers. To see its progress you can run the following command which shows the head block known so far and will exit when the node is fully synced:
Look for the
timestamp value in the output from that. When that value gets to within a minute or so of the current date and time then your node is synced. The expected network/chain_id value is
It's possible to start up your node with a copy of the chain data that is (typically) just a few days old. See the directions at https://www.tzdutch.com/quicksync/
TL;DR Install the lz4 system package, then stop the node and do:
cd ~/.tezos-node mkdir old mv context store old curl http://quicksync.tzdutch.com/latest.tar.lz4 | lz4 -d | tar xf -
Then start tezos-node again as usual and it will sync the rest of the chain.
To activate a donation account
./tezos-client add address my_account <public key hash from donation PDF> ./tezos-client activate fundraiser account my_account with <activation key from verification site>
my_account name/alias above is arbitrary, but conventional.
Note: you can also import your private key info, but that is not necessary in order to claim the donation account:
./tezos-client import fundraiser secret key my_account
Also: if your goal is only to activate your Tezos account and claim the tez from the fundraiser, it’s much easier to just use stephenandrews online utility at https://stephenandrews.github.io/activatez/ .
Baking on Mainnet
See the Tezos baking howto by @dakk.
Workarounds when things won't build or run
In the top code directory, ~/tezos, run
eval $(opam env). Then try again.
eval $(opam env), do
opam update && opam upgrade. Then try again.
Sometimes it helps to remove the entire ~/.opam directory and start over again from the
opam init step. Slow, but it gives a clean start for OPAM packages. Note that if you are building alphanet or other from the same user, this also wipes out the OPAM context for that work too.
rm -rf ~/.opam
make build-deps step pins many packages to particular versions. If you want a clean start short of removing ~/.opam, you can remove all those pins:
opam pin list -s | xargs opam pin remove
If you encounter an error about the opam depext plugin not being installed, you can install it manually and try again. Also, it seems that the system
rsync package it needed for opam to be able install depext. Do
sudo apt-get install rsync if necessary and try again.
opam install depext
If you get 0 connections, verify that your node identity was built with sufficient difficulty:
./tezos-node identity check
Fix issue in macOS
make build-deps sometimes fails since it cannot build OCaml compiler. You may get the following error
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 [ocaml-base-compiler.4.08.1] found in cache <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 [ERROR] The compilation of ocaml-base-compiler failed at "/Users/ameten/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/Users/ameten/.opam/4.08.1 CC=cc ASPP=cc -c". ∗ installed base-bigarray.base ∗ installed base-threads.base ∗ installed base-unix.base #=== ERROR while compiling ocaml-base-compiler.4.08.1 =========================# # context 2.0.5 | macos/x86_64 | | https://opam.ocaml.org#b679cc38 # path ~/.opam/4.08.1/.opam-switch/build/ocaml-base-compiler.4.08.1 # command ~/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/Users/ameten/.opam/4.08.1 CC=cc ASPP=cc -c # exit-code 65 # env-file ~/.opam/log/ocaml-base-compiler-5420-ffb3fd.env # output-file ~/.opam/log/ocaml-base-compiler-5420-ffb3fd.out ### output ### # /Users/ameten/.opam/opam-init/hooks/sandbox.sh: line 9: cd: /Users/ameten/.ccache: No such file or directory # sandbox-exec: empty subpath pattern <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 ┌─ The following actions failed │ λ build ocaml-base-compiler 4.08.1 └─ ┌─ The following changes have been performed (the rest was aborted) │ ∗ install base-bigarray base │ ∗ install base-threads base │ ∗ install base-unix base └─ # Run eval $(opam env) to update the current shell environment Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] Y
Sandbox executable complains that there is not place to store compiler cache. You don't have
/Users/username/.ccache on your system.
ccache using your favourite package manager. Command for Homebrew:
brew install ccache
ccache is installed, but you don't have
/Users/username/.ccache, run the following command to create the directory:
When you have
/Users/username/.ccache you should be able to install OCaml compiler using
opam switch create 4.08.1
Once you have OCaml compiler in
opam, you should be able to run
make build-deps although it will install its own OCaml compiler.
To rebuild with the latest Mainnet code you can move or remove the "tezos" directory and start again from the
git clone step. As an alternative you can update in place as follows.
git fetch git reset --hard origin/mainnet git clean -dxf eval $(opam env) make build-deps make
Docker images: https://hub.docker.com/r/tezos/tezos/tags/
Docker script: https://gitlab.com/tezos/tezos/blob/mainnet/docs/introduction/howtoget.rst Copy to mainnet.sh and run as usual.
Korean version : https://blog.naver.com/justmustone/221310459511
Korean version : Raspberry Pi 3 https://blog.naver.com/justmustone/221310583691
Written by @fredcy with help from the tech chat room and others.