How to set up Riak on El Capitan

I needed a Riak install separate from existing projects’ installations to work on a new project. I ran into some trouble. OSX keeps changing the way it handles configurations like maximum open files, so existing doc was out-of-date.

Install Homebrew (http://brew.sh)

> /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

Use Homebrew to install Riak

> brew install --devrel riak

Set your max open file limit to 65536

Riak opens a lot of files at once. OSX is set by default to open only a 4048 files at a time. El Capitan has a utility called csrutil  that protects the operating system by preventing certain configuration changes. 
Edit /Library/LaunchDaemons/limit.maxfiles.plist to look like the following:
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"  
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">  
  <dict>
    <key>Label</key>
    <string>limit.maxfiles</string>
    <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</strig>
      <string>524288</string>
      <string>524288</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist>
Edit /Library/LaunchDaemons/limit.maxproc.plist to look like the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN"
      "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
     <key>Label</key>
     <string>limit.maxproc</string>
     <key>ProgramArguments</key>
     <array>
       <string>launchctl</string>
       <string>limit</string>
       <string>maxproc</string>
       <string>2048</string>
       <string>2048</string>
     </array>
     <key>RunAtLoad</key>
     <true />
     <key>ServiceIPC</key>
     <false />
   </dict>
 </plist>
> chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist

> chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist

> chmod 644 /Library/LaunchDaemons/limit.maxfiles.plist

> chmod 644 /Library/LaunchDaemons/limit.maxproc.plist

> sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist

> sudo launchctl load -w /Library/LaunchDaemons/limit.maxproc.plist
Run
> ulimit -n 65536
and add it to your .bashrc , .zshrc , or their analog.

Start Riak

> riak start
> riak ping
Did you get pong?
> riak-admin test
Did it give you an error?

Use Riak

Make set a value
> curl -v -XPUT -d 'Hello, world!' http://127.0.0.1:8098/buckets/MYBUCKET/keys/MYKEY
Get a value
> curl http://127.0.0.1:8098/buckets/MYBUCKET/keys/MYKEY 
Delete a value
> curl -v -X DELETE http://127.0.0.1:8098/buckets/MYBUCKET/keys/MYKEY

Additional Info

Your configuration file is here: /usr/local/opt/riak/libexec/etc/riak.conf 
Your data directory (defined in that file) is here: /usr/local/var/lib/riak . You can completely reset your data by deleting its contents.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s