您的位置:首页 > 运维架构 > Linux

Centos6.5里安装Erlang 并安装riak

2015-08-22 02:13 776 查看
一.Erlang安装:

1 首先进入www.erlang.org 下载页面,下载otp_src_17.5.tar.gz. IT网,http://www.it.net.cn

2 解压缩:tar -xzvf otp_src_17.5.tar.gz Linux学习,http:// linux.it.net.cn

3 进入解压缩后的文件夹:cd otp_src_17.5.tar.gz

4 如果直接运行./configure,会提示没有curses库,所以首先还得安装这个库:yum install ncurses-devel,运行此命令需要具备root权限。

5 运行./congigure命令。

6 运行make命令。

7 运行make install命令。

安装成功后,在命令行输入erl,则erlang shell便会运行起来。至此,安装完全成功。

yum install gcc

riak安装:
http://docs.basho.com/riak/1.3.2/tutorials/installation/Installing-on-RHEL-and-CentOS/
备注:(不知道有什么卵用)

package com.demo;

import java.io.IOException;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.RiakException;
import com.basho.riak.client.RiakFactory;
import com.basho.riak.client.RiakRetryFailedException;
import com.basho.riak.client.bucket.Bucket;

public class ClientTest {

public static void main(String[] args) throws IOException {

IRiakClient client = null;
try {// 使用pbc方式连接,而不是http,在/etc/riak/app.config
client = RiakFactory.pbcClient("192.168.1.111", 8087);
} catch (RiakException e) {
e.printStackTrace();
}
// 显示.
System.out.println(client);
Bucket myBucket = null;
String bucketName = "userInfo";
try {
myBucket = client.fetchBucket(bucketName).execute();
if (myBucket == null) {
myBucket = client.createBucket(bucketName).execute();
}
} catch (RiakRetryFailedException e) {
e.printStackTrace();
}
// ################保存数据 .
UserInfo info = new UserInfo();
info.setUid("001");
info.setName("张三");
info.setCity("北京");
try {
myBucket.store(info.getUid(), info).execute();
} catch (Exception e) {
e.printStackTrace();
}

// ################查询数据.
UserInfo fetchedUserInfo = null;
try {
fetchedUserInfo = myBucket.fetch("001", UserInfo.class).execute();
System.out.println(fetchedUserInfo);
} catch (Exception e) {
e.printStackTrace();
}
// ################修改数据.
try {
fetchedUserInfo = myBucket.fetch("001", UserInfo.class).execute();
fetchedUserInfo.setName("李四");
fetchedUserInfo.setNickName("老李");
myBucket.store(info.getUid(), info).execute();
// 保存 新数据
fetchedUserInfo = myBucket.fetch("001", UserInfo.class).execute();
System.out.println("新数据:" + fetchedUserInfo);
} catch (Exception e) {
e.printStackTrace();
}

// ################删除数据.
try {
myBucket.delete("001").execute();
fetchedUserInfo = myBucket.fetch("001", UserInfo.class).execute();
System.out.println("删除收数据." + fetchedUserInfo);
} catch (Exception e) {
e.printStackTrace();
}
// 关闭。
client.shutdown();

}

}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: