<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hello World!!&#187; S3</title>
	<atom:link href="http://bhags.org/?feed=rss2&#038;tag=s3" rel="self" type="application/rss+xml" />
	<link>http://bhags.org</link>
	<description>Welcome to Sinyu&#039;s  site</description>
	<lastBuildDate>Mon, 06 Nov 2017 04:17:27 +0000</lastBuildDate>
	<language>ja</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8.1</generator>
	<item>
		<title>AWS S3 Bucketを instanceにマウント</title>
		<link>http://bhags.org/?p=112</link>
		<comments>http://bhags.org/?p=112#comments</comments>
		<pubDate>Tue, 18 Jun 2013 11:24:12 +0000</pubDate>
		<dc:creator><![CDATA[bhags]]></dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[S3]]></category>

		<guid isPermaLink="false">http://bhags.org/?p=112</guid>
		<description><![CDATA[aws php library http://aws.amazon.com/jp/developer[...]]]></description>
				<content:encoded><![CDATA[<p>aws php library</p>
<p>http://aws.amazon.com/jp/developers/getting-started/php/</p>
<p>サーバで発生する大量のログをS3上で保管するための作業ログ<br />
&#8211;>> s3をCDNとして活用するためのログ</p>
<ol>
<li>S3　上で Bucket 生成
<li>S3上で生成されたBucketに下記権限を追加<br />
{<br />
  &#8220;Version&#8221;:&#8221;2012-10-17&#8243;,<br />
  &#8220;Statement&#8221;:[{<br />
	"Sid":"AddPerm",<br />
        "Effect":"Allow",<br />
	  "Principal": {<br />
            "AWS": "*"<br />
         },<br />
      "Action":["s3:GetObject"],<br />
      &#8220;Resource&#8221;:["arn:aws:s3:::{bucket name}/*"<br />
      ]<br />
    }<br />
  ]<br />
}</p>
<li>s3マウントに必要なライブラリインストール
<pre class="brush: bash; title: ; notranslate">
yum install gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel openssl-devel mailcap make
</pre>
<li>アクセスーキーの登録(AWSトップページの上部にあるメニューから［Your Account］－［Security Credentials］で「Access Credentials」のセクションにある［Access Keys］で「Access Key ID」と「Secret Access Key」の英数字列
<pre class="brush: bash; title: ; notranslate">
vim /etc/passwd-s3fs
accesskeyid:secretaccesskey
</pre>
<li>権限設定
<pre class="brush: bash; title: ; notranslate">chmod 600 /etc/passwd-s3fs </pre>
<li>s3fsのインストール
<pre class="brush: bash; title: ; notranslate">
wget http://s3fs.googlecode.com/files/s3fs-1.61.tar.gz
tar xvzf s3fs-1.61.tar.gz
cd s3fs-1.61/
./configure --prefix=/usr
make
sudo make install
</pre>
<li>Requested &#8216;fuse >= 2.8.4&#8242; but version of fuse is 2.8.3　エラー時
<pre class="brush: bash; title: ; notranslate">
yum remove fuse fuse*
[download latest fuse from here - &gt;http://sourceforge.net/projects/fuse/postdownload?source=dlp]
tar -zxf fuse-2.8.6.tar.gz
cd fuse-2.8.6
./configure --prefix=/usr
make
make install
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/
ldconfig
modprobe fuse
pkg-config --modversion fuse (should return new version)


&lt;li&gt;s3マウント
1
mkdir /mnt/s3 #マウント用のdirectory 生成
s3fs [自分のbucket名]  /mnt/s3 #マウント -o allow_other
</pre>
</ol>
<p>マウントは上記で終了<br />
以下ログバックアップのためのロジック</p>
<ol>
<li>batch時点の日付directory生成 #prev_batch_date < user_log_data_period　=<current_batch_date
<li>ユーザごとに保存されるdirectoryを検索
<pre class="brush: php; title: ; notranslate">
$userId =xxx #作業対象ユーザ
function findUserDirectory($userId,$directoryStr=&quot;&quot;){
     
     if($userId/$mod == 0){
     //現在のdirectory階層に保存
     
     }else{

     }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bhags.org/?feed=rss2&#038;p=112</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
