Ibm cloud 有没有办法从Bluemix运行时访问NFS?

Ibm cloud 有没有办法从Bluemix运行时访问NFS?,ibm-cloud,Ibm Cloud,我需要将需要通过NFS访问远程文件系统的应用程序推送到Bluemix 我没有找到任何NFS服务。现有的对象存储服务使用Swift API,应用程序需要本机文件系统访问,而不是其他类型的API 我试图从应用程序初始化中执行“mkdir”和“mount”命令,但运行运行时的用户执行这些命令似乎有限制。我得到了表示错误的返回码 所以我没有主意了。你有什么建议或想法去探索吗? 我认为Dockers可能是一个选项(如果我可以挂载nfs文件系统,我还没有探索),但目前它处于测试阶段,所以还没有生产准备就绪

我需要将需要通过NFS访问远程文件系统的应用程序推送到Bluemix

我没有找到任何NFS服务。现有的对象存储服务使用Swift API,应用程序需要本机文件系统访问,而不是其他类型的API

我试图从应用程序初始化中执行“mkdir”和“mount”命令,但运行运行时的用户执行这些命令似乎有限制。我得到了表示错误的返回码

所以我没有主意了。你有什么建议或想法去探索吗? 我认为Dockers可能是一个选项(如果我可以挂载nfs文件系统,我还没有探索),但目前它处于测试阶段,所以还没有生产准备就绪


谢谢

NFS不受支持,但是CloudFoundry现在支持FUSE,它是NFS的一个非常接近的替代品

要利用FUSE,您需要使用
cflinuxfs2
堆栈

cflinuxfs2
是一个支持FUSE的新堆栈,请参见下文。CloudFoundry最近添加了FUSE支持

推送应用程序时,需要使用
-s
选项,示例如下

cf push myappname-s cflinuxfs2

更新:

海报上贴出了一个关于如何做到这一点的另一个问题。我把它贴在下面

好的,在团队同事的帮助下,我终于找到了问题的原因。问题在于私有ssh密钥的权限。它必须是600,在cf推送后默认为644

因此,这里是最后的代码(快速和肮脏)的工作,只是以防万一,它可以对其他人有用

1.-在应用程序中包含私钥和已知的_主机文件

2.-推送应用程序添加“-s cflinuxfs2”参数

3.-在运行时启动时执行以下代码:

String s = null;
Process p = null;
BufferedReader br = null;
try 
{
    p = Runtime.getRuntime().exec("mkdir -p /home/vcap/misc");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command mkdir with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("chmod 600 /home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/cloud.key");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command chmod with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("chmod 600 /home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/known_hosts");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command chmod with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("sshfs ibmcloud@129.41.133.34:/home/ibmcloud /home/vcap/misc -o IdentityFile=/home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/cloud.key -o StrictHostKeyChecking=yes -o UserKnownHostsFile=/home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/known_hosts -o idmap=user -o compression=no -o sshfs_debug");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command sshfs with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("ls -l /home/vcap/misc");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command ls with exit: " + p.exitValue());
    p.destroy();
    br.close();
}
catch(IOException ex)
{
    ex.printStackTrace();
}
catch(InterruptedException ex)
{
    ex.printStackTrace();
}
finally
{
    try 
    {
        if(br != null)
            br.close();
    }
    catch(IOException ex) 
    {
        ex.printStackTrace();
    }
}

此代码段应创建一个文件夹,将远程文件系统装入该文件夹,并列出远程文件系统的内容。

谢谢。真的很有趣。。。我会尝试一下。工作很好,我发布了一个样本作为我的答案更新,包括一个链接到您的答案,并张贴了代码,以便其他人可以找到它。
String s = null;
Process p = null;
BufferedReader br = null;
try 
{
    p = Runtime.getRuntime().exec("mkdir -p /home/vcap/misc");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command mkdir with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("chmod 600 /home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/cloud.key");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command chmod with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("chmod 600 /home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/known_hosts");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command chmod with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("sshfs ibmcloud@129.41.133.34:/home/ibmcloud /home/vcap/misc -o IdentityFile=/home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/cloud.key -o StrictHostKeyChecking=yes -o UserKnownHostsFile=/home/vcap/app/wlp/usr/servers/defaultServer/apps/myapp.ear/known_hosts -o idmap=user -o compression=no -o sshfs_debug");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command sshfs with exit: " + p.exitValue());
    p.destroy();
    br.close();

    p = Runtime.getRuntime().exec("ls -l /home/vcap/misc");
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while((s = br.readLine()) != null)
        System.out.println("line: " + s);
    p.waitFor();
    System.out.println ("#### Executing command ls with exit: " + p.exitValue());
    p.destroy();
    br.close();
}
catch(IOException ex)
{
    ex.printStackTrace();
}
catch(InterruptedException ex)
{
    ex.printStackTrace();
}
finally
{
    try 
    {
        if(br != null)
            br.close();
    }
    catch(IOException ex) 
    {
        ex.printStackTrace();
    }
}