Fedora 17 まとめ

  • Gnome のfallback mode の設定
# gsettings set org.gnome.desktop.session session-name gnome-fallback
  • sshd の有効化、起動、停止、再起動
# systemctl {enable|start|stop|restart} sshd.service
  • 日本語入力環境

Input Method Selecter から、EnglishとJapanese Anthyを選択

  • Desktop環境(cdm + qvwm
# yum install cdm

Edit /etc/cdmrc

usexinit=yes

/etc/yum.repos.d/rpm-sphere.repo

[rpm-sphere]
name=RPM Sphere
baseurl=http://download.opensuse.org/repositories/home:/zhonghuaren/Fedora_17/
gpgkey=http://download.opensuse.org/repositories/home:/zhonghuaren/Fedora_17/repodata/repomd.xml.key
enabled=1
gpgcheck=1
# yum install qvwm
# echo exec qvwm > /etc/skel/.xsession
# echo exec qvwm > /etc/skel/.xinitrc

$ echo exec qvwm > ~/.xsession
$ echo exec qvwm > ~/.xinitrc

/etc/yum.repos.d/google-chrome.repo

[google-chrome]
name=google-chrome - 64-bit
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

How to capture video from IEEE1394 to Linux

Env: Fedora Core 15

1) Add RPM Fusion repository

$ su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'

2) Install RPMs

# yum install dvgrab ffmpeg gstreamer-ffmpeg xvidcore-devel

3) Capture a video and convert it to MPEG2 for DVD

# dvgrab - | ffmpeg -i - -target dvd output.mpg

4) Make an dvd.xml file for dvdauthor.

<dvdauthor>
<vmgm/>
<titleset>
<titles>
<pgc>
<vob file="output.mpg" chapters="0,5:00,10:00,15:00,20:00,25:00,30:00,35:00,40:00,45:00,50:00,55:00,60:00,65:00,70:00,75:00,80:00,85:00,90:00,95:00,100:00,105:00,110:00,115:00,120:00,125:00,130:00,135:00,140:00,145:00" />
</pgc>
</titles>
</titleset>
</dvdauthor>

5) Make a DVD directory.

# dvdauthor -o dvd/ -x dvd.xml

6) Make an index for the dvd directory.

# dvdauthor -T -o /tmp/dvd

7) Make an iso file of the movie.

# mkisofs -dvd-video -o dvd.iso dvd/

8) Burn the iso image to the blank media.

# growisofs -dvd-compat -Z /dev/hdc=dvd.iso

dyndns.com 用のシンプルなクライアント

dyndnsを調べてみると、IPアドレスを更新するには、以下のURLにアクセスするだけでよいようだ。

http://members.dyndns.org/nic/update?hostname=ホスト名&myip=IPアドレス

ただしこのページにはBASIC認証がかかっている。
dyndns用のクライアントを探したけど、どれも長くて管理が面倒くさそうなので自分で作ってみた。Linux用。wgetさえあれば動く。

crontab に以下のように登録すればOK。(20分おきの場合)

# crontab -e

*/20 * * * * /root/bin/dyndns_client.pl
  • dyndns_client.pl
#!/usr/bin/perl

use strict;
use warnings;

my $ID='ユーザID';
my $PW='パスワード';
my $MYHOST='ホスト名';

my $last_ip=`cat /tmp/last_ip`;
my $current_ip = (`wget -q -O - "http://checkip.dyndns.org/"` =~ m/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/) && $1;
`echo -n $current_ip > /tmp/last_ip`;

if( $current_ip ne $last_ip ) {
        `wget -q -O - --http-user='$ID' --http-passwd='$PW' 'http://members.dyndns.org/nic/update?hostname=$MYHOST&myip=$current_ip'`;
}

IDとパスワードとホスト名だけ変えればOK。IPアドレスが変化したら更新する。

Semisynchronous Replication (半同期レプリケーション?)を試してみた

今までの非同期レプリケーションでは、同期完了前にマスターが死んだ場合に、データのロストが起きるが、MySQL5.5から導入された Semisynchronous Replication(半同期?)を使うと、スレーブ側のバイナリログの更新までが同期で行われるのでデータのロストの可能性がぐっと減る。今回はMySQL5.5.5_m3 というバージョンを使って検証した。
OSは、CentOS5.5-64bit。RPMOracle のサイトからダウンロード。

MySQL-client-5.5.5_m3-1.rhel5.x86_64.rpm
MySQL-server-5.5.5_m3-1.rhel5.x86_64.rpm
MySQL-devel-5.5.5_m3-1.rhel5.x86_64.rpm
MySQL-shared-compat-5.5.5_m3-1.rhel5.x86_64.rpm

