海运的博客

Linux下资源容器

发布时间:July 24, 2014 // 分类:Linux服务 // No Comments

FastDFS配合FastDHT去重

发布时间:January 28, 2014 // 分类:Linux服务 // No Comments

FastDHT使用Berkeley DB为后端存储,安装:

wget https://fastdht.googlecode.com/files/FastDHT_v1.23.tar.gz
tar zxvf FastDHT_v1.23.tar.gz 
cd FastDHT
./make.sh C_INCLUDE_PATH=/usr/local/BerkeleyDB.6.0/include \
LIBRARY_PATH=/usr/local/BerkeleyDB.6.0/lib/
./make.sh install
mkdir -p /home/yuqing/fastdht
echo "/usr/local/BerkeleyDB.6.0/lib/" > /etc/ld.so.conf.d/db.conf
ldconfig

配置fastdht:

/etc/fdht/fdht_servers.conf
group_count = 2
group0 = 192.168.1.1:11411
group0 = 192.168.1.2:11411
group1 = 192.168.1.1:11411
group1 = 192.168.1.2:11411

配置fastdfs storage

/etc/fdfs/storage.conf 
check_file_duplicate=1
file_signature_method=hash
key_namespace=FastDFS
keep_alive=1
#include /etc/fdht/fdht_servers.conf

再次测试上传多次同个文件,重复上传的文件以链接方式保存。

分布式存储FastDFS使用

发布时间:January 28, 2014 // 分类:Linux服务 // No Comments

安装:

yum install -y libevent-devel pcre-devel zlib-devel
wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz
tar zxvf FastDFS_v4.06.tar.gz
cd FastDFS
./make.sh && ./make.sh install

配置tracker:

/etc/fdfs/tracker.conf 
base_path=/home/fastdfs #工作目录,记录日志相差信息
bind_addr=0.0.0.0
port=22122
run_by_group=fastdfs
run_by_user=fastdfs

配置storage:

/etc/fdfs/storage.conf 
group_name=group1 #服务器所在组,组内服务器数据同步
base_path=/home//fastdfs
store_path0=/home/fastdfs #数据目录
tracker_server=192.168.1.1:22122 #tracker服务器

配置client:

/etc/fdfs/client.conf 
tracker_server=192.168.1.1:22122

测试上传:

fdfs_test /etc/fdfs/client.conf upload .bashrc 

查看group/storage信息及删除storage:

fdfs_monitor /etc/fdfs/client.conf
fdfs_monitor /etc/fdfs/client.conf delete group1 192.168.1.1

安装配置php客户端:

cd php_client/
./configure
make && make install
cp fastdfs_client.ini /etc/php.d/
#配置调用上面配置的/etc/fdfs/client.conf 

使用php上传文件:

<?php
$tracker = fastdfs_tracker_get_connection();
var_dump($tracker);
$storage = fastdfs_tracker_query_storage_store();
var_dump($storage);
$ret = fastdfs_storage_upload_by_filename('fastdfs.spec');
var_dump($ret);
$ret = fastdfs_storage_upload_by_filename1('fastdfs.spec');
var_dump($ret);
$file = file_get_contents("fastdfs.spec");
$ret = fastdfs_storage_upload_by_filebuff($file, 'spec');
var_dump($ret);
$ret = fastdfs_storage_upload_by_filebuff1($file, 'spec');
var_dump($ret);
?>

storage存储安装Nginx模块,用于提供文件下载,文件不存在时通过tracker获取同组内其它storage数据:

wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz
./configure --add-module=/root/fastdfs-nginx-module/src
cp mod_fastdfs.conf /etc/fdfs/ #配置文件

插件配置:

tracker_server=192.168.1.1:22122
group_name=group1
url_have_group_name = false #url是否包含组名
response_mode=proxy #向其它storage获取数据方式,代理或重定向
    #location /grout0/M00 { #url_have_group_name要设置为true
    location /M00 {
            root /home/yuqing/fastdfs/data;
            ngx_fastdfs_module;
    }

直接使用Nginx提供文件访问,不通过tracker:

  location /M00 {
    alias /home/yuqing/fastdfs/data;
    #ngx_fastdfs_module;
  }

此内容被密码保护

发布时间:January 12, 2014 // 分类:Linux服务 // No Comments

请输入密码访问

此内容被密码保护

发布时间:January 12, 2014 // 分类:Linux服务 // 2 Comments

请输入密码访问

分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...