![Hive-in-a-box Logo](https://cdn.privex.io/img/posts/hive-in-a-box.png)
# Fresh install To become a witness without using MIRA, you'll require a server with at LEAST 64GB of RAM, 500GB disk (preferably SSD / NVMe), and a fast, reliable network. If you do not have a server which meets these requirements, you can order one from [Privex](privex.io) (you can even pay with HIVE/HBD!) I personally use @privex for my own witness as a Top 20. While I am the CEO of Privex, there are many other customers, including witnesses who use our servers for their witness nodes, seed nodes, RPC nodes and/or other projects. You're free to use any other server provider. I don't recommend trying to run a witness on your home internet, as it's likely not reliable enough for a witness. Be aware that certain server providers have poor networks or hardware, which may cause missed blocks, so you may be hopping around a few until you can find one that's suitable for a witness node. If you want to learn more about witnesses and what they do, check out my article: [here](https://peakd.com/witness-category/@someguy123/seriously-what-is-a-witness-why-should-i-care-how-do-i-become-one-answer) ### Shared memory note Right now, the minimum RAM requirement for non-MIRA witnesses is 64GB due to shared memory. This is because Hive stores information in a file called "shared_memory.bin" which is used similar to RAM. This file is around 58GB on HF23, and will continue to grow overtime. As this file continues to grow, you will need to increase the amount of RAM in your server. So it is better to have some room. ### Install hive-docker and dependencies First, we install some basic dependencies (assuming you're on Ubuntu/Debian). ``` sudo apt update sudo apt install git curl wget ``` Next, we install hive-docker (a line starting with a # is a comment, you don't need to paste them) ```bash git clone https://github.com/someguy123/hive-docker.git cd hive-docker # If you don't already have a docker installation, this will install it for you ./run.sh install_docker ``` After the install_docker command has finished, it's recommended to log out and back in again (e.g. close your SSH client and re-connect) to ensure that the shell correctly detects docker. Then, you can download and install the latest witness/seed docker image ``` # This downloads/updates the low-memory docker image for Hive ./run.sh install ``` If you are a witness, you need to adjust the configuration as needed e.g. witness name, private key, logging config, turn off p2p-endpoint etc. If you're running a seed, then don't worry about the config, it will just work and you can skip the signing key/config section ### Generating a signing key For witnesses, you'll need to generate a signing key first. You can use the remote wallet for this. Open the wallet using a public server with the following command: ``` ./run.sh remote_wallet ``` **Note: you may receive an error such as "timeout" or "invalid http status". This is normal, it's usually due to a server in the Privex load balancer having temporary problems.** **Just run the command again a few times until it connects (you'll see new>>> or locked>>>)** Create a key pair for your witness. ``` suggest_brain_key ```
![Screenshot of cli_wallet suggest_brain_key command](https://cdn.privex.io/img/posts/hive-suggest-brainkey.png)
You should get something similar to this: ``` { "brain_priv_key": "GOCART VINCENT PHOTIC IRON OUTHIT UNGLOBE SICCA LOP TASKIT BOOSTER WINDED SPRY SACKBUT UNICE WELL RUBELLE", "wif_priv_key": "5J1Wn41BbSS4L83N9n7P5nmMSVg9uaWfVySnd363TvyhWPzU2e9", "pub_key": "STM7iCEkCR261F7CeBCsmpE1RcW8hnR5pZYKCFbuVqe5HSJ41YewE" } ``` **Put the keys in Notepad or something similar for the moment so you don't lose them.** Press CTRL-D to exit the wallet. ### Setting up your config Now, to set your witness name and private key. You can use `nano` (a simple text editor on Linux) for this. ``` nano data/witness_node_data_dir/config.ini ``` If you are running a witness, you'll want to change one of the first lines in the file to disable the seed. ``` # Endpoint for P2P node to listen on p2p-endpoint = 0.0.0.0:2001 ``` Simply place a # (hash sign) at the start of the p2p-endpoint line. This will disable the seed. Example: ``` # Endpoint for P2P node to listen on #p2p-endpoint = 0.0.0.0:2001 ``` Now to add your witness settings. Scroll down the file (use the up/down arrows, or page up/down) until you see something like this: ``` # Percent of witnesses (0-99) that must be participating in order to produce blocks required-participation = 33 # name of witness controlled by this node (e.g. initwitness ) # witness = # name of miner and its private key (e.g. ["account","WIF PRIVATE KEY"] ) # miner = # Number of threads to use for proof of work mining # mining-threads = # WIF PRIVATE KEY to be used by one or more witnesses or miners # private-key = ```
![Screenshot of witness config.ini](https://cdn.privex.io/img/posts/hive-witness-config.png)
You'll want to uncomment (remove the # from the start) the `witness =` line, and the `private-key =` line. Grab your public/private key that you saved earlier into notepad (or other similar app). Then, similar to below, add your witness' name in quotes, e.g. "someguy123" in front of the `witness =`, and your private key (without quotes) in front of the `private-key =` line. To save you time in the future, it can be useful to place your public signing key in a comment above your private key (see example) Example: ``` # name of witness controlled by this node (e.g. initwitness ) witness = "someguy123" # name of miner and its private key (e.g. ["account","WIF PRIVATE KEY"] ) # miner = # Number of threads to use for proof of work mining # mining-threads = # WIF PRIVATE KEY to be used by one or more witnesses or miners # public key: STM7iCEkCR261F7CeBCsmpE1RcW8hnR5pZYKCFbuVqe5HSJ41YewE private-key = 5J1Wn41BbSS4L83N9n7P5nmMSVg9uaWfVySnd363TvyhWPzU2e9 ``` Now (assuming you're using nano) press CTRL-X, and press the y key when it asks if you would like to save. ### Environment settings If you're already comfortable with Linux, and want to play around with settings for hive-docker you may want to consider setting up a .env file, see the [README for more information](https://github.com/someguy123/hive-docker) Otherwise, let's continue. The defaults are generally fine for most people. ### Setting up shared memory, swap settings, and downloading the blockchain At this point you should have: - installed hive-in-a-box - installed docker (through the run.sh command) - downloaded and installed the Hive docker container - set up your witness configuration Your witness is almost ready. Just a few more small things. You'll need to set the shared memory size (use sudo if not logged in as root). 64 gigabytes is recommended (64G). Please be aware that the shared memory size changes constantly. ``` sudo ./run.sh shm_size 64G ``` You'll also want to adjust your "swappiness". This is a setting which tells Linux how much it should use swap (virtual memory on your disk. very slow). You'll want to set this to 1, which means "don't use the swap unless it's absolutely necessary". This helps to prevent missed blocks due to excessive swapping despite plenty of free RAM. ``` # To persist on reboot, place 'vm.swappiness=1' in /etc/sysctl.conf sudo sysctl -w vm.swappiness=1 ``` Now that you've configured your server, it's recommended to download the block log, as replays can be faster than p2p download. ``` ./run.sh dlblocks ``` ![Screenshot of run.sh dlblocks command](https://cdn.privex.io/img/posts/hive-dlblocks.png) ### Almost ready! Once this is done, you should be ready to start your server. The `replay` command will start `steemd` (the binary is still called `steemd` for Hive) in docker, and begin replaying the blockchain which was downloaded to create a block index, and the shared_memory file. ``` ./run.sh replay ``` You can check the status with the `logs` command. ``` ./run.sh logs ``` Assuming you did everything correctly, you should see something like this: ``` ------------------------------------------------------ STARTING HIVE NETWORK ------------------------------------------------------ initminer public key: STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX chain id: 0000000000000000000000000000000000000000000000000000000000000000 blockchain version: 0.23.0 ------------------------------------------------------ 2393837ms main.cpp:121 main ] Backtrace on segfault is enabled. 2393837ms chain_plugin.cpp:405 plugin_startup ] Starting chain with shared_file_size: 53687091200 bytes 2393837ms chain_plugin.cpp:483 plugin_startup ] Replaying blockchain on user request. 2393837ms database.cpp:185 reindex ] Reindexing Blockchain 2396435ms block_log.cpp:142 open ] Log is nonempty 2396435ms block_log.cpp:151 open ] Index is nonempty 2396435ms database.cpp:193 reindex ] Replaying blocks... ``` Please be aware that this can take many hours depending on your disk speed and CPU. In some cases it can take up to 24 hours. You can press CTRL-C to exit the logs, or just leave it if you want to watch it replay. ### After you've replayed Once you see something which looks like this, it means your server is now ready to go: ``` 1299055ms th_a application.cpp:507 handle_block ] Got 14 transactions on block 12928269 by pharesim -- latency: 55 ms 1302427ms th_a application.cpp:507 handle_block ] Got 18 transactions on block 12928270 by xeldal -- latency: 426 ms 1305291ms th_a application.cpp:507 handle_block ] Got 26 transactions on block 12928271 by arhag -- latency: 291 ms 1308045ms th_a application.cpp:507 handle_block ] Got 20 transactions on block 12928272 by pfunk -- latency: 45 ms 1311092ms th_a application.cpp:507 handle_block ] Got 23 transactions on block 12928273 by bhuz -- latency: 92 ms ``` Go to your profile: - https://wallet.hive.blog/@yourusername/permissions - https://peakd.com/@yourusername/permissions - (for the links, you need to edit the @yourusername part) Click Wallet, then Permissions. Next to "Active Key" you should see "Reveal". Click that button and log in. Then press "Show private key", to reveal it. Make sure it begins with a "5". Copy the key. Now open the wallet with: ``` ./run.sh wallet ``` ![Screenshot of Hive Wallet active key page](https://cdn.privex.io/img/posts/hive-wallet-activekey.png) Set a password, unlock the wallet with the same password, then import your ACTIVE private key from wallet.hive.blog / Peakd (NOT the one in notepad): ``` set_password "hunter2" unlock "hunter2" import_key 5somethingprivatekey ``` Finally, we can update/create the witness on the network. Replace the STMxxxx key with the public key you saved earlier in notepad (or if you wrote it as a comment in your config file, you can open that and get it from there), and replace YOURNAME with your witness name on Hive. ``` update_witness "YOURNAME" "https://hive.blog/witness-category/@YOURNAME/my-witness-thread" "STMxxxxxxx" {"account_creation_fee":"3.000 HIVE","maximum_block_size":65536,"sbd_interest_rate":0} true ``` # Congratulations, your witness should now be working, and you can begin getting votes and producing blocks ### Other useful information You may want to persist the /dev/shm size (shared memory) across reboots. To do this, you can edit `/etc/fstab`, please be very careful, as any mistakes in this file will cause your system to become unbootable. (**if you are not comfortable with linux, please don't try this as you may break your server**). Simply add this to the bottom of the file on a new line. Be sure not to damage any other lines in the file. Adjust "64G" to whatever size you would like /dev/shm to be. ``` tmpfs /dev/shm tmpfs nodev,nosuid,size=64G 0 0 ``` See [the README](https://github.com/someguy123/hive-docker) for more advanced options. # Upgrading steem-docker to hive-docker If you have an existing `steem-docker` installation, you can convert it into a `hive-docker` installation by following the below steps. ## Updating your Git repository Use `git remote set-url` to change your steem-docker installation to track my `hive-docker` repository. Then `git fetch` to download any updates, checkout master, and `git pull` to update to `hive-docker`. ``` ~/steem-docker $ git remote set-url origin https://github.com/Someguy123/hive-docker.git ~/steem-docker $ git fetch ~/steem-docker $ git checkout master ~/steem-docker $ git pull ``` To ensure `hive-docker` always uses the Hive network, add `NETWORK=hive` to your `.env` file ```shell echo "NETWORK=hive" >> .env ``` Download the Hive HF23 docker image using this command. ``` ./run.sh install ``` ## If you were previously running Steem, you'll need to replace your blockchain and state files Delete your blockchain files and shared memory files using the `clean` command: ``` ./run.sh clean ``` ![Screenshot of run.sh clean command](https://cdn.privex.io/img/posts/hive-clean.png) Download a fresh block_log: ``` ./run.sh dlblocks ``` ![Screenshot of run.sh dlblocks command](https://cdn.privex.io/img/posts/hive-dlblocks.png) ### Now for the slow part - replaying When upgrading from Steem to Hive, you'll need to replay. To replay your witness, do the following (this will shutdown and remove the Steem software, and start a Hive one in replay mode) ``` ./run.sh stop ./run.sh replay ``` You can check the status of the replay with the logs command ``` ./run.sh logs ``` Note: the command now automatically updates in realtime. to exit the logs press CTRL-C If all is well, you'll see it replaying on v0.23.0 (or whatever version is out by the time you read this): ``` ------------------------------------------------------ STARTING HIVE NETWORK ------------------------------------------------------ initminer public key: STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX chain id: 0000000000000000000000000000000000000000000000000000000000000000 blockchain version: 0.23.0 ------------------------------------------------------ 2393837ms main.cpp:121 main ] Backtrace on segfault is enabled. 2393837ms chain_plugin.cpp:405 plugin_startup ] Starting chain with shared_file_size: 53687091200 bytes 2393837ms chain_plugin.cpp:483 plugin_startup ] Replaying blockchain on user request. 2393837ms database.cpp:185 reindex ] Reindexing Blockchain 2396435ms block_log.cpp:142 open ] Log is nonempty 2396435ms block_log.cpp:151 open ] Index is nonempty 2396435ms database.cpp:193 reindex ] Replaying blocks... ``` Once it's replayed (may take 3 or more hours), you'll see the standard "got x transactions on block y". ``` 1668107ms p2p_plugin.cpp:210 handle_block ] Got 54 transactions on block 25299003 by cervantes -- latency: 107 ms 1671090ms p2p_plugin.cpp:210 handle_block ] Got 36 transactions on block 25299004 by blocktrades -- latency: 90 ms 1674098ms p2p_plugin.cpp:210 handle_block ] Got 28 transactions on block 25299005 by roelandp -- latency: 98 ms ``` If you see this, you can now re-enable this server :) You're successfully upgraded to 0.23.0 (or higher). For future HF23 releases, it will now be as simple as `./run.sh install && ./run.sh restart`, but as always, be careful, always assume a replay may be needed. Test on your backup, or disable your witness before attempting to update. To see if I've released a new version of the docker image and haven't made a post yet, just check my docker hub: https://hub.docker.com/r/someguy123/hive/tags/ ---
![](https://i.giphy.com/media/l378lvuErndt84HII/giphy.gif)
GIF Avatar by @stellabelle --- ### Do you like what I'm doing for Hive? [Vote for me to be a witness](https://wallet.hive.blog/~witnesses) - every vote counts. ### Don't forget to follow me for more like this. --- Are you looking for a new server provider? My company @privex offers highly-reliable and affordable dedicated and virtual servers for HIVE, HBD, EOS, Monero, DOGE, LTC, and BTC! Check out our website at https://www.privex.io Join the Privex discord at: https://invite.gg/privex ---

See: How to set up a Hive Witness or Seed node (non-MIRA) / Upgrade from Steem-Docker to Hive-Docker by @someguy123