テストを簡単にするためにDBはtestを使用し、テーブル無しの状態から。

master:10.0.7.8、 slave:10.0.7.8 とする。

  • マスター側の設定

プラグインのインストールとユーザ追加

mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';

mysql> CREATE USER 'repl'@'%' IDENTIFIED BY 'pw';     #レプリケーション用のユーザの作成
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';  #レプリケーション用のユーザへの「REPLICATION SLAVE」権限設定

/etc/my.cnfの編集

[mysqld]
log-bin=mysql-bin
server-id=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1

rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=10

ログの位置確認

mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      107 |              |                  |
+------------------+----------+--------------+------------------+

上記の値を以下で使用する。

  • スレーブ側の設定

プラグインのインストール

mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';

/etc/my.cnfの編集

[mysqld]
server-id=2
rpl_semi_sync_slave_enabled=1
mysql> CHANGE MASTER TO MASTER_HOST='10.0.7.8', MASTER_USER='repl', MASTER_PASSWORD='pw', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;
mysql> STOP SLAVE IO_THREAD;
mysql> START SLAVE IO_THREAD;
mysql> START SLAVE;
  • テスト開始

マスター側

mysql> CREATE TABLE `t1` (`id` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
mysql> INSERT INTO `t1` VALUES(1);
mysql> INSERT INTO `t1` VALUES(2);
mysql> INSERT INTO `t1` VALUES(3);
mysql> SELECT * FROM `t1`;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.01 sec)

スレーブ側

mysql> SELECT * FROM `t1`;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.01 sec)

これでは、semisynchronousレプリケーション なのか、asynchronous レプリケーション のどちらでレプリケーションされたかわからない。

次に、SLAVE側のSQL_THREADを停止して、ログの位置を確認する。(878)

スレーブ側

mysql> STOP SLAVE SQL_THREAD;
mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
	<省略>
          Read_Master_Log_Pos: 878
          Exec_Master_Log_Pos: 878
	<省略>
1 row in set (0.00 sec)

次にマスター側にレコードを追加してログの位置を確認する。「1062」まで進んでいるのがわかる。

mysql> INSERT INTO `t1` VALUES(4);
mysql> SELECT * FROM `t1`;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
+------+
4 rows in set (0.00 sec)

mysql> SHOW MASTER STATUS\G
*************************** 1. row ***************************
            File: mysql-bin.000002
        Position: 1062
    Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)


次にスレーブ側のログの位置を確認する。「1062」まで作成されているが、「878」までしか実行されていない。テーブルの中身を確認すると3レコードのまま。

mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
          Read_Master_Log_Pos: 1062
          Exec_Master_Log_Pos: 878

mysql> SELECT * FROM `t1`;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)

semisynchronousレプリケーション により、バイナリログは正常に同期されていることがわかる。この時点で、マスター側を停止しても、スレーブ側へのレプリケーションが問題なく行われることを確認する。

マスター側のMySQLを停止する。

# service mysql stop

スレーブ側のSQL_THREADを再開する。ログの位置が「1062」まで実行されている。テーブルの中身を確認すると4レコードに増えていることを確認する。

mysql> START SLAVE SQL_THREAD;

mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
          Read_Master_Log_Pos: 1062
          Exec_Master_Log_Pos: 1062

mysql> SELECT * FROM `t1`;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
+------+
4 rows in set (0.01 sec)

SMTP Authを使った外部のSMTPサーバーへのリレー方法

自宅サーバーからメールを送信する際に、直接メールを送信するのではなく、ISPが提供しているSMTPサーバーを利用する。
通常は固定グローバルIPでは無いため、SPAM扱いされ易いが、正規のSMTPサーバー経由で送信するので素性の知れたメールになるので少しはSPAM扱いされにくくなる。OSは、Ubuntu 10.04サーバーを使用。


1./etc/postfix/main.cf を以下のように編集。

#relayhost = [プロバイダから指定されているSMTPサーバーのIPまたはホスト名]
relayhost = [smtp.comcast.net]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=


2. /etc/postfix/sasl_passwd を以下のように作成

smtp.comcast.net ユーザID:パスワード

Comcastの場合は、@comcast.netの前の部分。

念のため以下のようにしておく。

$ sudo chown root:root /etc/postfix/sasl_passwd
$ sudo chmod 600 /etc/postfix/sasl_passwd

3. postmapコマンドを実行

$ sudo postmap hash:/etc/postfix/sasl_passwd

4. Postfix のリロード

$ sudo /etc/init.d/postfix reload