【问题标题】:Error on trying to run a simple RPC program尝试运行简单的 RPC 程序时出错
【发布时间】:2012-05-13 23:45:57
【问题描述】:

我正在尝试运行一个使用 rpcgen 创建的简单 RPC 程序。 它是一个简单的阶乘程序。这是我的第一个 RPC 程序。 制作工作正常。还创建了可执行文件。 但是在尝试运行可执行文件时,我收到此错误:

$sudo ./fact_server 
Cannot register service: RPC: Unable to receive; errno = Connection refused
unable to register (FACTPROGRAM, FACTVERSION, udp).

我尝试在另一台具有相同操作系统 (ubuntu) 的电脑上运行相同的程序。它在那里运行完美。

【问题讨论】:

  • 听起来你要绑定的端口上已经有其他东西在运行
  • 尝试运行/etc/init.d/rpcbind start

标签: c ubuntu rpc


【解决方案1】:

首先检查端口映射器是否工作,使用rpcinfo 进行检查。 如果遇到任何错误,请安装portmap

【讨论】:

    【解决方案2】:

    使用rpcinfo检查服务是否正在运行。这就是我得到的。

    $ rpcinfo 
       program version netid     address                service    owner
        100000    4    tcp6      ::.0.111               portmapper superuser
        100000    3    tcp6      ::.0.111               portmapper superuser
        100000    4    udp6      ::.0.111               portmapper superuser
        100000    3    udp6      ::.0.111               portmapper superuser
        100000    4    tcp       0.0.0.0.0.111          portmapper superuser
        100000    3    tcp       0.0.0.0.0.111          portmapper superuser
        100000    2    tcp       0.0.0.0.0.111          portmapper superuser
        100000    4    udp       0.0.0.0.0.111          portmapper superuser
        100000    3    udp       0.0.0.0.0.111          portmapper superuser
        100000    2    udp       0.0.0.0.0.111          portmapper superuser
        100000    4    local     /run/rpcbind.sock      portmapper superuser
        100000    3    local     /run/rpcbind.sock      portmapper superuser
            24    5    udp       0.0.0.0.3.99           -          superuser
            24    5    tcp       0.0.0.0.3.100          -          superuser
    

    如果服务没有运行,您必须使用rpcbind 启动它。在 Ubuntu 上,我需要 root 权限才能运行该服务。

    【讨论】:

      【解决方案3】:

      在最近的 Linux 版本的 rpcbind 中有一个错误/功能 - 它现在在系统启动后不活动/运行,但根据 systemctl 配置 rpcbind.service 文件应该以某种方式“激活套接字”在 /usr/lib/systemd/system/:

      [Install] 
      Also=rpcbind.socket
      

      检查此线程,了解导致 Ubuntu 问题的相同错误/功能 (https://bugs.launchpad.net/ubuntu/+source/rpcbind/+bug/1558196)。

      对您(我们)的 rpcbind 问题的简短回答是 - 为了运行 RPC 服务器代码,对系统的 systemctrl 配置进行此修改

      sudo systemctl add-wants multi-user.target rpcbind
      

      现在,设置 rpcbind 运行的预期方法是以某种方式访问​​ /var/run/rpcbind.sock,我要感谢一些 Unix/Linux 大师,他们可能会启发我了解 RPC 服务器应用程序代码应该做什么,以便实现这个rpcbind“socket激活”效果。

      【讨论】:

      • 重启后我遇到了这个问题,你的最后一行有帮助 - 谢谢
      • @serup:你的意思是'sudo systemctl ....'行?由于我的最后一段是一个问题,我仍然不知道答案。如何实现“套接字激活” - 因为尝试使用 rpc 服务并没有做到这一点。
      • 是的,在运行最后一行并重新启动系统后,问题消失了
      【解决方案4】:

      如何安装 rpcgen

      在终端上输入此命令。

      sudo apt-get install rpcbind
      

      但有时上面的代码无法帮助您安装rpcgen

      那时您必须按照这些步骤操作。然后您可以轻松安装它。 你应该按照这个一步一步来

      sudo apt-get update  
      sudo apt-get install rpcbind
      

      最后你可以使用这个命令rpcinfo查看它

      【讨论】:

        【解决方案5】:

        问题是由于portmaprpcbind 等实用程序不可用而出现的。安装其中任何一个即可解决问题。

        【讨论】:

          【解决方案6】:

          只需安装以下并尝试。

          sudo apt install libc-dev-bin
          

          有关更多信息,请查看以下 GitHub。 https://github.com/riyazathali/RPC-HelloWorld

          【讨论】:

          • 欢迎使用 stackoverflow!你确定这会有所帮助吗?似乎该人已经在大约 8 年前将另一个答案标记为已接受。
          • 是的。当然。因为,这种方式在不依赖rpcbind的情况下会出现偏差。您可以通过停止 rcpbind 或卸载 rcpbind 轻松尝试此操作
          • 好的,我完全没有经验,只是想了解更多关于您的回答的信息:)谢谢!
          【解决方案7】:

          我在使用 rpcinfo 时也遇到了错误。最后我不得不跑:

          /etc/init.d/rpcbind start
          

          here 建议的那样。

          得到后:

          [info] Already running: rcpbind.
          

          rpc 服务器二进制文件能够注册。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2018-07-23
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多