<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mariano Guerra's Log (Publicaciones sobre riak_core)</title><link>http://marianoguerra.org/</link><description></description><atom:link href="http://marianoguerra.org/es/categories/cat_riak_core.xml" rel="self" type="application/rss+xml"></atom:link><language>es</language><lastBuildDate>Mon, 18 Nov 2024 17:56:27 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Riak Core Tutorial Part 2: Starting</title><link>http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/</link><dc:creator>Mariano Guerra</dc:creator><description>&lt;p&gt;This is part of a series, see the previous one at &lt;a class="reference external" href="http://marianoguerra.org/posts/riak-core-tutorial-part-1-setup/"&gt;Riak Core Tutorial Part 1: Setup&lt;/a&gt;&lt;/p&gt;
&lt;section id="creating-our-project"&gt;
&lt;h2&gt;Creating our Project&lt;/h2&gt;
&lt;p&gt;Now that we have our tools and our template installed we can start by asking
rebar3 to create a new project we will call tanodb using the &lt;a class="reference external" href="https://github.com/basho/riak_core"&gt;riak_core&lt;/a&gt; template we just installed:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_5473021e55194a3db288dd969013e35c-1" name="rest_code_5473021e55194a3db288dd969013e35c-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_5473021e55194a3db288dd969013e35c-1"&gt;&lt;/a&gt;rebar3&lt;span class="w"&gt; &lt;/span&gt;new&lt;span class="w"&gt; &lt;/span&gt;rebar3_riak_core&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;tanodb
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If it fails saying it can't find rebar3 check that it's in your &lt;cite&gt;$PATH&lt;/cite&gt;
environment variable and that you have Erlang activated.&lt;/p&gt;
&lt;p&gt;The output should be something like this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;===&amp;gt; Writing tanodb/apps/tanodb/src/tanodb.app.src
===&amp;gt; Writing tanodb/apps/tanodb/src/tanodb.erl
===&amp;gt; Writing tanodb/apps/tanodb/src/tanodb_app.erl
===&amp;gt; Writing tanodb/apps/tanodb/src/tanodb_sup.erl
===&amp;gt; Writing tanodb/apps/tanodb/src/tanodb_console.erl
===&amp;gt; Writing tanodb/apps/tanodb/src/tanodb_vnode.erl
===&amp;gt; Writing tanodb/rebar.config
===&amp;gt; Writing tanodb/.editorconfig
===&amp;gt; Writing tanodb/.gitignore
===&amp;gt; Writing tanodb/README.rst
===&amp;gt; Writing tanodb/Makefile
===&amp;gt; Writing tanodb/config/admin_bin
===&amp;gt; Writing tanodb/priv/01-tanodb.schema
===&amp;gt; Writing tanodb/config/advanced.config
===&amp;gt; Writing tanodb/config/vars.config
===&amp;gt; Writing tanodb/config/vars_dev1.config
===&amp;gt; Writing tanodb/config/vars_dev2.config
===&amp;gt; Writing tanodb/config/vars_dev3.config&lt;/pre&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;The content of this chapter is in the &lt;cite&gt;01-template&lt;/cite&gt; branch.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://gitlab.com/marianoguerra/tanodb/tree/01-template"&gt;https://gitlab.com/marianoguerra/tanodb/tree/01-template&lt;/a&gt;&lt;/p&gt;
&lt;/aside&gt;
&lt;/section&gt;
&lt;section id="building-and-running"&gt;
&lt;h2&gt;Building and Running&lt;/h2&gt;
&lt;p&gt;Before explaining what the files mean so you get an idea what just happened
let's run it!&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_a513e760cf3e40b59d246d09183d2967-1" name="rest_code_a513e760cf3e40b59d246d09183d2967-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_a513e760cf3e40b59d246d09183d2967-1"&gt;&lt;/a&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;tanodb
&lt;a id="rest_code_a513e760cf3e40b59d246d09183d2967-2" name="rest_code_a513e760cf3e40b59d246d09183d2967-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_a513e760cf3e40b59d246d09183d2967-2"&gt;&lt;/a&gt;make
&lt;a id="rest_code_a513e760cf3e40b59d246d09183d2967-3" name="rest_code_a513e760cf3e40b59d246d09183d2967-3" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_a513e760cf3e40b59d246d09183d2967-3"&gt;&lt;/a&gt;make&lt;span class="w"&gt; &lt;/span&gt;console
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;cite&gt;make&lt;/cite&gt; runs rebar3 commands to build a release of our project, for that it uses a tool called &lt;a class="reference external" href="https://github.com/erlware/relx"&gt;relx&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The initial build may take a while since it has to fetch all the dependencies
and build them.&lt;/p&gt;
&lt;p&gt;After the release is built (you can check the result by inspecting the folder
&lt;cite&gt;_build/default/rel/tanodb/&lt;/cite&gt;) we can run it.&lt;/p&gt;
&lt;p&gt;When we run &lt;cite&gt;make console&lt;/cite&gt; we get some noisy output that should end with something like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code erl"&gt;&lt;a id="rest_code_428bfa5253c3409a8134346e697ec91d-1" name="rest_code_428bfa5253c3409a8134346e697ec91d-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_428bfa5253c3409a8134346e697ec91d-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;Eshell V9.3  (abort with ^G)&lt;/span&gt;
&lt;a id="rest_code_428bfa5253c3409a8134346e697ec91d-2" name="rest_code_428bfa5253c3409a8134346e697ec91d-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_428bfa5253c3409a8134346e697ec91d-2"&gt;&lt;/a&gt;&lt;span class="gp"&gt;(tanodb@127.0.0.1)1&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is the Erlang shell, something like a REPL connected to our system,
we now can test our system by calling &lt;cite&gt;tanodb:ping()&lt;/cite&gt; on it.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code erl"&gt;&lt;a id="rest_code_149e5a7d59cf4b1980210c167382e1b2-1" name="rest_code_149e5a7d59cf4b1980210c167382e1b2-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_149e5a7d59cf4b1980210c167382e1b2-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;(tanodb@127.0.0.1)1&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;tanodb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nf"&gt;ping&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;
&lt;a id="rest_code_149e5a7d59cf4b1980210c167382e1b2-2" name="rest_code_149e5a7d59cf4b1980210c167382e1b2-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/#rest_code_149e5a7d59cf4b1980210c167382e1b2-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;{pong,1347321821914426127719021955160323408745312813056}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The response is the atom &lt;cite&gt;pong&lt;/cite&gt; and a huge number that we will explain later,
but to make it short, it's the id of the process that replied to us.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="exploring-the-template-files"&gt;
&lt;h2&gt;Exploring the Template Files&lt;/h2&gt;
&lt;p&gt;The template created a lot of files and if you are like me, you don't like things
that make magic and don't explain what's going on, that's why we will get a
brief overview of the files created here.&lt;/p&gt;
&lt;p&gt;First this files are created:&lt;/p&gt;
&lt;pre class="literal-block"&gt;apps/tanodb/src/tanodb.app.src
apps/tanodb/src/tanodb.erl
apps/tanodb/src/tanodb_app.erl
apps/tanodb/src/tanodb_sup.erl
apps/tanodb/src/tanodb_console.erl
apps/tanodb/src/tanodb_vnode.erl&lt;/pre&gt;
&lt;p&gt;Those are the meat of this project, the source code we start with, if you
know a little of erlang you will recognice many of them, let's explain them briefly,
if you think you need more information I recommend you this awesome book which
you can read online: &lt;a class="reference external" href="http://learnyousomeerlang.com/"&gt;Learn You Some Erlang for great good!&lt;/a&gt;&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;tanodb.app.src&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file is "The Application Resource File", you can read it, it's quite self descriptive.
You can read more about it in the
&lt;a class="reference external" href="http://learnyousomeerlang.com/building-otp-applications"&gt;Building OTP Applications Section of Learn You Some Erlang&lt;/a&gt;
or in the &lt;a class="reference external" href="http://www.erlang.org/doc/man/app.html"&gt;man page for app in the Erlang documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;tanodb.erl&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file is the main API of our application, here we expose all the things
you can ask our application to do, for now it can only handle the &lt;cite&gt;ping()&lt;/cite&gt;
command but we will add some more in the future.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;tanodb_app.erl&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file implements the &lt;a class="reference external" href="http://www.erlang.org/doc/design_principles/applications.html"&gt;application behavior&lt;/a&gt; it's a set of callbacks
that the Erlang runtime calls to start and stop our application.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;tanodb_sup.erl&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file implements the &lt;a class="reference external" href="http://www.erlang.org/doc/design_principles/sup_princ.html"&gt;supervisor behavior&lt;/a&gt; it's a set of callbacks
that the Erlang runtime calls to build the supervisor hierarchy.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;tanodb_console.erl&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file is specific to riak_core, it's a set of callbacks that will be
called by the &lt;cite&gt;tanodb-admin&lt;/cite&gt; command.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;tanodb_vnode.erl&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file is specific to riak_core, it implements the riak_code_vnode
behavior, which is a set of callbacks that riak_core will call to
accomplish different tasks, it's the main file we will edit to add new
features.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;Those were the source code files, but the template also created other files,
let's review them&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;rebar.config&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This is the file that rebar3 reads to get information about our project
like dependencies and build configuration, you can read more about it
on the &lt;a class="reference external" href="http://www.rebar3.org/docs/basic-usage"&gt;rebar3 documentation&lt;/a&gt;&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;.editorconfig&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file describes the coding style for this project, if your text editor
understands editorconfig files then it will change it's setting for this
project to the ones described in this file, read more about editor config
on the &lt;a class="reference external" href="http://editorconfig.org/"&gt;editorconfig website&lt;/a&gt;&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;.gitignore&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A file to tell git which files to ignore from the repository.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;README.rst&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The README of the project&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Makefile&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A make file with some targets that will make it easier to achieve some
complex tasks without copying and pasting too much.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;config/admin_bin&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A template for the &lt;cite&gt;tanodb-admin&lt;/cite&gt; command.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;priv/01-tanodb.schema&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The &lt;a class="reference external" href="https://github.com/basho/cuttlefish/wiki"&gt;cuttlefish schema&lt;/a&gt; file
that describes what configuration our application supports, it starts with
some example configuration fields that we will
use as the application grows.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;config/advanced.config&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file is where we configure some advanced things of our application
that don't go on our &lt;cite&gt;tanodb.config&lt;/cite&gt; file, here we configure riak_core and
our &lt;a class="reference external" href="https://github.com/basho/lager/"&gt;logging library&lt;/a&gt;&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;config/vars.config&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;This file contains variables used by relx to build a release, you can
read more about it in the &lt;a class="reference external" href="http://www.rebar3.org/docs/releases"&gt;rebar3 release documentation&lt;/a&gt;&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;The following files are like vars.config but with slight differences to allow
running more than one node on the same machine:&lt;/p&gt;
&lt;pre class="literal-block"&gt;config/vars_dev1.config
config/vars_dev2.config
config/vars_dev3.config&lt;/pre&gt;
&lt;p&gt;Normally when you have a cluster for your application one operating system
instance runs one instance of your application and you have many operating
system instances, but to test the clustering features of riak_core we will
build 3 releases of our application using offsets for ports and changing the
application name to avoid collisions.&lt;/p&gt;
&lt;p&gt;Those are all the files, follow the links to know more about them.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="playing-with-clustering"&gt;
&lt;h2&gt;Playing with Clustering&lt;/h2&gt;
&lt;p&gt;Before starting to add features, let's first play with clustering so we understand
all those config files above work.&lt;/p&gt;
&lt;p&gt;Build 3 releases that can run on the same machine:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make devrel&lt;/pre&gt;
&lt;p&gt;This will build 3 releases of the application using different parameters (the
dev1, dev2 and dev3 files we saw earlier) and will place them under:&lt;/p&gt;
&lt;pre class="literal-block"&gt;_build/dev1
_build/dev2
_build/dev3&lt;/pre&gt;
&lt;p&gt;This is achived by using the &lt;a class="reference external" href="http://www.rebar3.org/docs/profiles"&gt;profiles feature from rebar3&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now open 3 consoles and run the following commands one on each console:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make dev1-console
make dev2-console
make dev3-console&lt;/pre&gt;
&lt;p&gt;This will start the 3 nodes but they won't know about each other, for them
to know about each other we need to "join" them, that is to tell one of them
about the other two, this is achieved using the tanodb-admin command, here is
how you should run it manually (don't run them):&lt;/p&gt;
&lt;pre class="literal-block"&gt;_build/dev2/rel/tanodb/bin/tanodb-admin cluster join tanodb1@127.0.0.1
_build/dev3/rel/tanodb/bin/tanodb-admin cluster join tanodb1@127.0.0.1&lt;/pre&gt;
&lt;p&gt;We tell dev2 and dev3 to join tanodb1 (dev1), to make this easier and less
error prone run the following command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make devrel-join&lt;/pre&gt;
&lt;p&gt;Now let's check the status of the cluster:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make devrel-status&lt;/pre&gt;
&lt;p&gt;You can read the Makefile to get an idea of what those commands do, in this case
devrel-status does the following:&lt;/p&gt;
&lt;pre class="literal-block"&gt;_build/dev1/rel/tanodb/bin/tanodb-admin member-status&lt;/pre&gt;
&lt;p&gt;You should see something like this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;================================= Membership ===============
Status     Ring    Pending    Node
------------------------------------------------------------
joining     0.0%      --      'tanodb2@127.0.0.1'
joining     0.0%      --      'tanodb3@127.0.0.1'
valid     100.0%      --      'tanodb1@127.0.0.1'
------------------------------------------------------------
Valid:1 / Leaving:0 / Exiting:0 / Joining:2 / Down:0&lt;/pre&gt;
&lt;p&gt;It should say that 3 nodes are joining, now check the cluster plan:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make devrel-cluster-plan&lt;/pre&gt;
&lt;p&gt;The output should be something like this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;=============================== Staged Changes ==============
Action         Details(s)
-------------------------------------------------------------
join           'tanodb2@127.0.0.1'
join           'tanodb3@127.0.0.1'
-------------------------------------------------------------


NOTE: Applying these changes will result in 1 cluster transition

#############################################################
                         After cluster transition 1/1
#############################################################

================================= Membership ================
Status     Ring    Pending    Node
-------------------------------------------------------------
valid     100.0%     34.4%    'tanodb1@127.0.0.1'
valid       0.0%     32.8%    'tanodb2@127.0.0.1'
valid       0.0%     32.8%    'tanodb3@127.0.0.1'
-------------------------------------------------------------
Valid:3 / Leaving:0 / Exiting:0 / Joining:0 / Down:0

WARNING: Not all replicas will be on distinct nodes

Transfers resulting from cluster changes: 42
  21 transfers from 'tanodb1@127.0.0.1' to 'tanodb3@127.0.0.1'
  21 transfers from 'tanodb1@127.0.0.1' to 'tanodb2@127.0.0.1'&lt;/pre&gt;
&lt;p&gt;Now we can commit the plan:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make devrel-cluster-commit&lt;/pre&gt;
&lt;p&gt;Which should say something like:&lt;/p&gt;
&lt;pre class="literal-block"&gt;Cluster changes committed&lt;/pre&gt;
&lt;p&gt;Now riak_core started an internal process to join the nodes to the cluster,
this involve some complex processes that we will explore in the following
chapters.&lt;/p&gt;
&lt;p&gt;You should see on the consoles where the nodes are running that some logging
is happening describing the process.&lt;/p&gt;
&lt;p&gt;Check the status of the cluster again:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make devrel-status&lt;/pre&gt;
&lt;p&gt;You can see the vnodes transfering, this means the content of some virtual
nodes on one tanodb node are being transferred to another tanodb node:&lt;/p&gt;
&lt;pre class="literal-block"&gt;================================= Membership =============
Status     Ring    Pending    Node
----------------------------------------------------------
valid      75.0%     34.4%    'tanodb1@127.0.0.1'
valid       9.4%     32.8%    'tanodb2@127.0.0.1'
valid       7.8%     32.8%    'tanodb3@127.0.0.1'
----------------------------------------------------------
Valid:3 / Leaving:0 / Exiting:0 / Joining:0 / Down:0&lt;/pre&gt;
&lt;p&gt;At some point you should see something like this, which means that the nodes
are joined and balanced:&lt;/p&gt;
&lt;pre class="literal-block"&gt;================================= Membership ==============
Status     Ring    Pending    Node
-----------------------------------------------------------
valid      34.4%      --      'tanodb1@127.0.0.1'
valid      32.8%      --      'tanodb2@127.0.0.1'
valid      32.8%      --      'tanodb3@127.0.0.1'
-----------------------------------------------------------
Valid:3 / Leaving:0 / Exiting:0 / Joining:0 / Down:0&lt;/pre&gt;
&lt;p&gt;When you are bored you can stop them:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make devrel-stop&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="building-a-production-release"&gt;
&lt;h2&gt;Building a Production Release&lt;/h2&gt;
&lt;p&gt;Even when our application doesn't have the features to merit a production
release we are going to learn how to do it here since you can later do it at
any step and get a full release of the app:&lt;/p&gt;
&lt;pre class="literal-block"&gt;make prod-release&lt;/pre&gt;
&lt;p&gt;In that command rebar3 runs the release task using the prod profile, which has
some configuration differences with the dev profiles we use so that it builds
something we can unpack and run on another operating system without installing
anything.&lt;/p&gt;
&lt;p&gt;Let's package our release:&lt;/p&gt;
&lt;pre class="literal-block"&gt;cd _build/prod/rel
tar -czf tanodb.tgz tanodb tanodb_config
cd -
mv _build/prod/rel/tanodb.tgz .&lt;/pre&gt;
&lt;p&gt;You can copy it to a clean OS and run:&lt;/p&gt;
&lt;pre class="literal-block"&gt;tar -xzf tanodb.tgz
./tanodb/bin/tanodb console&lt;/pre&gt;
&lt;p&gt;And it runs!&lt;/p&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;You should build the production release on the same operating system
version you are intending to run it to avoid version problems, the
main source of headaches are C extensions disagreeing on libc versions
and similar.&lt;/p&gt;
&lt;p&gt;So, even when you could build it on a version that is close and test
it it's better to build releases on the same version to avoid
problems. More so if you are packaging the Erlang runtime with the
release as we are doing here.&lt;/p&gt;
&lt;/aside&gt;
&lt;/section&gt;
&lt;section id="wrapping-up"&gt;
&lt;h2&gt;Wrapping Up&lt;/h2&gt;
&lt;p&gt;Now you know how to create a riak_core app from a template, how to build a
release and run it, how to build releases for a development cluster, run
the nodes, join them and inspect the cluster status and how to build a
production release and run it on a fresh server.&lt;/p&gt;
&lt;/section&gt;</description><guid>http://marianoguerra.org/es/posts/riak-core-tutorial-part-2-starting/</guid><pubDate>Thu, 03 May 2018 12:48:26 GMT</pubDate></item><item><title>Riak Core Tutorial Part 1: Setup</title><link>http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/</link><dc:creator>Mariano Guerra</dc:creator><description>&lt;p&gt;This is the first chapter in a series that will explore how to use riak_core
to build a distributed key-value store.&lt;/p&gt;
&lt;p&gt;We first need to have Erlang installed and rebar3 installed.&lt;/p&gt;
&lt;section id="the-easy-way"&gt;
&lt;h2&gt;The Easy Way&lt;/h2&gt;
&lt;p&gt;If you don't have Erlang installed or you don't have problem to install the
latest one system wide you can try installing it with your package manager:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;For Homebrew on OS X: &lt;cite&gt;brew install erlang&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For MacPorts on OS X: &lt;cite&gt;port install erlang&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Ubuntu and Debian: &lt;cite&gt;apt-get install erlang&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Fedora: &lt;cite&gt;yum install erlang&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For FreeBSD: &lt;cite&gt;pkg install erlang&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Please check that the package version is 20.x, if not, check for instructions
on how to install the Erlang Solutions package for Ubuntu, CentOS, Mac OS X, Debian or Fedora here: &lt;a class="reference external" href="https://www.erlang-solutions.com/resources/download.html"&gt;https://www.erlang-solutions.com/resources/download.html&lt;/a&gt;&lt;/p&gt;
&lt;/section&gt;
&lt;section id="setting-up-rebar3"&gt;
&lt;h2&gt;Setting up rebar3&lt;/h2&gt;
&lt;p&gt;Now we have Erlang, we need a build tool, we are going to use &lt;a class="reference external" href="http://rebar3.org"&gt;rebar3&lt;/a&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_66127f2a593a41efae7003f932528314-1" name="rest_code_66127f2a593a41efae7003f932528314-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_66127f2a593a41efae7003f932528314-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# download rebar3 to our bin directory&lt;/span&gt;
&lt;a id="rest_code_66127f2a593a41efae7003f932528314-2" name="rest_code_66127f2a593a41efae7003f932528314-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_66127f2a593a41efae7003f932528314-2"&gt;&lt;/a&gt;wget&lt;span class="w"&gt; &lt;/span&gt;https://s3.amazonaws.com/rebar3/rebar3&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/bin/rebar3
&lt;a id="rest_code_66127f2a593a41efae7003f932528314-3" name="rest_code_66127f2a593a41efae7003f932528314-3" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_66127f2a593a41efae7003f932528314-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_66127f2a593a41efae7003f932528314-4" name="rest_code_66127f2a593a41efae7003f932528314-4" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_66127f2a593a41efae7003f932528314-4"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# set execution permissions for our user&lt;/span&gt;
&lt;a id="rest_code_66127f2a593a41efae7003f932528314-5" name="rest_code_66127f2a593a41efae7003f932528314-5" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_66127f2a593a41efae7003f932528314-5"&gt;&lt;/a&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;u+x&lt;span class="w"&gt; &lt;/span&gt;rebar3
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just in case you have problems running the rebar3 commands with a different
version, here's the version I'm using:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_f0e6eabcdda8410ab122ee489f3870fb-1" name="rest_code_f0e6eabcdda8410ab122ee489f3870fb-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_f0e6eabcdda8410ab122ee489f3870fb-1"&gt;&lt;/a&gt;rebar3&lt;span class="w"&gt; &lt;/span&gt;version
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;
&lt;pre class="literal-block"&gt;rebar 3.5.0 on Erlang/OTP 20 Erts 9.2&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="install-riak-core-rebar3-template"&gt;
&lt;h2&gt;Install Riak Core Rebar3 Template&lt;/h2&gt;
&lt;p&gt;To create a Riak Core project from scratch we will use a template called &lt;a class="reference external" href="https://github.com/marianoguerra/rebar3_template_riak_core/"&gt;rebar3_template_riak_core&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;we need to clone its repo in a place where rebar3 can see it:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_4359e7d9a58643ce8f628ae19c596ade-1" name="rest_code_4359e7d9a58643ce8f628ae19c596ade-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_4359e7d9a58643ce8f628ae19c596ade-1"&gt;&lt;/a&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;~/.config/rebar3/templates
&lt;a id="rest_code_4359e7d9a58643ce8f628ae19c596ade-2" name="rest_code_4359e7d9a58643ce8f628ae19c596ade-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_4359e7d9a58643ce8f628ae19c596ade-2"&gt;&lt;/a&gt;git&lt;span class="w"&gt; &lt;/span&gt;clone&lt;span class="w"&gt; &lt;/span&gt;https://github.com/marianoguerra/rebar3_template_riak_core.git&lt;span class="w"&gt; &lt;/span&gt;~/.config/rebar3/templates/rebar3_template_riak_core
&lt;/pre&gt;&lt;/div&gt;
&lt;/section&gt;
&lt;section id="the-hard-way-building-erlang-with-kerl"&gt;
&lt;h2&gt;The Hard Way: Building Erlang with kerl&lt;/h2&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;If you installed Erlang with the instructions above, skip until the
&lt;em&gt;Test that Everything Works&lt;/em&gt; section below.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;If you have or want to have more than one version running side by side you can
use &lt;a class="reference external" href="https://github.com/kerl/kerl"&gt;kerl&lt;/a&gt;, from its github README:&lt;/p&gt;
&lt;pre class="literal-block"&gt;Easy building and installing of Erlang/OTP instances.

Kerl aims to be shell agnostic and its only dependencies, excluding what's
required to actually build Erlang/OTP, are curl and git.&lt;/pre&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;On Mac you can install it with homebrew: &lt;cite&gt;brew install kerl&lt;/cite&gt;&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;First we need to fetch kerl:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-1" name="rest_code_fe178600a39349738ac66b7e542be6c6-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# create bin folder in our home directory if it's not already there&lt;/span&gt;
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-2" name="rest_code_fe178600a39349738ac66b7e542be6c6-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-2"&gt;&lt;/a&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;~/bin
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-3" name="rest_code_fe178600a39349738ac66b7e542be6c6-3" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-4" name="rest_code_fe178600a39349738ac66b7e542be6c6-4" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-4"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# cd to it&lt;/span&gt;
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-5" name="rest_code_fe178600a39349738ac66b7e542be6c6-5" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-5"&gt;&lt;/a&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~/bin
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-6" name="rest_code_fe178600a39349738ac66b7e542be6c6-6" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-6"&gt;&lt;/a&gt;
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-7" name="rest_code_fe178600a39349738ac66b7e542be6c6-7" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-7"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# download kerl script&lt;/span&gt;
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-8" name="rest_code_fe178600a39349738ac66b7e542be6c6-8" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-8"&gt;&lt;/a&gt;curl&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;https://raw.githubusercontent.com/kerl/kerl/master/kerl
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-9" name="rest_code_fe178600a39349738ac66b7e542be6c6-9" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-10" name="rest_code_fe178600a39349738ac66b7e542be6c6-10" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-10"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# set execution permitions for our user&lt;/span&gt;
&lt;a id="rest_code_fe178600a39349738ac66b7e542be6c6-11" name="rest_code_fe178600a39349738ac66b7e542be6c6-11" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_fe178600a39349738ac66b7e542be6c6-11"&gt;&lt;/a&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;u+x&lt;span class="w"&gt; &lt;/span&gt;kerl
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You will need to add ~/bin to your PATH variable so your shell can find the
kerl script, you can do it like this in your shell:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-1" name="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# set the PATH environment variable to the value it had before plus a colon&lt;/span&gt;
&lt;a id="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-2" name="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-2"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# (path separator) and a new path which points to the bin folder we just&lt;/span&gt;
&lt;a id="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-3" name="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-3" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-3"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# created&lt;/span&gt;
&lt;a id="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-4" name="rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-4" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_a424fc6034cb48f0a84aa31a1d6f6b89-4"&gt;&lt;/a&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;:&lt;span class="nv"&gt;$HOME&lt;/span&gt;/bin
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you want to make this work every time you start a shell you need to put it
it the rc file of your shell of choice, for bash it's ~/.bashrc, for zsh it's
~/.zshrc, you will have to add a line like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_e7fdc7b425a946f6b1a8f9b0040dee98-1" name="rest_code_e7fdc7b425a946f6b1a8f9b0040dee98-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_e7fdc7b425a946f6b1a8f9b0040dee98-1"&gt;&lt;/a&gt;&lt;span class="nb"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;:&lt;span class="nv"&gt;$HOME&lt;/span&gt;/bin
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After this, start a new shell or source your rc file so that it picks up your
new PATH variable, you can check that it's set correctly by running:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_77871afea9794d67934f37e280cd6dde-1" name="rest_code_77871afea9794d67934f37e280cd6dde-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_77871afea9794d67934f37e280cd6dde-1"&gt;&lt;/a&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And checking in the output if $HOME/bin is there (notice that $HOME will be
expanded to the actual path).&lt;/p&gt;
&lt;/section&gt;
&lt;section id="building-an-erlang-release-with-kerl"&gt;
&lt;h2&gt;Building an Erlang release with kerl&lt;/h2&gt;
&lt;p&gt;We have kerl installed and available in our shell, now we need to build an
Erlang release of our choice, for this we will need a compiler and other
tools and libraries needed to compile it:&lt;/p&gt;
&lt;p&gt;This are instructions on ubuntu 17.10, check the names for those packages
on your distribution.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-1" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# required: basic tools and libraries needed&lt;/span&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-2" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-2"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# (compiler, curses for the shell, ssl for crypto)&lt;/span&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-3" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-3" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-3"&gt;&lt;/a&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;-y&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;build-essential&lt;span class="w"&gt; &lt;/span&gt;m4&lt;span class="w"&gt; &lt;/span&gt;libncurses5-dev&lt;span class="w"&gt; &lt;/span&gt;libssl-dev
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-4" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-4" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-4"&gt;&lt;/a&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-5" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-5" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-5"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# optonal: if you want odbc support (database connectivity)&lt;/span&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-6" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-6" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-6"&gt;&lt;/a&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;unixodbc-dev
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-7" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-7" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-8" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-8" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-8"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# optonal: if you want pdf docs you need apache fop and xslt tools and java (fop is a java project)&lt;/span&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-9" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-9" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-9"&gt;&lt;/a&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;-y&lt;span class="w"&gt; &lt;/span&gt;fop&lt;span class="w"&gt; &lt;/span&gt;xsltproc&lt;span class="w"&gt; &lt;/span&gt;default-jdk
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-10" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-10" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-10"&gt;&lt;/a&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-11" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-11" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-11"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# optional: if you want to build jinterface you need a JDK&lt;/span&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-12" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-12" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-12"&gt;&lt;/a&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;-y&lt;span class="w"&gt; &lt;/span&gt;default-jdk
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-13" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-13" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-14" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-14" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-14"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# optional: if you want wx (desktop GUI modules)&lt;/span&gt;
&lt;a id="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-15" name="rest_code_2be6d6a9121f4f5bac5df688f9869f7e-15" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2be6d6a9121f4f5bac5df688f9869f7e-15"&gt;&lt;/a&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;-y&lt;span class="w"&gt; &lt;/span&gt;libwxgtk3.0-dev
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now that we have everything we need we can finally build our Erlang release.&lt;/p&gt;
&lt;p&gt;First we fetch an updated list of releases:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_48de79ad9d9c4001be6def30b23fc032-1" name="rest_code_48de79ad9d9c4001be6def30b23fc032-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_48de79ad9d9c4001be6def30b23fc032-1"&gt;&lt;/a&gt;kerl&lt;span class="w"&gt; &lt;/span&gt;update&lt;span class="w"&gt; &lt;/span&gt;releases
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output in my case:&lt;/p&gt;
&lt;pre class="literal-block"&gt;The available releases are:

