2

当您有几个目录(大约 70 个)每个目录都有很多文件时,s3fs 挂载上的任何递归chownchmod命令都需要很长时间。

这些命令中的任何一个都可能需要将近 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

关于如何更快地做到这一点的任何想法?

4

3 回答 3

5

过了一会儿,我发现并行处理流程以加快速度会更好。例子:

find /s3fsmount/path/to/somewhere -print | xargs --max-args=1 --max-procs=100 chmod 777

它仍然很慢,但远没有以前那么慢。

于 2015-07-07T14:19:19.787 回答
1

使用aws cli可能会有所帮助。

我所做的:

  1. 用于aws cli获取目标目录的完整文件列表。
  2. 编写脚本以并行执行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;
    }
}

?>
于 2015-11-16T07:40:01.853 回答
0

对于更改用户

find /s3fsmount/path/to/somewher -print | xargs --max-args=1 --max-procs=100 sudo chown -R  user:user

它对我有用..

于 2021-02-14T01:13:02.837 回答