Riak node no longer working after changing IP address

风格不统一 提交于 2019-12-04 10:01:44

So after some more digging around and intense reading, I've found a solution:

You need to remove the Riak ring and start Riak again to reset riak_core.

You can do this by using this command in the terminal:

rm -rf /var/lib/riak/ring/*

  • NOTE: This should be done after you've updated app.config and vm.args with the new server IP, nasty side-effects can occur otherwise.

Then

riak start

I was no longer thrown a 'failed to connect' error, and after issuing a riak-admin test command I pleasantly received (where y.y.y.y is my instance's private IP):

>Attempting to restart script through sudo -H -u riak
>Successfully completed 1 read/write cycle to 'riak@y.y.y.y'

I should note that this solution applies to virtual servers as well as physical ones. Although I would imagine the reassigning of IP's would be a much rarer occurrence in physical servers.

Now while that solves the issue, it still means whenever I need to reboot the instance I have to go through editing the app.config and vm.args files to change the private IP address (remember the private IP changes every time an Ubuntu instance is started/stopped) and then clear the Riak ring using the command above, so it's not exactly an elegant solution.

If anyone knows a way to set a static private IP to an EC2 instance (or another solution that tackles both hurdles?) it would solve this problem outright.

EDIT: 14/12/12

A limited solution to assigning a static IP to an EC2 instance:

Amazon Web Services allows the association of Elastic IP's to EC2 instances (of any kind). Therefore, if an instance has an elastic IP associated with it, even if it is rebooted, that IP will remain associated with that instance. You can find the documentation on elastic IP's here.

If you're under Amazon's free usage tier, creating an Elastic IP shouldn't charge you as long as it's associated with a running instance. If an elastic IP is disassociated, Amazon will incur charges for each running hour of an unused Elastic IP for as long as that Elastic IP remains disassociated. For example, terminating an instance will disassociate an elastic IP, unless that elastic IP is re-associated or released, the above applies. Stopping your instance entirely then starting it at a later time will also disassociate an elastic IP.

You can have a maximum of one elastic IP per an instance, any more and this will incur charges.

For those interested, you can find more information Elastic IP's pricing here under Elastic IP Addresses.

As of Riak 1.3, riak-admin reip is deprecated and the use of riak-admin cluster replace is the recomended way of replacing a cluster's name.

These are the commands I had to issue:

riak stop # stop the node
riak-admin down riak@127.0.0.1 # take it down
sudo rm -rf /var/lib/riak/ring/* # delete the riak ring
sudo sed -i "s/127.0.0.1/`hostname -i`/g" /etc/riak/vm.args # Change the name in config
riak-admin cluster force-replace riak@127.0.0.1 riak@"`hostname -i`" # replace the name
riak start # start the node

That should set the node's name to riak@[your EC2 internal IP address].

As well as changing the PB and HTTP IP's in the app.config, and the vm.args IP I also had to run:

http://docs.basho.com/riak/1.2.0/references/Command-Line-Tools---riak-admin/#reip

Without doing this, running riak console and looking in the output, the old IP is still present in the error log.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!