R10B-0 R10B-10 R10B-1a R10B-2 R10B-3 R10B-4 R10B-5 R10B-6 R10B-7 R10B-8
R10B-9 R11B-0 R11B-1 R11B-2 R11B-3 R11B-4 R11B-5 R12B-0 R12B-1 R12B-2 R12B-3
R12B-4 R12B-5 R13A R13B01 R13B02-1 R13B02 R13B03 R13B04 R13B R14A R14B01
R14B02 R14B03 R14B04 R14B_erts-5.8.1.1 R14B R15B01 R15B02
R15B02_with_MSVCR100_installer_fix R15B03-1 R15B03 R15B
R16A_RELEASE_CANDIDATE R16B01 R16B02 R16B03-1 R16B03 R16B 17.0-rc1 17.0-rc2
17.0 17.1 17.3 17.4 17.5 18.0 18.1 18.2.1 18.2 18.3 19.0 19.1 19.2 19.3
20.0 20.1 20.2 20.3&lt;/pre&gt;
&lt;p&gt;Let's build the 20.3 version:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_d17bda0c99a74b2ba902d45a513a917d-1" name="rest_code_d17bda0c99a74b2ba902d45a513a917d-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_d17bda0c99a74b2ba902d45a513a917d-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# this will take a while&lt;/span&gt;
&lt;a id="rest_code_d17bda0c99a74b2ba902d45a513a917d-2" name="rest_code_d17bda0c99a74b2ba902d45a513a917d-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_d17bda0c99a74b2ba902d45a513a917d-2"&gt;&lt;/a&gt;kerl&lt;span class="w"&gt; &lt;/span&gt;build&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;.3&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;.3
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And install it:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_2f09aa1254d64a68bfead1792a891e16-1" name="rest_code_2f09aa1254d64a68bfead1792a891e16-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_2f09aa1254d64a68bfead1792a891e16-1"&gt;&lt;/a&gt;kerl&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;.3&lt;span class="w"&gt; &lt;/span&gt;~/bin/erl-20.3
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now everytime we want to use this version of Erlang we need to run:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_b46e417ea7774047aa7bdcdf921700cc-1" name="rest_code_b46e417ea7774047aa7bdcdf921700cc-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_b46e417ea7774047aa7bdcdf921700cc-1"&gt;&lt;/a&gt;.&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/bin/erl-20.3/activate
&lt;/pre&gt;&lt;/div&gt;
&lt;/section&gt;
&lt;section id="test-that-everything-works"&gt;
&lt;h2&gt;Test that Everything Works&lt;/h2&gt;
&lt;p&gt;We have installed several tools:&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;kerl&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Let's you install multiple Erlang releases that can live side by side&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Erlang 20.3&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The version of erlang we are going to be using&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Rebar 3&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Our build tool&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;rebar3_template_riak_core&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Rebar 3 Template that will make it easy to setup fresh riak_core projects
for experimentation&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;Now we need to check that everything is setup correctly, we will do that by
creating a template and building it.&lt;/p&gt;
&lt;p&gt;Remember to have $HOME/bin in your $PATH and Erlang 20.3 activated, &lt;cite&gt;cd&lt;/cite&gt; to a folder of your choice to hold this project and run:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_55dd3626266449579a12308241d5df81-1" name="rest_code_55dd3626266449579a12308241d5df81-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_55dd3626266449579a12308241d5df81-1"&gt;&lt;/a&gt;rebar3&lt;span class="w"&gt; &lt;/span&gt;new&lt;span class="w"&gt; &lt;/span&gt;rebar3_riak_core&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;akv
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Output should be similar to this one:&lt;/p&gt;
&lt;pre class="literal-block"&gt;===&amp;gt; Writing akv/apps/akv/src/akv.app.src
===&amp;gt; Writing akv/apps/akv/src/akv.erl
===&amp;gt; Writing akv/apps/akv/src/akv_app.erl
===&amp;gt; Writing akv/apps/akv/src/akv_sup.erl
===&amp;gt; Writing akv/apps/akv/src/akv_console.erl
===&amp;gt; Writing akv/apps/akv/src/akv_vnode.erl
===&amp;gt; Writing akv/rebar.config
===&amp;gt; Writing akv/.editorconfig
===&amp;gt; Writing akv/.gitignore
===&amp;gt; Writing akv/README.rst
===&amp;gt; Writing akv/Makefile
===&amp;gt; Writing akv/config/admin_bin
===&amp;gt; Writing akv/priv/01-akv.schema
===&amp;gt; Writing akv/config/advanced.config
===&amp;gt; Writing akv/config/vars.config
===&amp;gt; Writing akv/config/vars_dev1.config
===&amp;gt; Writing akv/config/vars_dev2.config
===&amp;gt; Writing akv/config/vars_dev3.config&lt;/pre&gt;
&lt;p&gt;Now let's try to build it:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_53dfafd08f4d49dfac11a2f4daf4c86c-1" name="rest_code_53dfafd08f4d49dfac11a2f4daf4c86c-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_53dfafd08f4d49dfac11a2f4daf4c86c-1"&gt;&lt;/a&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;akv
&lt;a id="rest_code_53dfafd08f4d49dfac11a2f4daf4c86c-2" name="rest_code_53dfafd08f4d49dfac11a2f4daf4c86c-2" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_53dfafd08f4d49dfac11a2f4daf4c86c-2"&gt;&lt;/a&gt;make
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Output is to long to list, after it ends, near the end you should see this line:&lt;/p&gt;
&lt;pre class="literal-block"&gt;===&amp;gt; release successfully created!&lt;/pre&gt;
&lt;p&gt;Now let's try to run it:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code sh"&gt;&lt;a id="rest_code_623c7ebdea68408b8ed1184c6d19f8fd-1" name="rest_code_623c7ebdea68408b8ed1184c6d19f8fd-1" href="http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/#rest_code_623c7ebdea68408b8ed1184c6d19f8fd-1"&gt;&lt;/a&gt;make&lt;span class="w"&gt; &lt;/span&gt;console
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Last lines should be:&lt;/p&gt;
&lt;pre class="literal-block"&gt;Eshell V9.3  (abort with ^G)
(akv@127.0.0.1)1&amp;gt;&lt;/pre&gt;
&lt;p&gt;You can exit with &lt;cite&gt;q().&lt;/cite&gt; and pressing enter or hitting Ctrl-C twice.&lt;/p&gt;
&lt;p&gt;We're ready to start!&lt;/p&gt;
&lt;/section&gt;</description><guid>http://marianoguerra.org/es/posts/riak-core-tutorial-part-1-setup/</guid><pubDate>Thu, 03 May 2018 12:32:23 GMT</pubDate></item></channel></rss>