centos6.5 fastdfs分散ストレージの構築

7326 ワード

FastDFS分散ファイルシステム環境紹介システム:centos 6.5_64_mini FastDFSバージョン:FastDFS_v5.01実験ノードは以下の通りである:(注:以下の2つのノードのインストールと配置は全く同じ)SERVER 1 IP:192.168.100.250 SERVER 2 IP:192.168.100.251 1:インストールタイミング同期関連#yum install-y ntpdate#cp/usr/share/zoneinfo/ASia/Shanghai/etc/localtime#ntpdate us.pool.ntp.org 2:構成時間同期#crontab-e 3:以下のコード*/10***/usr/sbin/ntpdate usを入力.pool.ntp.org|logger-t NTP 4:関連依存パッケージのインストール#yum-y install gcc-c++openssl openssl-devel pcre-devel perl wget#mkdir/yunwei 8/soft#cd/yunwei 8/soft 5:必要なインストールパッケージをソフトウェアフォルダの下にダウンロード#wgethttp://down.yunwei8.com/soft/linux/libevent-2.0.21-stable.tar.gz#  wget http://down.yunwei8.com/soft/linux/FastDFS_v5.01.tar.gz #  wget http://down.yunwei8.com/soft/linux/fastdfs-nginx-module_v1.15.tar.gz#  wget http://down.yunwei8.com/soft/linux/nginx-1.6.0.tar.gz6:付属libevent#rpm-qa libevent#rpm-e--nodeps libevent-1.4.13-4を削除する.el6.x86_64 7:libevent-2.0.21#cd/yunwei 8/soft/#tar-zxvf libevent-2.0.2-stableをインストールします.tar.gz #  cd libevent-2.0.21-stable#  ./configure#make&&make install 8:libeventにソフトリンクを作成/libライブラリの下、64ビットシステム対応/lib 64#ln-s/usr/local/lib/libevent*/lib 64/#ln-s/usr/local/lib/lib/lib/9:FastDFSのインストールv5.01#  cd/yunwei8/soft#  tar -zxvf FastDFS_v5.01.tar.gz#  cd FastDFS/#  ./make.sh #  ./make.sh install 10:トラッカーtracker server 10.1フォルダ#mkdir-p/yunwei 8/data/fastdfs 10.2を構成trackerパラメータを変更し、base_を見つけるpath=/home/yuqing/fastdfs次のように変更します#vi/etc/fdfs/tracker.conf base_path=/yunwei 8/data/fastdfs 11:trackerサービス開始#/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf#  echo '/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf' >>/etc/rc.local 12:ストレージサービスstorage serverを構成し、関連パラメータ#mkdir-p/yunwei 8/data/fastdfs注:(trackerとstorageが異なるサーバで確立する必要がある場合)#mkdir/yunwei 8/data/images#vi/etc/fdfs/storage.conf base_を見つけたpath=/home/yuqing/fastdfs、次のように変更しますbase_path=/yunwei 8/data/fastdfs見つけstore_path 0=/home/yuqing/fastdfs、以下のように変更しますstore_path 0=/yunwei 8/data/images見つけtracker_server=192.168.209.121:22122、以下のtrackerを修正server=192.168.100.251:22122tracker_server=192.168.100.250:22122 13:storageサービス開始#/usr/local/bin/fdfs_storaged/etc/fdfs/storage.confには次のような長い列が表示されます.mkdir data path:00...mkdir data path: 01 ...mkdir data path: 02 ...mkdir data path: 03 ...mkdir data path: 04 ...mkdir data path: 05 ...mkdir data path: 06 ... 書き込みPOST起動#echo'/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf' >>/etc/rc.local 14:storage serverにnginxモジュール#cd/yunwei 8/soft/#tar-zxvf fastdfs-nginx-module_をインストールv1.15.tar.gz #  tar -zxvf nginx-1.6.0.tar.gz #  cd nginx-1.6.0#  ./configure --prefix=/yunwei8/server/nginx --add-module=../fastdfs-nginx-module/src#make&&make install 15:nginxパラメータの構成を変更すると、vi/yunwei 8/server/nginx/conf/nginxとなる.confworker_processes  1; events {    worker_connections  1024;} http {    include       mime.types;    default_type  application/octet-stream;    sendfile        on;    keepalive_timeout  65; server {    listen       80;    server_name  localhost;     location/group1/M00 {        alias/data/images/data;        ngx_fastdfs_module;}}}16:nginx起動スクリプト#vi/etc/initを記述する.d/nginxは、以下のコードを入力、
#!/bin/sh## nginx - this script starts and stops the nginx daemin## chkconfig:   - 85 15 # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \#               proxy and IMAP/POP3 proxy server# processname: nginx# config:      /yunwei8/server/nginx/conf/nginx.conf# pidfile:     /yunwei8/server/nginx/logs/nginx.pid  # Source function library.. /etc/rc.d/init.d/functions  # Source networking configuration.. /etc/sysconfig/network  # Check that networking is up.[ "$NETWORKING" = "no" ] && exit 0  nginx="/yunwei8/server/nginx/sbin/nginx"prog=$(basename $nginx)  NGINX_CONF_FILE="/yunwei8/server/nginx/conf/nginx.conf"  lockfile=/var/lock/subsys/nginx  start() {    [ -x $nginx ] || exit 5    [ -f $NGINX_CONF_FILE ] || exit 6    echo -n $"Starting $prog: "    daemon $nginx -c $NGINX_CONF_FILE    retval=$?    echo    [ $retval -eq 0 ] && touch $lockfile    return $retval}  stop() {    echo -n $"Stopping $prog: "    killproc $prog -QUIT    retval=$?    echo    [ $retval -eq 0 ] && rm -f $lockfile    return $retval}  restart() {    configtest || return $?    stop    start}  reload() {    configtest || return $?    echo -n $"Reloading $prog: "    killproc $nginx -HUP    RETVAL=$?    echo}  configtest() {  $nginx -t -c $NGINX_CONF_FILE}  rh_status() {    status $prog}  rh_status_q() {    rh_status >/dev/null 2>&1}  case "$1" in    start)        rh_status_q && exit 0        $1        ;;    stop)        rh_status_q || exit 0        $1        ;;    restart|configtest)        $1        ;;    reload)        rh_status_q || exit 7        $1        ;;    status)        rh_status        ;;    *)        echo $"Usage: $0 {start|stop|status|restart|reload|configtest}"        exit 2esac
,117を保存する:保存後、権限を設定して起動サービスリストに追加する#chmod 755/etc/init.d/nginx#chkconfig--add nginx#chkconfig--level 345 nginx on 18:nginxサービスを起動#service nginx start 19:storageのストレージディレクトリにソフト接続#ln-s/yunwei 8/data/images/data//yunwei 8/data/images/data/images/data/M 00 20:コピーmod_fastdfs.confから/etc/fdfs/#cp/yunwei 8/soft/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/21:mod_の変更fastdfs.conf構成#vi/etc/fdfs/mod_fastdfs.conf base_を見つけたpath=/tmp、次のように変更されましたbase_path=/yunwei 8/data/fastdfs見つけstore_path 0=/home/yuqing/fastdfs、以下のように変更しますstore_path 0=/yunwei 8/data/images url_を見つけたhave_group_name=fasle、次のurlを変更します.have_group_name=true tracker_を見つけたserver=tracker:22122、以下のtrackerを変更します.server=192.168.100.251:22122tracker_server=192.168.100.250:22122:tracker server上でclient#vi/etc/fdfs/clientを構成する.confクライアントパラメータを変更し、base_を見つけます.path=/home/yuqing/fastdfs、次のように変更しますbase_path=/yunwei 8/data/fastdfs tracker_を見つけたserver=192.168.0.197:22122、以下のtrackerを変更します.server=192.168.100.250:22122tracker_server=192.168.100.251:2212223:ファイアウォールは対応するポート#/sbin/iptables-I INPUT-p tcp--dport 80-j ACCEPT#/sbin/iptables-I INPUT-p tcp--dport 2212-j ACCEPT#/etc/rcを開放する.d/init.d/iptables save 24:テストファイルを作成する#cd/yunwei 8/yunwei 8というWebページ名を作成する.html#  vi yuwnei8.html入力ページ内容yunwei 8 25:終了と再起動25.1直接killを終了するとserverプロセスが正常に終了します.killallコマンドを使用して、#killall fdfs_trackerd#  killall fdfs_storagedはFastDFSが持参したstopも使用できる.shスクリプト、例えば#/usr/local/bin/stop.sh /usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf# /usr/local/bin/stop.sh  /usr/local/bin/fdfs_storaged/etc/fdfs/storage.confstop.shは、コマンドライン(パラメータを含む)が完全に同じプロセスを停止するだけです.-9パラメータを使用して強く殺さないでください.そうしないとbinlogデータが失われる可能性があります.25.2サーバプロセスをkillで削除した後、起動コマンドラインを実行します.例:#killall fdfs_trackerd#  killall fdfs_storaged# /usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf#  /usr/local/bin/fdfs_storaged/etc/fdfs/storage.confまたはFastDFSが持参するrestartを直接使用する.shスクリプト、例えば#/usr/local/bin/restart.sh  /usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf#  /usr/local/bin/restart.sh /usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf 26:アップロードテスト/usr/local/bin/restart.sh  /usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf# /usr/local/bin/fdfs_test/etc/fdfs/client.conf upload /yunwei8/yunwei8.html(絶対パス)27:アップロード出力のテストアドレスにアクセスhttp://192.168.100.250/group1/M00/00/00/wKhk-lNC56-ABoAZAAAAd6SYAsE45_yunwei8.html http://192.168.100.251/group1/M00/00/00/wKhk-lNC56-ABoAZAAAAd6SYAsE45_yunwei8.html