Linux 作業系統

在 Linux 系統上自動啟動伺服器

您可以使用 systemdsystem V 起始設定系統,在 Linux® 作業系統上自動啟動伺服器。

使用 systemd 起始設定自動啟動伺服器

若要使用 systemd 起始設定系統在 Linux® 作業系統上自動啟動伺服器,請配置並執行 dsmserv.rc Script。

開始之前

請確定 /usr/bin/systemctl/bin/systemctl 公用程式已安裝在系統上。

請確定伺服器實例是以名稱與實例擁有者相同的非 root 使用者 ID 來執行。

關於這項作業

您可以使用 dsmserv.rc Script 來自動啟動或停止伺服器實例。

程序

對於您要自動啟動的每一個伺服器實例,請完成下列步驟:

  1. 重新命名 dsmserv.rc Script,以符合伺服器實例擁有者的名稱。 例如,如果伺服器實例擁有者是 tsminst1 且檔案儲存在 install_dir/server/bin 目錄中,請發出下列指令:
    cp /opt/Tivoli/tsm/server/bin/dsmserv.rc /opt/Tivoli/tsm/server/bin/tsminst1
  2. 執行下列指令,以在新重新命名的 Script 上設定執行權:
    chmod +x install_dir/server/bin/instance
    例如:
    chmod +x /opt/Tivoli/tsm/server/bin/tsminst1
  3. 如果伺服器實例目錄不是 home_directory/tsminst1,請在 Script 副本中找到下列行:
    instance_dir="${instance_home}/tsminst1"

    變更這一行,以將它指向您的伺服器實例目錄。 例如:

    instance_dir="/tsminst1"
  4. 在 Script 副本中,尋找下列行:
    # pidfile: /var/run/dsmserv_instancename_su.pid

    將實例名稱值變更為伺服器實例擁有者的名稱。 例如,如果伺服器實例擁有者是 tsminst1,請發出下列指令來更新該行:

    # pidfile: /var/run/dsmserv_tsminst1_su.pid
  5. /etc/systemd/system 目錄中建立實例.service檔案。

    例如:

    vi /etc/systemd/system/tsminst1.service

    檔案包含下列內容:

    [Unit]
    Description=IBM Spectrum Protect Server instance tsminst1
    
    [Service]
    TasksMax=infinity
    Type=oneshot
    RemainAfterExit=true
    ExecStart=/opt/tivoli/tsm/server/bin/tsminst1 start
    ExecStop=/opt/tivoli/tsm/server/bin/tsminst1 stop
    ExecReload=/opt/tivoli/tsm/server/bin/tsminst1 restart
    
    [Install]
    WantedBy=multi-user.target
    
  6. 儲存服務檔並執行下列指令:
    systemctl daemon-reload
  7. 建立從 /etc/systemd/system 目錄中的 Script 指向 /etc/systemd/system/multi-user.target.wants 目錄的符號鏈結。 例如:
    ln -s /etc/systemd/system/tsminst1.service  /etc/systemd/system/multiuser.target.wants/tsminst1.service
  8. 若要啟用 systemd 起始設定服務,請執行下列指令:
    systemctl enable service_name

    例如:

    systemctl enable tsminst1.service

使用 System V 起始設定自動啟動伺服器

若要使用 System V 起始設定系統在 Linux 作業系統上自動啟動伺服器,請配置並執行 dsmserv.rc Script。

開始之前

請確定核心參數設定正確。

請確定伺服器實例在實例擁有者使用者 ID 下執行。

請確定已正確設定存取權和使用者限制。

關於這項作業

dsmserv.rc Script 位於伺服器安裝目錄中,例如,/opt/tivoli/tsm/server/bin

dsmserv.rc Script 可用來手動啟動伺服器,或是在 /etc/rc.d/init.d 目錄中新增項目來自動啟動伺服器。 該 Script 與 Linux 公用程式一起運作,例如 CHKCONFIGSERVICE

程序

對於您要自動啟動的每一個伺服器實例,請完成下列步驟:

  1. dsmserv.rc Script 的副本放在 /init.d 目錄中,例如,/etc/rc.d/init.d

    請確定您只變更 Script 的副本。 請不要變更原始 Script。

  2. 重新命名 Script 副本,使其符合伺服器實例擁有者的名稱,例如,tsminst1

    建立 Script 的前提是假定伺服器實例目錄是 home_directory/tsminst1,例如:/home/tsminst1/tsminst1

  3. 如果伺服器實例目錄不是 home_directory/tsminst1,請在 Script 副本中找到下行:
    instance_dir="${instance_home}/tsminst1"
    變更該行,以便它指向伺服器實例目錄,例如:
    instance_dir="/tsminst1"
  4. 在 Script 副本中,尋找下列行:
    # pidfile: /var/run/dsmserv_instancename_su.pid
    將實例名稱值變更為伺服器實例擁有者的名稱。
    例如,如果伺服器實例擁有者為 tsminst1,請更新如下所示的行:
    # pidfile: /var/run/dsmserv_tsminst1_su.pid
  5. 配置伺服器自動啟動的執行層次。 透過使用工具(例如 CHKCONFIG 公用程式),指定對應於多使用者模式的值,並開啟網路連線。 使用的執行層次通常為 3 或 5,視作業系統及其配置而定。 如需多使用者模式及執行層次的相關資訊,請參閱您作業系統的說明文件。
  6. 若要啟動伺服器,請發出下列指令:
    service server_instance_owner start

    例如,如果伺服器實例擁有者是 tsminst1,則會發出下列指令:

    service tsminst1 start

  7. 若要停止伺服器,請發出下列指令:
    service server_instance_owner stop

    例如,如果伺服器實例擁有者是 tsminst1,則會發出下列指令:

    service tsminst1 stop

範例

此範例使用下列其中一個值:
  • 實例使用者是 tsminst1。
  • 伺服器實例目錄是 /home/tsminst1/tsminst1
  • dsmserv.rc Script 副本命名為 tsminst1
  • CHKCONFIG 公用程式用來配置 Script,以在執行層次 3、4 及 5 啟動。
cp /opt/tivoli/tsm/server/bin/dsmserv.rc /etc/rc.d/init.d/tsminst1
sed -i 's/dsmserv_instancename.pid/dsmserv_tsminst1.pid/' /etc/rc.d/init.d/tsminst1
chkconfig --list tsminst1
service tsminst1 supports chkconfig, but is not referenced in
any runlevel (run 'chkconfig --add tsminst1')
chkconfig --add tsminst1
chkconfig --list tsminst1
tsminst1 0:off 1:off 2:off 3:off 4:off 5:off 6:off
chkconfig --level 345 tsminst1 on
chkconfig --list tsminst1
tsminst1 0:off 1:off 2:off 3:on 4:on 5:on 6:off