redoules.github.io/cryptocurrencies/Installing_bitcoind_on_raspberry_pi.html
redoules b2a2d71169 added an article
added an article on extanding pandas datatypes
2018-12-24 18:25:16 +01:00

335 lines
16 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Data Science for Political and Social Phenomena">
<meta name="author" content="Guillaume Redoulès">
<link rel="icon" href="../favicon.ico">
<title>Installing bitcoind on raspberry pi - Cryptocurrencies</title>
<!-- JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
</script>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
<!-- Custom styles for this template -->
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<meta name="tags" content="Bitcoin" />
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
</div>
<div class="navbar-collapse collapse" id="searchbar">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="../pages/about.html">About Guillaume</a></li>
<li><a href="https://github.com/redoules">GitHub</a></li>
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="..#Blog">Blog</a></li>
<li><a href="..#Python">Python</a></li>
<li><a href="..#Bash">Bash</a></li>
<li><a href="..#SQL">SQL</a></li>
<li><a href="..#Mathematics">Mathematics</a></li>
<li><a href="..#Machine_Learning">Machine Learning</a></li>
<li><a href="..#Projects">Projects</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
</ul>
</li>
<!--<li class="dropdown">
<a href="../feeds/blog.rss.xml">Blog RSS</a>
</li>-->
</ul>
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
<div class="form-group" style="display:inline;">
<div class="input-group" style="display:table;">
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
</div>
</div>
</form>
</div>
<!--/.nav-collapse -->
</div>
</div>
<!-- end of header section -->
<div class="container">
<!-- <div class="alert alert-warning" role="alert">
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
</div> -->
<section id="content" class="body">
<header>
<h1>
Installing bitcoind on raspberry pi
</h1>
<ol class="breadcrumb">
<li>
<time class="published" datetime="2018-01-03T16:51:00+01:00">
03 janvier 2018
</time>
</li>
<li>Cryptocurrencies</li>
<li>Bitcoin</li>
</ol>
</header>
<div class='article_content'>
<h3>Installing bitcoind on linux</h3>
<p>Running a full bitcoin node helps the bitcoin network to accept, validate and relay transactions. If you want to volunteer some spare computing and bandwidth resources to run a full node and allow Bitcoin to continue to grow you can grab an inexpensive and power efficient raspberry pi and turn it into a full node.</p>
<p>There are plenty of tutorials on the Internet explaining how to install a bitcoin full node; this tutorial won't go over setting up a raspberry pi and using ssh.</p>
<p>In order to store the full blockchain we will mount a network drive and tell bitcoind to use this mapped drive as the data directory.</p>
<h4>Download the bitcoin client</h4>
<p>Go to <a href="https://bitcoin.org/en/download">https://bitcoin.org/en/download</a></p>
<p><img alt="png" src="../images/Installing_bitcoind_on_raspberry_pi/1.png"></p>
<p>Copy the URL for the ARM 32 bit version and download it onto your raspberry pi. </p>
<div class="highlight"><pre><span></span>wget https://bitcoin.org/bin/bitcoin-core-0.15.1/bitcoin-0.15.1-arm-linux-gnueabihf.tar.gz
</pre></div>
<p>Locate the downloaded file and extract it using the arguement xzf</p>
<div class="highlight"><pre><span></span>tar xzf bitcoin-0.15.1-arm-linux-gnueabihf.tar.gz
</pre></div>
<p>a new directory <em>bitcoin-0.15.1</em> will be created, it contrains the files we need to install the software</p>
<h4>Install the bitcoin client</h4>
<p>We will install the content by copying the binaries located in the bin folder into /usr/local/bin by using the install command.
You must use sudo because it will write data to a system directory</p>
<div class="highlight"><pre><span></span>sudo install -m <span class="m">0755</span> -o root -g root -t /usr/local/bin bitcoin-0.15.1/bin/*
</pre></div>
<p>Launch the bitcoin core client by running </p>
<div class="highlight"><pre><span></span>bitcoind -daemon
</pre></div>
<h3>Configuration of the node</h3>
<h4>Start your node at boot</h4>
<p>Starting you node automatically at boot time is a good idea because it doesn't require a manual action from the user. The simplest way to achive this is to create a cronjob. </p>
<p>Run the following command </p>
<div class="highlight"><pre><span></span>crontab -e
</pre></div>
<p>Select the text editor of your choice, then add the following line at the end of the file</p>
<div class="highlight"><pre><span></span>@reboot bitcoind -daemon
</pre></div>
<p>Save the file and exit; the updated crontab file will be installed for you.</p>
<h4>Full Node</h4>
<p>If you can afford to download and store all the blockchain, you can run a full node. At the time of writing, the blockchain is 150Go (<a href="https://blockchain.info/fr/charts/blocks-size">https://blockchain.info/fr/charts/blocks-size</a>). Tree ways to store this are :
<em> use a microSD with 256Go or more
</em> add a thumbdrive or an external drive to your raspberry pi
* mount a network drive from a NAS</p>
<p>If you have purchased a big SD card then you can leave the default location for the blockchain data (~/.bitcoin/).
Otherwise, you will have to change the datadir location to where your drive is mounted (in my case I have mounted it to /mnt)</p>
<p>In order to configure your bitcoin client, edit/create the file bitcoin.conf located in ~/.bitcoin/</p>
<div class="highlight"><pre><span></span>nano ~/.bitcoin/bitcoin.conf
</pre></div>
<p>copy the following text</p>
<div class="highlight"><pre><span></span># From redoules.github.io
# This config should be placed in following path:
# ~/.bitcoin/bitcoin.conf
# [core]
# Specify a non-default location to store blockchain and other data.
datadir=/mnt
# Set database cache size in megabytes; machines sync faster with a larger cache. Recommend setting as high as possible based upon mach$
dbcache=100
# Keep at most &lt;n&gt; unconnectable transactions in memory.
maxorphantx=10
# Keep the transaction memory pool below &lt;n&gt; megabytess.
maxmempool=50
# [network]
# Maintain at most N connections to peers.
maxconnections=40
# Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit.
maxuploadtarget=5000
</pre></div>
<p>Check <a href="https://jlopp.github.io/bitcoin-core-config-generator">https://jlopp.github.io/bitcoin-core-config-generator</a> it is a handy site to edit the bitcoin.conf file</p>
<h4>Pruning node</h4>
<p>If you don't want to store the entire blockchain you can run a pruning node which reduces storage requirements by enabling pruning (deleting) of old blocks. </p>
<p>Let's say you want to allocated at most 5Go to the blockchain, then specify prune=5000 into your bitcoin.conf file. Edit/create the file bitcoin.conf located in ~/.bitcoin/</p>
<div class="highlight"><pre><span></span>nano ~/.bitcoin/bitcoin.conf
</pre></div>
<p>copy the following text</p>
<div class="highlight"><pre><span></span># From redoules.github.io
# This config should be placed in following path:
# ~/.bitcoin/bitcoin.conf
# [core]
# Set database cache size in megabytes; machines sync faster with a larger cache. Recommend setting as high as possible based upon mach$
dbcache=100
# Keep at most &lt;n&gt; unconnectable transactions in memory.
maxorphantx=10
# Keep the transaction memory pool below &lt;n&gt; megabytess.
maxmempool=50
# Reduce storage requirements by only storing most recent N MiB of block. This mode is incompatible with -txindex and -rescan. WARNING: Reverting this setting requires re-downloading the entire blockchain. (default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, greater than 550 = automatically prune blocks to stay under target size in MiB).
prune=5000
# [network]
# Maintain at most N connections to peers.
maxconnections=40
# Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit.
maxuploadtarget=5000
</pre></div>
<h3>Checking if your node is public</h3>
<p>one of the best way to help the bitcoin network is to allow your node to be visible and to propagate block to other nodes.</p>
<p>The bitcoin protocole uses port 8333, other clients should be able to share information with your client.</p>
<p>Run </p>
<div class="highlight"><pre><span></span>ifconfig
</pre></div>
<p>and check if you have an ipv6 adresse (look for adr inet6:)</p>
<h4>IPV6</h4>
<p>Get the global ipv6 adresse of your raspberry pi</p>
<div class="highlight"><pre><span></span> Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet adr:192.168.1.x Bcast:192.168.1.255 Masque:255.255.255.0
adr inet6: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Lien
adr inet6: xxxx:xxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42681744 errors:0 dropped:0 overruns:0 frame:0
TX packets:38447218 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
RX bytes:3044414780 (2.8 GiB) TX bytes:2599878680 (2.4 GiB)
</pre></div>
<p>it is located between adr inet4 and Scope:Global</p>
<div class="highlight"><pre><span></span>adr inet6: xxxx:xxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/64 Scope:Global
</pre></div>
<p>Copy this adresse and past it into the search field on <a href="https://bitnodes.earn.com/">https://bitnodes.earn.com/</a></p>
<p><img alt="jpg" src="../images/Installing_bitcoind_on_raspberry_pi/2.jpg"></p>
<p>If your node is visible, it will appear on the website</p>
<p><img alt="jpg" src="../images/Installing_bitcoind_on_raspberry_pi/3.jpg"></p>
<h4>IPV4</h4>
<p>If you don't have an ipv6 adresse, you will have to open port 8333 on your router and redirect it to the internal IP of your raspberry pi.</p>
<p>It is not detailed here because the configuration depends on your router.</p>
</div>
<aside>
<div class="bug-reporting__panel">
<h3>Find an error or bug? Have a suggestion?</h3>
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
</div>
</aside>
</section>
</div>
<!-- start of footer section -->
<footer class="footer">
<div class="container">
<p class="text-muted">
<center>This project contains 81 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
<br/>
Copyright &copy; Guillaume Redoulès,
<time datetime="2018">2018</time>.
</center>
</p>
</div>
</footer>
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
<script>
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
</script>
<!-- Load Google Analytics -->
<script>
/*
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-66582-32', 'auto');
ga('send', 'pageview');
*/
</script>
<!-- End of Google Analytics -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../theme/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>