Sheepdog HTTP API

1、sheepdog中http simple storage中nginx后台配置文件模板留存:

events {

worker_connections 1024;
}

http {
server {
listen 80;
server_name localhost;

location / {
fastcgi_pass localhost:8000;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param HTTP_RANGE $http_range;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param REQUEST_URI $request_uri;
}
}

client_max_body_size 0;
}

2、sheepdog中HTTP API未实现POST操作,但已实现GET、HEAD、DELETE、PUT操作。

3、客户端可使用httpie(linux)或者libcurl等。

其中httpie安装(ubuntu)使用如下:

pip install --upgrade httpie

$ http PUT http://localhost/v1/mandy # create a user account named 'mandy'
$ http PUT http://localhost/v1/mandy/books # create a book container for 'mandy'
$ http PUT http://localhost/v1/mandy/movies # create a movie container for 'mandy'
$ http GET http://localhost/v1/mandy # to see what containers 'mandy' has
$ http PUT http://localhost/v1/mandy/books/yourbookname < yourbook # upload your book
$ http PUT http://localhost/v1/mandy/movies/yourmoviename < yourmovie
$ http HEAD http://localhost/v1/mandy/movies/ # Get the statistics of movie container
$ http GET http://localhost/v1/mandy/books/yourbookname > yourbook # Download your book
$ http DELETE http://localhost/v1/mandy/books/yourbookname # delete the book in the container

4、HTTP浏览器客户端调用PUT时,如若提示跨域问题,一般方案可使用JSONP解决;但在实践中,通过nginx中配置OPTIONS操作的返回值来实现,因为浏览器端发送HTTP PUT之前会发送OPTIONS进行校验。

附(编译sheepdog0.9.2):

编译过程中出现权限拒绝,请改(递归目录可使用-R)目录权限(为方便可改为777或+x)

sheepdog 0.9.2

sudo apt-get install libfuse-dev
sudo apt-get install yasm
apt-get install libcurl4-gnutls-dev
apt-get install nginx
apt-get install lighttpd
./autogen.sh
./configure --enable-http
make
make install

出现error while loading shared libraries:libfcgi.so.0
编辑文件 /etc/ld.so.conf添加一行:
------
/usr/local/lib/
------

然后刷新一下:
ldconfig
执行如下指令查看:
ldconfig -p | grep libfcgi.so.0

修改配置文件后开启服务
nginx -c /etc/nginx/nginx.conf


目前仅支持local和zookeeper 1.4.5 or plus
sheep -c local -r swift

collie cluster format -c 1

原文地址:https://www.cnblogs.com/wangzhigang/p/5085104.html