CentOS 7.5下搭建高可用的FastDFS分布式文件系统(2)

[root@storage71 fastdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/test.jpg group_name=group1, ip_addr=192.168.5.72, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKgFSFvAem6AfpJXAAA2FXv_nRs556.jpg source ip address: 192.168.5.72 file timestamp=2018-10-12 18:41:50 file size=13845 file crc32=2080349467 example file url: storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKgFSFvAem6AfpJXAAA2FXv_nRs556_big.jpg source ip address: 192.168.5.72 file timestamp=2018-10-12 18:41:51 file size=13845 file crc32=2080349467 example file url:

CentOS 7.5下搭建高可用的FastDFS分布式文件系统

通过客户端连接并上传文件:

#上传"/etc/passwd"文件到fastdfs服务器: # fdfs_upload_file /etc/fdfs/client.conf /etc/passwd 下载刚才上传的文件: # fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKgFSFvBpdSAB33ZAAI8IU3BQ48068.jpg 查看文件属性: # fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/wKgFSFvBpdSAB33ZAAI8IU3BQ48068.jpg 删除上传的文件: # fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgFSFvBpdSAB33ZAAI8IU3BQ48068.jpg # fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgFSFvBtTuAGz2VAAAJHTkxfCU312.txt 监控fastdfs的状态: # fdfs_monitor /etc/fdfs/client.conf

###------------------- 在storage server上安装nginx -------------------------###

#安装nginx关于fastdfs集合的扩展模块,注意这个模块nginx默认的编译模块中没有,需手动下载安装

cd /opt wget #jemalloc 优化nginx,内存管理 wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2 wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz #nginx缓存清理模块 wget git clone https://github.com/happyfish100/fastdfs-nginx-module.git

yum -y install openssl openssl-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel

tar -jxvf jemalloc-5.1.0.tar.bz2 cd jemalloc-5.1.0 ./configure --prefix=/usr/local/jemalloc --libdir=/usr/local/lib make;make install echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf ldconfig cd ../ /usr/sbin/groupadd www /usr/sbin/useradd -g www www -s /sbin/nologin tar -zxvf pcre-8.42.tar.gz tar -zxvf ngx_cache_purge-2.3.tar.gz tar -zxvf nginx-1.15.5.tar.gz cd nginx-1.15.5 ./configure --prefix=/usr/local/nginx \ --with-pcre=/opt/pcre-8.42 \ --user=www \ --group=www \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_gzip_static_module \ --with-ld-opt="-ljemalloc" \ --with-http_realip_module \ --add-module=/opt/fastdfs-nginx-module/src \ --add-module=/opt/ngx_cache_purge-2.3 make;make install

#修改mod_fastdfs配置文件

cp /opt/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ cd /opt/fastdfs/conf/ #进入fastdfs安装包文件夹 cp anti-steal.jpg http.conf mime.types /etc/fdfs/ vi /etc/fdfs/mod_fastdfs.conf base_path=/tmp 改为 base_path=/data/fastdfs tracker_server=tracker:22122 改为 tracker_server=192.168.5.71:22122 store_path0=/home/yuqing/fastdfs 改为 store_path0=/data/fastdfs url_have_group_name = false 改为 true

#配置nginx

server { listen 80; server_name 192.168.5.72; location /group1/M00 { ngx_fastdfs_module; } }

#添加nginx启动脚本

cat >> /etc/init.d/nginx <<EOF #! /bin/sh ulimit -n 65535 # Description: Startup script for nginx # chkconfig: 2345 55 25 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="nginx daemon" NAME=nginx DAEMON=/usr/local/nginx/sbin/$NAME CONFIGFILE=/usr/local/nginx/conf/$NAME.conf PIDFILE=/usr/local/nginx/logs/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME set -e [ -x "$DAEMON" ] || exit 0 do_start() { $DAEMON -c $CONFIGFILE || echo -n "nginx already running" } do_stop() { kill -INT `cat $PIDFILE` || echo -n "nginx not running" } do_reload() { kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload" } case "$1" in start) echo -n "Starting $DESC: $NAME" do_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" do_stop echo "." ;; reload|graceful) echo -n "Reloading $DESC configuration..." do_reload echo "." ;; restart) echo -n "Restarting $DESC: $NAME" do_stop do_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2 exit 3 ;; esac exit 0 EOF

#将nginx添加到启动服务中

chmod 700 /etc/init.d/nginx /sbin/chkconfig --add nginx /sbin/chkconfig --level 2345 nginx on

#启动nginx

[root@storage72 opt]# /etc/init.d/nginx start Starting nginx daemon: nginxngx_http_fastdfs_set pid=21702

#查看jemalloc内存管理

lsof -n | grep jemalloc

###------------------ tracker server端做nginx反向代理 ----------------------###

#nginx.conf配置

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/76666a2be68706cfecbbd94c74b005af.html