メーリングリストサーバmailmanの構築

【前提条件】
apacheがインストール済み
postfix,sendmail,qmail等のsmtpがインストール済み
Pythonがインストール済み
Python-develがインストール済み
gccが2.8.1以降

※selinuxが動いているとmailmanのCGIが動きません。
 SElinuxの設定をする必要がありますが今のところ
 面倒なのでdisableにしています。

今回はpostfixを使用しています。

mailmanはmailman-2.1.14+j7.tgzを使用します。
事前に公式サイトからダウンロードして/usr/local/src/に
配置します。

グループ及びユーザー作成
# groupadd mailman
# useradd -c “GNU Mailman” -s /sbin/nologin -g mailman mailman

デフォルトでインストールディレクトリが/usr/local/mailmanなので
フォルダを作り権限を設定します。
# mkdir /usr/local/mailman
# usermod -d /usr/local/mailman mailman
# chown mailman. /usr/local/mailman
# chmod a+rx,g+ws /usr/local/mailman

mailmanをダウンロードしたディレクトリに移動して解凍します。
また所有者をmailmanユーザーにします。

# cd /usr/local/src/
# tar zxvf mailman-2.1.14+j7.tgz
# chown -R mailman. mailman-2.1.14+j7

解凍したディレクトリへ移動しインストールを実施します。
※注意点 日本語はEUCになります。linux環境でUTF-8にしている場合は
文字化けするので注意すること

# cd mailman-2.1.14+j7
# su mailman -s “/bin/bash” -c “./configure –with-cgi-gid=apache”
# su mailman -s “/bin/bash” -c “make” && make install

インストール終了後、インストールディレクトリに移動して
パーミッションの補正スクリプトcheck_permsを実行します。

# cd /usr/local/mailman
# bin/check_perms -f

警告: 限定公開保存書庫ディレクトリが other-executable (o+x) に
なっています. あなたのシステムのシェルユーザがこの保存書庫
を読むことができます. インストールマニュアルには, これを
どうしたら修正できるか書いてありますので, 参考にしてください.

問題ありません

問題ありませんとなるまで何度か実行します。

●WEBサーバの設定
CGIを使うのでCGIの許可設定が必要です。
今回はmailman用にコンフィグファイルを別途作ります。

# vi /etc/httpd/conf.d/mailman.conf
ScriptAlias /mailman/ /usr/local/mailman/cgi-bin/
<Directory /usr/local/mailman/cgi-bin/>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
Alias /pipermail/ /usr/local/mailman/archives/public/
<Directory /usr/local/mailman/archives/public/>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

mailman用ロゴファイルを所定のディレクトリーにコピーします。
# cp /usr/local/mailman/icons/* /var/www/icons/

ここまで終わったらWEBサーバの再起動
# /etc/init.d/httpd restart

●メールサーバの設定(postfix編)

postfixのmain.cfに下記の設定をします。
デフォルトではoffになっていると思うのでコメントアウトを外すか
新規で記述して下さい。

# vi /etc/postfix/main.cf

alias_maps = hash:/etc/postfix/aliases, hash:/usr/local/mailman/data/aliases

owner_request_special = no
recipient_delimiter = +
unknown_local_recipient_reject_code = 550

●mailmanの設定
mailmanの設定ファイルを編集します。

# vi /usr/local/mailman/Mailman/mm_cfg.py

##################################################
# Put YOUR site-specific settings below this line.

## mailman setup ###
MTA = ‘Postfix’
DEFAULT_URL_HOST = ‘testserver.ddo.jp’
DEFAULT_EMAIL_HOST = ‘testserver.ddo.jp’
DEFAULT_URL_PATTERN = ‘http://%s/mailman/’
DEFAULT_SERVER_LANGUAGE = ‘ja’

PostfixのPは大文字です。間違えると次がエラーになってしまいます。

bin/genaliases スクリプトを実行して aliases ファイルを初期化し、
メーリングリストサーバ管理パスワード設定します。

# /usr/local/mailman/bin/genaliases パスワード
パスワードを変更しました。

data/aliases と data/aliases.db の所有者とグループををmailmanに変更します。
またグループ書き込み許可も付けます。

# chown mailman:mailman data/aliases*
# chmod g+w data/aliases*

