Icecast 2.3.3でCentOS 6.3 x86_64にストリーミングオーディオサーバをインストールする方法
重要: 本ガイドはCentOS 6.3とIcecast 2.3.3を前提としています。OSやIcecastのバージョンが異なる場合は手順やパスが変わるため注意してください。
目的と関連キーワード
この記事の主目的: Icecast 2.3.3をCentOS 6.3 x86_64にインストールしてOGGおよびMP3のストリーミングを構築する手順を学ぶ。
関連キーワード(検索意図のバリエーション):
- Icecast インストール
- Icecast CentOS 6.3 指示
- ices 設定 OGG
- icegenerator MP3 ストリーミング
- Icecast セキュリティ ハードニング
前提条件
- CentOS 6.3 x86_64がインストール済みでroot権限が使用可能であること。sudoでも可。
- ネットワーク接続(外部からのパッケージ取得とリポジトリアクセス)。
- ミュージックファイルがサーバ上に存在すること(/music/ 以下など)。
- 著作権や配信権の確認を行っていること(配信コンテンツの法的要件は別途確認してください)。
主要ステップ(概要)
- ビルド環境と依存パッケージをインストールする。
- Icecast 2.3.3 をソースからダウンロード、コンパイル、インストールする。
- 設定ファイル(icecast.xml)を編集してユーザ・ログディレクトリを準備する。
- libshout をビルドしてインストールする。
- OGG向けクライアントices、MP3向けクライアントicegeneratorをビルドして設定する。
- 動作確認、ログ確認、トラブルシューティング。
セクション1 — サーバ本体のセットアップ: Icecast
まずソフトウェアと依存パッケージを取得してインストールします。以下はroot権限で実行するコマンド例です。
# yum groupinstall "Development Tools"
# yum install -y curl-devel libtheora-devel libvorbis-devel libxslt-devel speex-devel libxslt
# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
# cd /home
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# mkdir -p /usr/src/icecast
# cd /usr/src/icecast
# wget http://downloads.xiph.org/releases/icecast/icecast-2.3.3.tar.gz
次にソースを展開してディレクトリを移動します。
*# tar xf icecast-2.3.3.tar.gz
# cd icecast-2.3.3*
ソースをconfigureしてインストール先を指定します。
# ./configure --prefix=/opt/icecast/2.3.3
ビルドとインストール:
# make
# make install
インストール後のバイナリの場所確認:
# ls /opt/icecast/2.3.3/bin/
icecast*
最新ディレクトリをシンボリックリンクで指すと運用が楽になります:
# cd /opt/icecast
# ln -s 2.3.3 latest
icecastの設定ファイルを編集します。サンプルをまず退避:
# cd /opt/icecast/latest/etc
# mv icecast.xml icecast.xml.orig
# vi icecast.xml
以下は構成サンプル(元ファイルそのままを掲載しています)。
100
10
5
524288
30
15
10
1
65535
password
admin
password
MyHost/IP
8000
1
/opt/icecast/latest/share/icecast
/opt/icecast/latest/share/icecast/web
/opt/icecast/latest/share/icecast/admin
/var/log/icecast
/var/run/icecast/icecast.pid
access.log
error.log
playlist.log
1
10000
1
0
icecast
icecast
設定ファイルの要点(要約):
- limits: 最大クライアント数やソース(ラジオ局)数を設定します。デフォルト例ではsources=10, clients=100。
- authentication: source-passwordはストリーミングクライアントが接続するためのパスワードです。admin-user/ admin-passwordは管理GUI用。
- hostname と port: サーバのホスト名とポート(例: 8000)。
- paths: Web GUIのコンテンツやログ、pidファイルの位置。
- logging: ログファイル名とログレベル。
- security: chrootや実行ユーザ・グループの設定。
次にicecast用ユーザとグループ、ログディレクトリ、pidディレクトリを作成します。サンプルではUID/GIDに200を使用していますが、既存のUID/GIDと衝突しない値を選んでください。
# groupadd -g 200 icecast
# useradd -d /var/log/icecast -m -g icecast -s /bin/bash -u 200 icecast
# mkdir -p /var/run/icecast
# chown -R icecast:icecast /var/run/icecast
起動テスト:
# /opt/icecast/latest/bin/icecast -c /opt/icecast/latest/etc/icecast.xml -b
期待される起動メッセージの例:
Starting icecast2
Detaching from the console
Changed groupid to 200.
Changed userid to 200.
ログの位置と確認:
# ls /var/log/icecast/
access.log error.log playlist.log
プロセス確認:
# pgrep -fl icecast
4434 /opt/icecast/latest/bin/icecast -c /opt/icecast/latest/etc/icecast.xml -b
Web GUIは http://MyHost/IP:8000/ でアクセスできます(hostname/portは設定による)。管理UIのユーザとパスワードはicecast.xmlに記載したものが使われます。
セクション2 — OGG/Vorbis用ストリーミングクライアント: ices
icesをビルドする前にlibshoutをインストールします。
# cd /usr/src/icecast
# wget http://downloads.us.xiph.org/releases/libshout/libshout-2.3.1.tar.gz
# tar xf libshout-2.3.1.tar.gz
# cd libshout-2.3.1
# ./configure --prefix=/opt/icecast/latest
# make
# make install
icesのソース取得とビルド:
# cd /usr/src/icecast
# wget http://downloads.us.xiph.org/releases/ices/ices-2.0.2.tar.bz2
# tar xf ices-2.0.2.tar.bz2
# cd ices-2.0.2/
# export PKG_CONFIG_PATH=/opt/icecast/latest/lib/pkgconfig:$PKG_CONFIG_PATH
# ./configure --prefix=/opt/icecast/latest
# make
# make install
バイナリ確認:
# ls /opt/icecast/latest/bin/
icecast* ices*
icesの設定例(ices1.xml):
# cd /opt/icecast/latest/etc/
# vi ices1.xml
1
/var/run/icecast/ices1.pid
/var/log/icecast
ices1.log
2048
3
0
RadioStation 1: OGG
Varios
Test Radio 1
http://MyHost/IP:8000/
basic
/opt/icecast/latest/etc/playlist1.txt
1
0
1
MyHost/IP
8000
password
/radiostation1
ポイント:
- metadata の name/genre/description はプレイヤーに表示されます。
- input の file はプレイリストの完全パスを指定します。
- instance の password は icecast の source-password と一致させる必要があります。
プレイリスト作成例(playlist1.txt):
# cd /opt/icecast/latest/etc/
# vi playlist1.txt
/music/artist/album/song1.ogg
/music/artist/album/song2.ogg
プレイリストを自動生成するには find を使います:
# find /music/artist/album/ -name "*.ogg" > /opt/icecast/latest/etc/playlist1.txt
icesをicecastユーザで実行してストリーム開始:
# su - icecast -c "/opt/icecast/latest/bin/ices /opt/icecast/latest/etc/ices1.xml"
ログ確認:
# cat /var/log/icecast/ices1.log
ログの例(抜粋):
[2011-12-16 12:17:05] INFO signals/signal_usr1_handler Metadata update requested
[2011-12-16 12:17:05] INFO playlist-basic/playlist_basic_get_next_filename Loading playlist from file "/opt/icecast/latest/etc/playlist1.txt"
[2011-12-16 12:17:05] INFO playlist-builtin/playlist_read Currently playing "/music/artist/album/song2.ogg"
[2011-12-16 12:17:05] INFO stream/ices_instance_stream Connected to server: MyHost/IP:8000/radiostation1
...
ストリームURL: http://MyHost/IP:8000/radiostation1
複数局を運用する場合は、icesの設定ファイルとプレイリストを局ごとに用意します。
セクション3 — MP3用ストリーミングクライアント: icegenerator
MP3配信にはicegeneratorを使用します。libshoutが必要なので、先にlibshoutをビルド済みであることを確認してください(前節参照)。
libshoutのビルド(再掲):
# cd /usr/src/icecast
# wget http://downloads.us.xiph.org/releases/libshout/libshout-2.3.1.tar.gz
# tar xf libshout-2.3.1.tar.gz
# cd libshout-2.3.1
# ./configure --prefix=/opt/icecast/latest
# make
# make install
icegeneratorの入手とビルド:
# cd /usr/src/icecast
# wget http://netcologne.dl.sourceforge.net/project/icegenerator/icegenerator/0.5.5-pre2/icegenerator-0.5.5-pre2.tar.gz
# tar xfz icegenerator-0.5.5-pre2.tar.gz
# cd icegenerator-0.5.5-pre2
# ./configure
# make
# make install
バイナリ確認:
# ls -lah /usr/local/bin/ice*
-rwxr-xr-x 1 root root 55K 2011-12-16 12:41 /usr/local/bin/icegenerator*
icegenerator設定例(icegen1.cfg):
# cd /usr/local/etc
# vi icegen1.cfg
IP=192.168.1.100
PORT=8000
SERVER=2
MOUNT=/radiostation2
PASSWORD=password
FORMAT=1
MP3PATH=m3u:/usr/local/etc/playlist2.m3u
LOOP=1
SHUFFLE=1
NAME=RadioStation 2: MP3
DESCRIPTION=Test Radio
GENRE=Varios
URL=http://MyHost/IP:8000/
LOG=2
LOGPATH=/var/log/icecast/icegen1.log
BITRATE=48000
SOURCE=source
解説:
- SERVER=2 は HTTP 配信を意味する設定例(icy/http の扱いに依存)。
- FORMAT=1 はMP3、0はOGG。
- MP3PATH は m3u プレイリストを参照。プレイリストは通常1行に音声ファイルのパスを列挙。
- BITRATE は配信ビットレート(クライアント側のストリーミング品質に影響)。
playlist2.m3uの例:
# vi /usr/local/etc/playlist2.m3u
/music/artist/album/song1.mp3
/music/artist/album/song2.mp3
自動生成:
# find /music/artist/album/ -name "*.mp3" > /usr/local/etc/playlist2.m3u
実行例(ライブラリパスを通してicegeneratorを起動):
# su - icecast -c "export LD_LIBRARY_PATH=/opt/icecast/latest/lib:$LD_LIBRARY_PATH; /usr/local/bin/icegenerator -f /usr/local/etc/icegen1.cfg"
プロセスとログ確認:
# pgrep -fl icegen
31255 icegenerator -f /usr/local/etc/icegen1.cfg
# cat /var/log/icecast/icegen1.log
Fri Dec 16 13:44:38 2011: Connected to stream serverFri Dec 16 13:44:38 2011: Now playing song1.mp3Fri Dec 16 13:48:41 2011: Wait for all child process to terminate......
ストリームURL: http://MyHost/IP:8000/radiostation2
運用上のヒントとチェックリスト
受け入れ基準
- Icecast サーバが指定ポートでリッスンしていること(例: 8000)。
- 管理UIにアクセスでき、管理ユーザでログインできること。
- ices / icegenerator がログにエラーなく接続していること。
- クライアント(VLC等)で .ogg/.mp3 を再生できること。
運用前チェックリスト(管理者)
- ポート8000がファイアウォールで許可されていること。
- /var/log/icecast に書き込み権限があること。
- icecastユーザでサービスを起動できること。
- クライアント接続時の認証設定(source-password)が適切に設定されていること。
導入時のトラブル確認手順(速攻チェック)
- プロセスが存在するか: pgrep -fl icecast
- ポート待ち受け確認: netstat -tlnp | grep 8000
- ログにエラーはないか: tail -n 200 /var/log/icecast/error.log
- クライアントからブラウザで http://ホスト:8000/status.xsl にアクセス
セキュリティハードニング(推奨)
- パスワードをデフォルトの “password” にしない。長いランダムなパスワードを使用。
- 管理GUIをインターネット直結で公開しない。必要ならIP制限やリバースプロキシで保護。
- SELinux を有効にして運用する場合は、icecastがログディレクトリやpidディレクトリへ書き込めるようにコンテキストを調整する。
- 自動起動スクリプト(system V initスクリプト)を作成し、適切なユーザで起動すること。CentOS 6ではsystemdは未採用のためinitスクリプトを用いる。
- TLS/HTTPSでの配信(IcecastはTLSに対応した方法やリバースプロキシ経由での配信を検討)。
注意点: 本ガイドは暗号化の詳細や証明書発行までは扱いません。公開配信を行う場合は必ずHTTPSや適切な認証の導入を検討してください。
トラブルシューティング集(よくある問題と対処)
問題: icecastが起動しない / 直ちにクラッシュする
- 対処: /var/log/icecast/error.log を確認。権限エラーの場合はchown/chmodを確認。
問題: クライアントが接続できない
- 対処:
- ファイアウォールでポートが閉じられていないか確認(iptables -L -n)。
- netstat -tlnp でプロセスがポートをListenしているか確認。
- icecast.xml の hostname 値が正しいか再確認。
問題: ices / icegenerator が接続を拒否される
- 対処: icecast.xml の
が正しいか、そしてクライアント設定の password が一致しているかを確認。
問題: 音飛び・再生の途切れ
- 対処:
- サーバの帯域やスレッド数を確認。icecast の limits で threadpool や queue-size を調整。
- ネットワークのパケットロス、I/O負荷を監視。
代替アプローチと考慮事項
- OSパッケージを使う
- CentOSのEPELやrpmforgeにIcecastが存在する場合、ソースからビルドする代わりにyumでパッケージインストールする手もあります。パッケージ管理の利便性が利点。
- コンテナ化
- Docker/コンテナでIcecastを実行すると環境再現や依存関係の分離が容易です。ただしCentOS6固有の環境が必要な場合は注意。
- クラウドマネージド
- 大規模配信やスケーラビリティが必要ならCDNやクラウド型ストリーミングサービスの併用を検討する。
移行・互換性メモ
- Icecast 2.3.3は古いバージョンです。可能であれば新しいIcecastバージョンやOSに移行することを推奨します。設定項目やデフォルトの挙動がバージョン間で変わることがあります。
- CentOS 6 系は既にEOLに近い/終了しているため、新しいディストリビューション(CentOS 7/8 または互換OS)への移行計画を立ててください。
役割別チェックリスト
運用担当者(システム管理者)
- Icecastサービスの起動/停止/再起動手順を用意する。
- ログローテーションの設定(logrotate)を構成する。
- 定期的なバックアップと設定ファイルのバージョン管理を行う。
コンテンツ担当者(放送担当)
- プレイリストの保守とファイルパスの整備。
- 使用する音源の権利・メタデータの整合性を確認する。
開発/インフラ担当
- 監視設定(プロセス死活、接続数、レスポンスタイム)をSLAに合わせて構築。
- アップグレード手順とロールバックプランを作成。
テストケースと受入基準
テスト項目例:
- T1: icecastを起動し、管理GUIにログインできるか。
- T2: icesを起動して/radiostation1に接続、クライアントで再生できるか。
- T3: icegeneratorを起動して/radiostation2に接続、クライアントで再生できるか。
- T4: ファイアウォール越しの外部接続で音声が途切れないか(短時間負荷テスト)。
受入基準:
- 全てのテスト項目でエラーなく各ストリームが再生されること。
- エラーログが致命的なものを含まないこと。
簡易コマンドチートシート
- サービス起動: /opt/icecast/latest/bin/icecast -c /opt/icecast/latest/etc/icecast.xml -b
- ices起動: su - icecast -c “/opt/icecast/latest/bin/ices /opt/icecast/latest/etc/ices1.xml”
- icegenerator起動: su - icecast -c “export LD_LIBRARY_PATH=/opt/icecast/latest/lib:$LD_LIBRARY_PATH; /usr/local/bin/icegenerator -f /usr/local/etc/icegen1.cfg”
- プロセス確認: pgrep -fl icecast
- ポート確認: netstat -tlnp | grep 8000
- ログ確認: tail -f /var/log/icecast/error.log
参考リンク
- Icecast, libshout, ices: http://www.icecast.org
- icegeneratorの説明: http://www.becrux.com/index.php?page=projects&name=icegenerator#Configuration
まとめ
- Icecast 2.3.3をCentOS 6.3で動かすには、依存パッケージの導入、ソースビルド、設定ファイル編集、ユーザ/ディレクトリ作成、クライアント(ices/icegenerator)のビルドが必要です。
- デフォルトのパスワードを変更し、ログと権限の管理、ファイアウォール設定、監視を整えて運用に備えてください。
重要: このガイドは技術手順を中心にまとめています。配信コンテンツのライセンスや法的責任については別途専門家に相談してください。