fastdfs storage安裝

資源包可以從以下地址獲取:

 https://download.csdn.net/download/u012329294/12256109

 

 

1、在centos7上安裝相關的編譯環境

 yum -y install gcc gcc+ gcc-c++ openssl openssl-devel pcre pcre-d                                                        eve

 2、安裝libfastcommon

tar xvfz libfastcommon-1.0.43.tar.gz
cd libfastcommon-1.0.43
./make.sh
./make.sh install

 3、建立fastcommon軟連接,以便安裝程序能找到相關的庫文件:

ln -sv /usr/include/fastcommon/ /usr/local/include/fastcommon
ln -sv /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so

4、安裝fastdfs 

tar xvfz fastdfs-6.06.tar.gz
cd fastdfs-6.06/
./make.sh
./make.sh install

5、建立fastdfs軟連接

ln -sv /usr/include/fastdfs /usr/local/include/fastdfs

6、 存儲節點配置,建立數據存儲目錄

mkdir -p /data/fdfs_storage/base
mkdir -p /data/fdfs_storage/storage0
mkdir -p /data/fdfs_storage/storage1

7、編輯存儲節點配置

 

cd /etc/fdfs
cp storage.conf.sample storage.conf
vi storage.conf

 

8、編輯配置


base_path = /data/fdfs_storage/base

store_path_count = 2


store_path0 = /data/fdfs_storage/storage0
store_path1 = /data/fdfs_storage/storage1

tracker_server = 192.168.1.170:22122

9、啓動存儲節點,查看狀態

service fdfs_storaged start

fdfs_monitor /etc/fdfs/storage.conf

 10、安裝nginx和fastdfs-nginx-module

tar xvfz nginx-1.16.1.tar.gz
tar xvfz fastdfs-nginx-module-1.22.tar.gz

 11、添加模塊到nginx中

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.17.0/debian/debuild-base/nginx-1.17.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-module=/opt/fastdfs-nginx-module-1.22/src

make && make install

12、檢測nginx是否安裝成功,能找到,表示nginx安裝成功

which nginx

/usr/sbin/nginx

13、複製相關文件

cp /opt/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs
cd /opt/fastdfs-6.06/conf/
cp anti-steal.jpg http.conf mime.types /etc/fdfs

14、配置mod_fastdfs.conf

vi /etc/fdfs/mod_fastdfs.conf

tracker_server=192.168.1.170:22122


group_name=group2
url_have_group_name = true


store_path_count=2

store_path0=/data/fdfs_storage/storage0
store_path1=/data/fdfs_storage/storage1

15、配置nginx.conf

server {
        listen       8081;
        server_name  localhost;


        location ~ /group[0-9]/M0[1-9] {
            ngx_fastdfs_module;
        }

    }

16、啓動nginx,出現getpwnam("nginx") failed,參見https://blog.csdn.net/u012329294/article/details/104963887

17、配置軟連接,重新啓動nginx,關閉防火牆

ln -s /data/fdfs_storage/storage0 /data/fdfs_storage/storage0/M00
ln -s /data/fdfs_storage/storage1 /data/fdfs_storage/storage1/M00

nginx -s reload

service firewalld stop

18、在tracker服務器上配置nginx

[root@170 ~]# cat /etc/nginx/nginx.conf

user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        /usr/local/nginx/nginx-1.14.0/logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;
    client_max_body_size 50M;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    upstream fdfs_group {
        server 192.168.1.170:8081;
        server 192.168.1.66:8081;
    }

    server {
        listen 8080;
        server_name localhost;

        location ~/group[1-9] {
            proxy_pass http://fdfs_group;
        }
    }

    server {
        listen 8081;
        server_name localhost;

        location ~/group[0-9]/M0[0-9] {
           ngx_fastdfs_module;
           #root /data/fdfs_storage/storage0;
        }
    }
}

19、調試和定位

tail -f /var/log/nginx/error.log

 

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