s3fs mount上的任何递归chown
或chmod
命令都需要很长时间,因为你有几个目录(大约70个),每个目录都包含很多文件。
这些命令中的任何一个都可能需要将近24小时。我必须这样做,否则Apache进程无法访问这些文件/目录。普通安装上的命令大约需要20秒。
使用以下方式安装:
/storage -o noatime -o allow_other -o use_cache=/s3fscache -o default_acl=public-read-write
在/etc/fuse.conf
:
user_allow_other
使用最新版本:1.78
关于如何更快地做到这一点的任何想法?
答案 0 :(得分:3)
过了一段时间,我发现最好将这些流程并行以加快速度。例如:
find /s3fsmount/path/to/somewhere -print | xargs --max-args=1 --max-procs=100 chmod 777
它仍然很慢,但远没有那么慢。
答案 1 :(得分:1)
使用aws cli
可能会有所帮助。
我的所作所为:
aws cli
获取目标目录的完整文件列表。chmod 777
到每个文件(> /dev/null 2>&1 &
)然后我发现chmod作业立即从ps -ef
完成。
我的PHP代码:
<?php
$s3_dir = 'path/to/target/';
$s3fs_dir = '/mnt/s3-drive/' .$s3_dir;
echo 'Fetching file list...' . "\n\n";
sleep(1.5);
$cmd = 'aws s3 ls --recursive s3://<bucket_name>/' . $s3_dir;
exec($cmd, $output, $return);
$num = 0;
if ( is_array($output) ) {
foreach($output as $file_str) {
if ( $num>100 ) {
sleep(4);
$num=0;
}
$n = sscanf( $file_str, "%s\t%s\t%s\t". $s3_dir ."%s", $none1, $none2, $none3, $file );
$cmd = 'chmod 777 ' . $s3fs_dir . $file . ' > /dev/null 2>&1 &';
echo $cmd ."\n";
exec( $cmd );
$num+=1;
}
}
?>
答案 2 :(得分:0)
更改用户
find /s3fsmount/path/to/somewher -print | xargs --max-args=1 --max-procs=100 sudo chown -R user:user
它对我有用..