fastdfs

部署分布式存储服务
一、分布式文件系统介绍

二、配置分布式存储服务
2.1 配置主控节点(111) 装包 修改配置文件 启动服务 查看端口
]# yum -y install gcc gcc-c++ libevent
]# cd fastdfs
]# yum -y install libevent-*.rpm
]#tar -zxf FastDFS_v4.06.tar.gz
]#cd FastDFS
]#./make.sh
]#./make.sh install
]# ls /etc/fdfs/ #配置文件存放目录
]# ls /usr/local/bin/ #命令文件存放目录

]# vim /etc/fdfs/tracker.conf //服务主配置文件
base_path=/data/fastdfs
max_connections=4096

store_group=group1
use_storage_id = true
storage_ids_filename = storage_ids.conf

]# mkdir -p /data/fastdfs
]# cd FastDFS
]# cp conf/storage_ids.conf /etc/fdfs/
]# vim /etc/fdfs/storage_ids.conf

[root@mon111 FastDFS]# tail -2 /etc/fdfs/storage_ids.conf
100001 group1 192.168.4.108
100002 group1 192.168.4.109

]#cd FastDFS
]# cp init.d/fdfs_trackerd /etc/init.d/
]# chmod +x /etc/init.d/fdfs_trackerd
]# /etc/init.d/fdfs_trackerd status
fdfs_trackerd 停止

]# netstat -utnalp | grep :22122

++++++++++++++++++++++++++++++++++
2.2 配置数据节点 108 109
准备存储空间:分区 格式化 配置开机挂载到/data/fastdfs
172 fdisk /dev/vdb
173 fdisk -l /dev/vdb

174 mkfs.ext4 /dev/vdb1
175 mkdir -p /data/fastdfs
176 blkid /dev/vdb1

]#vim /etc/fstab
UUID=f2853b35-13d3-48b1-8c3f-9b9e5f225fca /data/fastdfs ext4 defaults 0 0

]# mount -a
]# mount | grep /data/fastdfs
/dev/vdb1 on /data/fastdfs type ext4 (rw)
装包 修改配置文件 启动服务 查看端口
2 yum -y install gcc gcc-c++ libevent
6 yum -y install libevent-*.rpm
]#tar -zxf FastDFS_v4.06.tar.gz
]#cd FastDFS
]#./make.sh
]#./make.sh install
]# ls /etc/fdfs/ #配置文件存放目录
]# ls /usr/local/bin/ #命令文件存放目录

]# vim /etc/fdfs/storage.conf
base_path=/data/fastdfs

max_connections=4096store_path0=/data/fastdfs
subdir_count_per_path=256

tracker_server=192.168.4.111:22122
++++++++++++++++++++++++++++++++
2.3 启动服务
2.3.1 启动主控节点主机上的服务trackerd
209 /etc/init.d/fdfs_trackerd status
210 /etc/init.d/fdfs_trackerd start
211 netstat -utnalp | grep :22122
212 ps -C fdfs_trackerd
]#cd /data/fastdfs/
]#ls
data logs
219 cat data/storage_changelog.dat
221 vim logs/trackerd.log

2.3.2 启动数据节点主机上的storaged服务
193 cd FastDFS
197 cp init.d/fdfs_storaged /etc/init.d/
198 chmod +x /etc/init.d/fdfs_storaged
]# /etc/init.d/fdfs_storaged start
]#netstat -utnalp | grep :23000

++++++++++++++++++++++++++++++++++++
2.3 在客户端测试配置 250 、254
254:
]# ping -c 2 192.168.4.111
]# echo $PATH
]# mkdir /root/bin

创建连接主控服务器111的配置文件
]# scp 192.168.4.108:/etc/fdfs/client.conf /root/

]# vim /root/client.conf
10 base_path=/data/fastdfs
14 tracker_server=192.168.4.111:22122
:wq

]# mkdir -p /data/fastdfs

108:
把命令行,操作文件的命令传给客户端
]# scp fdfs_test 192.168.4.254:/root/bin/
]# scp fdfs_upload_file 192.168.4.254:/root/bin/
]# scp fdfs_download_file 192.168.4.254:/root/bin/
]# scp fdfs_delete_file 192.168.4.254:/root/bin/

250:
上传文件:
显示上传文件过程fdfs_test
不显示上传文件过程 fdfs_upload_file

]# fdfs_test 配置文件 上传 文件名

]# fdfs_test /root/client.conf upload foo.sh
]#fdfs_upload_file /root/client.conf /etc/passwd

删除文件
]# fdfs_test /root/client.conf delete group1 M00/00/00/wKgEbVp7fh-AdtHSAAAJ6YX0WVM0035120

下载文件
++++++++++++++++++++++++++++++++
把数据节点主机110添加到存储组group1里
110的配置: 准备存储空间 装包 修改配置文件 启动服务 查看端口

111的配置: 修改storage_ids.conf 添加新的存储主机
重启tracked 服务

250客户端测试:

++++++++++++++++++++++++++++++++++
在存储服务器上配置web服务,让客户端访问存储服务器的web服务上传和下载文件
108
1 运行nginx网站服务: 装包 修改配置文件 启动服务 查看端口
]# netstat -utnalp | grep :80
]# systemct stop httpd ; systemctl disable httpd

]# yum -y install gcc gcc-c++
]# useradd nginx
]# yum -y install pcre-devel zlib-devel

]#tar -zxf fastdfs-nginx-module_v1.16.tar.gz
]#tar -zxf nginx-1.7.10.tar.gz
]#cd nginx-1.7.10
]# ./configure --prefix=/usr/local/nginx --user=nginx
--group=nginx --add-module=../fastdfs-nginx-module/src/

]# make && make install
]# ls /usr/local/nginx/
conf html logs sbin

]# cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
]# vim /etc/fdfs/mod_fastdfs.conf
40 tracker_server=192.168.4.111:22122
53 url_have_group_name = true
47 group_name=group1
57 store_path_count=1
62 store_path0=/data/fastdfs/:wq

]#vim /usr/local/nginx/conf/nginx.conf
43 location / {
44 #root html;
45 #index index.html index.htm;
ngx_fastdfs_module;
46 }
:wq

[root@web108 ~]# /etc/init.d/fdfs_storaged stop
stopping fdfs_storaged ...
..
[root@web108 ~]# /etc/init.d/fdfs_storaged start
Starting FastDFS storage server:

[root@web108 ~]# /usr/local/nginx/sbin/nginx -t
ngx_http_fastdfs_set pid=8668
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@web108 ~]#

[root@web108 ~]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=8674
[root@web108 ~]#

配置109 : 可以供客户端以web的方式访问。
装包 修改配置文件 启动服务

++++++++++++++++++++++++++++++++++++++++

客户端访问:
254: 上传文件
[root@room8pc205 ~]# ls *.jpg
tedu.jpg
[root@room8pc205 ~]# fdfs_upload_file /root/client.conf ./tedu.jpg
group1/M00/00/00/wKgEbFp7nlWABtXMAACwEV-ILDc616.jpg
[root@room8pc205 ~]#

254: 通过访问web页面下载文件
]#firefox http://192.168.4.108/group1/M00/00/00/wKgEbFp7nlWABtXMAACwEV-ILDc616.jpg

http://192.168.4.108
80 -----> nginx----->连接tracked服务的模块->模块读取配置文件---> 访问taracked服务器--->配置文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章