Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

C.3. 継承、ブロック、リソースの再利用

一部のリソースは、親リソースから値を継承することにメリットがあります。NFS サービスではこれが一般的に当てはまります。例C.5「リソース再利用と継承の為の NFS サービスセットアップ」 は、リソースの再利用と継承のためにセットアップされた標準的な NFS サービス設定を示しています。

例C.5 リソース再利用と継承の為の NFS サービスセットアップ


    <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 &
                                            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>

サービスが平坦(すなわち、親/子 関係が無い状態)である場合、以下のように設定される必要があります:
  • サービスは 4つの nfsclient リソースを必要とします — ファイルシステム毎に1つ (ファイルシステム群で計2つ)、そしてターゲットマシン毎に1つ (ターゲットマシン群で計2つ)
  • サービスは各 nfsclient にエクスポートパスとファイルシステム ID を指定する必要があります。これにより、設定にエラーが生じる可能性があります。
一方、例C.5「リソース再利用と継承の為の NFS サービスセットアップ」 では NFS クライアントリソース nfsclient:bobnfsclient:jim は、一度だけ定義されています。同じように NFS エキスポートリソース nfsexport:exports も一度だけ定義されています。リソースで必要とされる全ての属性は親リソースから継承されます。この継承属性は動的である (かつ相互に競合しない) ため、それらのリソースを再利用することは可能です — これがリソース群がリソースブロック内で定義される理由です。いくつかのリソースを複数の場所で設定することは実用的ではない場合があります。例えば、複数の場所でファイルシステムリソースを設定すると、1 つのファイルシステムを 2 つのノードにマウントすることになる場合があり、問題になります。