サイトリスト登録
# bin/newlist mailman
リスト管理者のメールアドレスを入力してください: webmaster@testserver.ddo.jp
mailman の初期パスワード:
Enter を押して mailman の管理者にメール通知する…

# bin/config_list -i data/sitelist.cfg mailman
標準でない値を修復: personalize

mailmanのcronを設定します。
# cd /usr/local/mailman/cron
# crontab -u mailman crontab.in
確認
# crontab -l -u mailman

起動します。
# /usr/local/mailman/bin/mailmanctl start

起動状況を確認

# ps aux | grep mailman
mailman 5166 0.0 1.0 14716 5444 ? Ss 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/mailmanctl star
mailman 5167 0.9 1.4 14472 7336 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=ArchRunner:0:1 -s
mailman 5168 0.8 1.4 14472 7352 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=BounceRunner:0:1 -s
mailman 5169 0.9 1.4 14476 7340 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=CommandRunner:0:1 -s
mailman 5170 0.8 1.4 14472 7300 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=IncomingRunner:0:1 -s
mailman 5171 0.9 1.4 14460 7384 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=NewsRunner:0:1 -s
mailman 5172 1.0 1.4 14860 7680 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=OutgoingRunner:0:1 -s
mailman 5173 0.9 1.4 14472 7472 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=VirginRunner:0:1 -s
mailman 5174 0.9 1.4 14472 7364 ? S 11:14 0:00 /usr/bin/python /usr/local/mailman/bin/qrunner –runner=RetryRunner:0:1 -s
root 5176 0.0 0.1 5108 788 pts/0 R+ 11:14 0:00 grep mailman

自動起動を登録します。
起動スクリプトをコピー
# cp /usr/local/mailman/scripts/mailman /etc/rc.d/init.d/
スクリプトが動く事を確認
# /etc/init.d/mailman stop
# /etc/init.d/mailman start
問題かければchkconfigに登録
# chkconfig –add mailman
# chkconfig mailman on
# chkconfig –list | grep mailman
mailman 0:off 1:off 2:on 3:on 4:on 5:on 6:off

●mailmanの確認
管理画面は
http://サーバ名/mailman/admin

リストを作ってみます。
http://サーバ名/mailman/create
「リストの名前」⇒test

「リスト管理者アドレスの初期設定」⇒リスト管理者メールアドレス

「初期パスワードを自動生成しますか?」⇒はい

「リスト作成者の認証パスワード」⇒メーリングリストサーバー管理パスワード

「リストを作成する」ボタン押下

管理画面でリストができていればOKです。

Xen+CentOS6.3でのディスク領域拡張(LVM編)

Xenの仮想サーバでdisk領域が足りなくなった際の対処と
してサーバへの割り当てサイズを増やす時の手順です。

【前提条件】

ホストOS:Xen
ゲストOS:CentOS6.3
ゲストOSパーティション:LVM
ホストOSのディスク領域は割り当て済みで空きがある

RHELの最近のバージョンであればほぼLVMになっていると思います。
LVM以外の方法はliknux disk領域拡張で記載しています。

まずはXen側のサイズを変更します。
XenCenterを開き該当の仮想サーバをShutDownします。
その後、ストレージがあるVirtualDisksを選択して、仮想サーバのDiskのProertiesから
Size and Locationを開きサイズを変更します。
※停止していないとsizeを変える事ができません。
今回は1300GBから1700GBへ拡張しました。
サイズを変更したらVMを起動します。

Xen側の作業は以上です。
続いてゲストOS側の作業です。

fdiskでlvmのパーティションを作成します。

まずはfdiskで確認
# fdisk -l

Disk /dev/xvda: 1825.4 GB, 1825361100800 bytes
255 heads, 63 sectors/track, 221920 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077127

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 64 169704 1362634356 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_home: 1339.5 GB, 1339534868480 bytes
255 heads, 63 sectors/track, 162855 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

/dev/xvdaが1800GBありますが割り当てが53Gと1339Gだけである事がわかります。
注意!!
ここの値はdiskのbytesサイズなのでXen等で設定した値と違うので間違えないように!!

# fdisk /dev/xvda

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): p  ←パーティションの確認、2番目の/dev/xvda2が今回の対象です。

Disk /dev/xvda: 1825.4 GB, 1825361100800 bytes
255 heads, 63 sectors/track, 221920 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077127

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 64 169704 1362634356 8e Linux LVM

