이 콘텐츠는 선택한 언어로 제공되지 않습니다.

D.3. Inheritance, the <resources> Block, and Reusing Resources


Some resources benefit by inheriting values from a parent resource; that is commonly the case in an NFS service. Example D.5, “NFS Service Set Up for Resource Reuse and Inheritance” shows a typical NFS service configuration, set up for resource reuse and inheritance.

Example D.5. NFS Service Set Up for Resource Reuse and Inheritance

<resources>
  <nfsclient name="bob" target="bob.example.com" options="rw,no_root_squash"/>
  <nfsclient name="jim" target="jim.example.com" options="rw,no_root_squash"/>
  <nfsexport name="exports"/>
</resources>
<service name="foo">
  <fs name="1" mountpoint="/mnt/foo" device="/dev/sdb1" fsid="12344">
    <nfsexport ref="exports">  <!-- nfsexport's path and fsid
        attributes are inherited from the mountpoint and fsid
	attribute of the parent fs resource -->
    <nfsclient ref="bob"/> <!-- nfsclient's path is inherited
        from the mountpoint and the fsid is added to the options
	string during export -->
    <nfsclient ref="jim"/ >
  </nfsexport>
</fs>
<fs name="2" mountpoint="/mnt/bar" device="/dev/sdb2" fsid="12345">
  <nfsexport ref="exports">
    <nfsclient ref="bob"/> <!-- Because all of the critical
       data for this resource is either defined in the resources block
       or inherited, we can reference it again! -->
    <nfsclient ref="jim"/>
  </nfsexport>
</fs>
<ip address="10.2.13.20"/>
</service>
If the service were flat (that is, with no parent/child relationships), it would need to be configured as follows:
  • The service would need four nfsclient resources — one per file system (a total of two for file systems), and one per target machine (a total of two for target machines).
  • The service would need to specify export path and file system ID to each nfsclient, which introduces chances for errors in the configuration.
In Example D.5, “NFS Service Set Up for Resource Reuse and Inheritance” however, the NFS client resources nfsclient:bob and nfsclient:jim are defined once; likewise, the NFS export resource nfsexport:exports is defined once. All the attributes needed by the resources are inherited from parent resources. Because the inherited attributes are dynamic (and do not conflict with one another), it is possible to reuse those resources — which is why they are defined in the resources block. It may not be practical to configure some resources in multiple places. For example, configuring a file system resource in multiple places can result in mounting one file system on two nodes, therefore causing problems.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.