Linuxの〜サービス管理。
サービスの紹介と分類。
自己の出発でスタート。
- サービスが開始されます。
これは、現在のシステムで実行されるサービスを作り、そして機能性を提供することです。
- スタートからのサービス。
自己始動手段は、システムの起動後にサービスをさせたり、開始して、システムを再起動し、自動的にサービスを開始します。
インストールされているサービスを表示します。
RMPサービスパッケージは、デフォルトではインストールされています。
-
chkconfigを--list
スタートからのサービスの状態を確認し、あなたはすべてのRPMパッケージがサービスをインストール見ることができます。
ソースパッケージのインストールサービス。
- ビューのサービスのインストール場所、通常は/ usr / localの下に。
違い。
RPMパッケージの間およびサービスパックのインストールソースサービスをインストール違いは、別のインストール場所です。
-
ソースパッケージは、通常は/ usr / localの下に、指定した位置に設置しました。
-
RPMパッケージは、デフォルトの位置にインストールされています。(開発者が従います)。
中には/ etc /ダウン設定ファイル。
/etc/rc.d/init.d/の下のスタートアップスクリプト。
削除する-eオプションは、delete一緒に。
管理RPMパッケージのインストールサービス。
独立したサービス管理。
[root@localhost ~]# ll /etc/init.d -d
lrwxrwxrwx. 1 root root 11 Feb 18 07:43 /etc/init.d -> rc.d/init.d
/etc/init.d/のか、/etc/rc.d/init.d/の | スタートアップスクリプトの場所。 |
の/ etc /のsysconfig / | 初期環境設定ファイルの場所。 |
/等/ | プロファイルの場所。 |
/etc/xinetd.conf/ | xinetdの設定ファイル。 |
/etc/xinetd.d/ | xinetd.dサービスベースの起動スクリプト。 |
/ var / libに/ | ここで生成されたサービスデータ。 |
/ var / log / | ログインします。 |
独立したサービスを開始します。
-
ストップ| |状況|再起動を/etc/init.d/の独立したサービス名が開始します
-
独立したサービス名は、サービス開始|停止|ステータス|再起動
/etc/init.d/
あまりにも長い間、私たちにサービスを提供するREDHAT、taが自動的に移動します/etc/init.d/
下のサービス名を見つけること。他のLinuxディストリビューションは持っていないかもしれません。
--status-すべてのサービス
独立したサービスの開始以来。
- chkconfigの[レベルの実行レベル] [独立したサービス名] [ON | OFF]
2345デフォルト-Level。
[root@localhost ~]# chkconfig | grep sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]# chkconfig --level 2345 sshd on
- /etc/rc.d/rc/localファイルを変更します。
[root@localhost ~]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 Feb 18 07:44 /etc/rc.local -> rc.d/rc.local
システムは、ユーザー名とパスワードを入力する開始する前にコマンドを実行します。
書かれているコマンドが実行されます。
だから、パッケージを管理することができます。
/etc/rc.d/init.d/sshd開始
[root@localhost ~]# vim /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
タッチ - >タッチ。新しい理解 - >
ファイルが存在しない場合は、新しいです。
ファイルは、更新時刻が存在する場合。
- スタートからのntsysvコマンド管理を使用してください。
グラフィカルなインターフェース。(同様のセットアップ)。RedHatのプロプライエタリ。
xinetdのベースのサービス管理。
xinetdのインストールおよびtelnet。
telnetの - >安全ではありません。今、sshを使用。
[ルート@ localhostの〜]#yumをインストールxinetdを
再び使用chkconfig
表示
xinetd based services:
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
tcpmux-server: off
time-dgram: off
time-stream: off
- すべてのxinetdサービスは、直接のxinetdベースのサービスの管理コールによってメモリが占有されていません。
telnetの。
[root@localhost ~]# yum install telnet
[root@localhost ~]# yum install telnet-server
[root@localhost ~]# chkconfig | grep telnet
telnet: off
直接使用することはできませんservice
Telnetを管理します。
TAは、xinetdサービスに基づいているため、xinetdで管理されます。
[root@localhost ~]# service telnet restart
telnet: unrecognized service
[root@localhost ~]# vim /etc/xinetd.d/telnet
disable = no # 服务启动。
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet # 服务的名称。
{
flags = REUSE # 设定 TCP/IP socket 可重用。
socket_type = stream # 允许 TCP 协议数据包。
wait = no # 允许多个连接同时连接。
user = root # 启动服务的用户为 root。
server = /usr/sbin/in.telnetd # 服务的启动程序。
log_on_failure += USERID # 登录失败后,记录用户 id。
disable = yes # 服务不启动。
}
~
~
"/etc/xinetd.d/telnet" 14L, 305C 1,1
- 再起動xinetdサービス。
[root@localhost ~]# service xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
[ルート@ localhostの〜]#netstatの-tlun
23ポートOK。
開始からxinetdをサービス。
-
chkconfigを信条に
-
ntsysvの
xinetは、起動と同じ状態から開始します。
ソースパッケージ管理インストールサービス。
ソースパッケージが開始されます。
- 絶対パスを使用して、起動する起動スクリプトを呼び出します。異なるソースパッケージは、別のスクリプトを起動します。あなたは、ソースコードパッケージのインストール手順を表示するスクリプトを起動する方法を見ることができます。
最初からソースパッケージ。
[root@localhost ~]# vim /etc/rc.d/rc.local
追加しました
/ usr / local / apache2の/ binに/はapachectl開始
サービスが開始されてからソースパッケージ管理コマンド(サービス)の管理もしてみましょう。
- apacheのサービスのソースパッケージはserviceコマンドの管理を開始することができましょう。
LN -sは/ usr / local / apache2の/ binに/はapachectl /etc/init.d/apache
// service
最終的な分析では、コマンドは/etc/init.d/のにコマンドを見つけることです。
ソースパッケージのchkconfigとntsysvのコマンド・サービスは最初から管理することができましょう。
[root@localhost ~]# vim /etc/init.d/sshd
#
シンボルを削除することはできません。
# chkconfig: 2345 55 25
# 指定 sshd 脚本可以被 chkconfig 命令管理。
config: 运行级别 启动顺序 关闭顺序
レベル3で動作開始におけるレベル
ブートシーケンス(Kxx
)と閉鎖配列(Sxx
)。
。
[root@localhost ~]# vim /etc/rc.d/rc3.d/
K10saslauthd S07iscsid S25netfs
K50vsftpd S08ip6tables S26udev-post
K74ntpd S08iptables S55sshd
K75ntpdate S10network S56xinetd
K87multipathd S11auditd S80postfix
K87restorecond S12rsyslog S90crond
K89netconsole S13iscsi S99local
K89rdisc S15mdmonitor
S02lvm2-monitor S25blk-availability
#!/bin/bash
#
# sshd Start up the OpenSSH server daemon
#
# chkconfig: 2345 55 25
# description: SSH is a protocol for secure remote shell access. \
# This service starts up the OpenSSH server daemon.
#
# processname: sshd
# config: /etc/ssh/ssh_host_key
# config: /etc/ssh/ssh_host_key.pub
# config: /etc/ssh/ssh_random_seed
# config: /etc/ssh/sshd_config
# pidfile: /var/run/sshd.pid
### BEGIN INIT INFO
- chkconfigの参加。
chkconfig --add sshd
chkconfigを--list