mogilefs + nginx 图片分布式存储

通过mogilefs + nginx实现图片的分布式存储和访问

分布存储代码

/**
*key 存储的的访问路径
*storageClass nginx中配置
*file 需要分布式图片文件
*/
import com.guba.mogilefs.PooledMogileFSImpl;

pooledMogileFS.storeFile(key, storageClass, file);

pooledMogileFS 的spring配置文件

<bean id="pooledMogileFS" class="com.guba.mogilefs.PooledMogileFSImpl">
      <constructor-arg index="0" value="yododo" /><!-- domain -->
      <constructor-arg index="1"><!-- trackers -->
         <list>
            <value>192.168.1.5:7001</value>
         </list>
      </constructor-arg>
      <constructor-arg index="2" value="100" /><!-- maxTrackerConnections -->
      <constructor-arg index="3" value="10" /><!-- maxIdleConnections -->
      <constructor-arg index="4" value="600000" /><!-- maxIdleTimeSecs -->
   </bean>

nginx配置文件

    upstream mogile {
      server 192.168.1.5:7000 max_fails=1;
      server 192.168.1.5:7000 max_fails=1;
    }


       location /micro/photo/ {
          proxy_pass   http://mogile;
          include     proxy.conf;
          expires     45d;
       }
 

猜你喜欢

转载自yangjayup.iteye.com/blog/1663127
今日推荐