Command (m for help): d  ←削除
Partition number (1-4): 2  ←パーティション指定

Command (m for help): p  ←対象パーティションが消えている事を確認

Disk /dev/xvda: 1825.4 GB, 1825361100800 bytes
255 heads, 63 sectors/track, 221920 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077127

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.

Command (m for help): n  ←新規パーティション作成
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2  ←パーティション指定
First cylinder (64-221920, default 64):   ←Startセクターを指定、全部使うのでdefault指定
Using default value 64
Last cylinder, +cylinders or +size{K,M,G} (64-221920, default 221920):   ←Endセクターを指定、こちらもdefault指定
Using default value 221920

Command (m for help): p  ←空き領域が全部割り当て有られている事を確認します。

Disk /dev/xvda: 1825.4 GB, 1825361100800 bytes
255 heads, 63 sectors/track, 221920 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077127

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 64 221920 1782059376 83 Linux

Command (m for help): t  ←LVMにする為にsystemidを変更します。
Partition number (1-4): 2  ←パーティション指定
Hex code (type L to list codes): 8e  ←LVMのidを指定、idを確認する場合はCommandでlで一覧がでます。
Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): p  ←最終チェックをします。

Disk /dev/xvda: 1825.4 GB, 1825361100800 bytes
255 heads, 63 sectors/track, 221920 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077127

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 64 221920 1782059376 8e Linux LVM

Command (m for help): w  ←書き込みをします。
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
# reboot ←デバイスが使用中だから適用させる為にリブートをします。

リブート完了後、ボリュームの拡張を実施します。
サイズを確認、この時点では何も変わっていません。
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.2G 46G 3% /
tmpfs 503M 0 503M 0% /dev/shm
/dev/xvda1 485M 30M 430M 7% /boot
/dev/mapper/VolGroup-lv_home
1.2T 1.1T 70G 95% /home

◎物理ボリュームの拡張
サイズの確認
# pvscan
PV /dev/xvda2 VG VolGroup lvm2 [1.27 TiB / 0 free]
Total: 1 [1.27 TiB] / in use: 1 [1.27 TiB] / in no VG: 0 [0 ]
再割り当てを実施
# pvresize /dev/xvda2
Physical volume “/dev/xvda2” changed
1 physical volume(s) resized / 0 physical volume(s) not resized
サイズが大きくなっている事を確認
# pvscan
PV /dev/xvda2 VG VolGroup lvm2 [1.66 TiB / 399.99 GiB free]
Total: 1 [1.66 TiB] / in use: 1 [1.66 TiB] / in no VG: 0 [0 ]

◎論理ボリュームの拡張
サイズの確認
# lvscan
ACTIVE ‘/dev/VolGroup/lv_root’ [50.00 GiB] inherit
ACTIVE ‘/dev/VolGroup/lv_home’ [1.22 TiB] inherit
ACTIVE ‘/dev/VolGroup/lv_swap’ [1.97 GiB] inherit

サイズの再割り当て、400GだとNGだったので399Gにしています。
# lvscan resize -L +399G /dev/VolGroup/lv_home
Extending logical volume lv_home to 1.61 TiB
Logical volume lv_home successfully resized
サイズが変更されている事を確認
# lvscan
ACTIVE ‘/dev/VolGroup/lv_root’ [50.00 GiB] inherit
ACTIVE ‘/dev/VolGroup/lv_home’ [1.61 TiB] inherit
ACTIVE ‘/dev/VolGroup/lv_swap’ [1.97 GiB] inherit

◎ファイルシステムの拡張

対象ボリュームを指定して再割り当てを実施、サイズによっては結構時間がかかります。
# resize2fs /dev/mapper/VolGroup-lv_home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_home is mounted on /home; on-line resizing required
old desc_blocks = 78, new_desc_blocks = 103
Performing an on-line resize of /dev/mapper/VolGroup-lv_home to 431630336 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_home is now 431630336 blocks long.

無事拡張されました。
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.2G 46G 3% /
tmpfs 503M 0 503M 0% /dev/shm
/dev/xvda1 485M 30M 430M 7% /boot
/dev/mapper/VolGroup-lv_home
1.6T 1.1T 443G 72% /home

注意!!
拡張は必ず物理→論理→ファイルシステムの順番で実施して下さい。
基本は箱の外側から大きくしていくことです。
外側が広がっていなければ内側が広がる事はないですからね。