2011年12月19日月曜日

apacheのrpmbuildでconfigure: error: distcache support failed: can't include distcache headers

httpdをrpmbuildするとよく怒られる。
configure: error: distcache support failed: can't include distcache headers
distcacheのライブラリがないと言ってるだけなので、
yum -y install distcache-devel
 で解決。

2011年10月14日金曜日

gpg を利用したLinuxでのファイル暗号化

GnuPG(gpg)をインストール後、鍵のペアを生成。

# gpg --gen-key

パスフレーズを紛失した時のために、破棄証明書を作成しておく

# gpg -o revcert.asc --gen-revoke user

他のサーバーでimportするための、公開鍵をexport(やる場合)

# gpg -a -o userpub.key --export user

作った公開鍵でファイルを暗号化

# gpg -a -o myfile.enc -e -r user myfile

gpg で失効証明書作ったんだけど

日本語訳がひどいのか原文がひどいのか、ちょっと面白いことに

# gpg -o revcert.asc --gen-revoke test
この鍵にたいする失効証明書を作成しますか? (y/N) y
失効の理由を選択してください:
0 = 理由は指定されていません
1 = 鍵がパクられました
2 = 鍵がとりかわっています
3 = 鍵はもう不用です
Q = キャンセル
(ここではたぶん1を選びます)
あなたの決定は? 3
予備の説明を入力。空行で終了:
>
失効理由: 鍵はもう不用です
(説明はありません)
よろしいですか? (y/N) y

次のユーザーの秘密鍵のロックを解除するには
パスフレーズがいります:“xxxxxxxxxxxxx”
1024ビットDSA鍵, ID 2C114969作成日付は2011-10-14

ASCII包装出力を強制します。
失効証明書を作成しました。

見つからないような媒体に移動してください。もしワルがこの証明書への
アクセスを得ると、そいつはあなたの鍵を使えなくすることができます。
媒体が読出し不能になった場合に備えて、この証明書を印刷して保管するの
が賢明です。しかし、ご注意ください。あなたのマシンの印字システムは、
だれでも見える場所にデータをおくことがあります!

マジか

2011年10月5日水曜日

icmp Destination Host Prohibited

pingで

icmp_seq=1 Destination Host Prohibited
icmp_seq=2 Destination Host Prohibited
icmp_seq=3 Destination Host Prohibited
icmp_seq=4 Destination Host Prohibited
icmp_seq=5 Destination Host Prohibited
...

とか出る場合は、だいたい相手に落とされてる場合が多い。
iptablesの確認をしてもらうのがよいかも。

2011年9月30日金曜日

pamとは

Linuxで認証系の設定をしようとすると避けては通れないPAMのメモ。
PAM:Pluggable Authentication Modulesということくらいは知っていたが、設定がよくわからなかった。

# cat /etc/pam.d/system-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required pam_env.so
auth sufficient pam_fprintd.so
auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_succeed_if.so uid >= 500 quiet
auth required pam_deny.so
...

上記は、system-authの抜粋。

左から、
type control module module-arguments
という感じで記述する。
typeは、
auth, account, password, session
の4種類あって、
auth はその名の通り認証系の設定
account は、アカウントの有効期限が正しいか、有効か、などのチェック
password は、チャレンジレスポンス認証などの際に、トークンを更新するのに使う
session は、ロギング等に使う。

controlは、
required, requisite, sufficient, optional, include
の5種類。
required に設定されていると、モジュールを必ず通る
requisite は、requiredに似ているが、失敗するとそこで止まる。
sufficient は、成功するとそこで認証を終わる。

2011年9月1日木曜日

memcached を複数起動する方法

memcachedを複数動かしたいと言われたので対応。

■ /etc/sysconfig/memcached を適当にコピーして変更
# cp /etc/sysconfig/memcached /etc/sysconfig/memcached-2

PORT="11212"
USER="nobody"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
■ /etc/init.d/memcached を適当にコピーして変更

#! /bin/sh
#
# chkconfig: - 55 45
# description:  The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached

# Source function library.
. /etc/rc.d/init.d/functions

PORT=11212
USER=nobody
MAXCONN=1024
CACHESIZE=64
OPTIONS=""

if [ -f /etc/sysconfig/memcached ];then
    . /etc/sysconfig/memcached-2
fi

# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
    exit 0
fi

RETVAL=0
prog="memcached"

start () {
    echo -n $"Starting $prog: "
    # insure that /var/run/memcached has proper permissions
    chown $USER /var/run/memcached
    daemon memcached -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached-2.pid $OPTIONS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached-2
}
stop () {
    echo -n $"Stopping $prog: "
    killproc memcached
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ] ; then
        rm -f /var/lock/subsys/memcached-2
        rm -f /var/run/memcached-2.pid
    fi
}

restart () {
    stop
    start
}


# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
    stop
    ;;
    status)
    status memcached
    ;;
    restart|reload)
    restart
    ;;
    condrestart)
    [ -f /var/lock/subsys/memcached-2 ] && restart || :
    ;;
    *)
    echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
    exit 1
esac

exit $?
ロックファイルとpidファイルだけリネームしておけばよさそう。

■ chkconfigに登録と起動
# chkconfig --add memcached-2
# service memcached-2 start
※chkconfig動いてない場合は、普通に/etc/init.d/memcached-2 start で起動する

■ 変更したポートで動いてるか確認
# telnet localhost 11212
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
set foo 0 100 4
test
STORED
get foo
VALUE foo 0 4
test
END
めでたし。

2011年8月23日火曜日

telnetでSMTPを確認

トランザクションはこんな感じ。
# telnet 172.16.113.12 25
Trying 172.16.113.12...
Connected to 172.16.113.12 (172.30.113.12).
Escape character is '^]'.
220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Tue, 23 Aug 2011 10:54:14 +0900
EHLO localhost
250-localhost.localdomain Hello [172.16.113.8], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
MAIL FROM: canada@dev
250 2.1.0 canada@dev... Sender ok
RCPT TO: test@sys.jp
250 2.1.5 test@sys.jp... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
TEST
.
250 2.0.0 p7N1sEpb009113 Message accepted for delivery
QUIT
221 2.0.0 localhost.localdomain closing connection
Connection closed by foreign host.
 telnetでport25を指定して接続、EHLOコマンドでセッションを確立して、MAIL FROMとRCPT TOで送信元と宛先を指定、DATAコマンドで本文を書く。.(ドット)で本文終了。QUITでセッション切断。

2011年8月22日月曜日

kill でプロセスが落とせないときは

SIGHUP以外のシグナルをおくる。
たとえばSIGQUITとか。

kill -s 3 <PID>

以下がシグナルのリスト。

 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
 5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE
 9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2
13) SIGPIPE     14) SIGALRM     15) SIGTERM     16) SIGSTKFLT
17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU
25) SIGXFSZ     26) SIGVTALRM   27) SIGPROF     28) SIGWINCH
29) SIGIO       30) SIGPWR      31) SIGSYS      34) SIGRTMIN
35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3  38) SIGRTMIN+4
39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6
59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX


2011年8月19日金曜日

BIG-IPのiRule使い方とか

BIG-IPのiRuleが結構便利。

設定は、[Local Traffic]->[iRules]からできる。

構文はこんな感じ。

when CLIENT_ACCEPTED  {
        if { [matchclass [IP::client_addr] equals $::proxy_global] }{
            pool POOL_TEST_80
        } else {
            reject
        }

}

when <EVENT>で、イベントを対象にして処理をトリガする。
CLIENT_ACCEPTEDだと、クライアントを受け付けたイベント。
ほかにもHTTP_REQUESTとかいろいろある。

2011年8月8日月曜日

linuxでCPUのベンチマーク

ちょっとlinuxでCPUのベンチをとる必要にかられたのでメモ。

使ったのはUnixBenchというツール。
ここからダウンロードできるみたい。

ダウンロードしたら、
tar zxvf UnixBench5.1.3.tgz
とかで普通に解凍して、makeを実行。あとは
./Run
で動かして、 結果が出力されるまでひたすら待つ。マルチCPUだと30分くらいかな?
環境によってはperlのTimes::HiResモジュールが必要なので、cpanでインストールする。

結果はこんな感じ

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: myhostname: GNU/Linux
   OS: GNU/Linux -- 2.6.18-238.9.1.el5 -- #1 SMP Tue Apr 12 18:10:13 EDT 2011
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(R) CPU X5670 @ 2.93GHz (5866.9 bogomips)
          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   00:24:56 up 2 days, 10:42,  2 users,  load average: 0.00, 0.00, 0.00; runlevel 3

------------------------------------------------------------------------
Benchmark Run: 月  8月 08 2011 00:24:56 - 00:53:06
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       18388869.4 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     3613.3 MWIPS (9.9 s, 7 samples)
Execl Throughput                               6182.9 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1229990.6 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          353667.4 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       2294764.6 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2850110.8 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 592138.4 lps   (10.0 s, 7 samples)
Process Creation                              19417.2 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   8989.3 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1257.5 lpm   (60.0 s, 2 samples)
System Call Overhead                        4903017.2 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   18388869.4   1575.7
Double-Precision Whetstone                       55.0       3613.3    657.0
Execl Throughput                                 43.0       6182.9   1437.9
File Copy 1024 bufsize 2000 maxblocks          3960.0    1229990.6   3106.0
File Copy 256 bufsize 500 maxblocks            1655.0     353667.4   2137.0
File Copy 4096 bufsize 8000 maxblocks          5800.0    2294764.6   3956.5
Pipe Throughput                               12440.0    2850110.8   2291.1
Pipe-based Context Switching                   4000.0     592138.4   1480.3
Process Creation                                126.0      19417.2   1541.0
Shell Scripts (1 concurrent)                     42.4       8989.3   2120.1
Shell Scripts (8 concurrent)                      6.0       1257.5   2095.9
System Call Overhead                          15000.0    4903017.2   3268.7
                                                                   ========
System Benchmarks Index Score                                        1947.0


とりあえず最後のIndexスコアっていうのが、全体の平均なので、その辺を参考に。 ちなみに上の結果は、Xeon5670の2.93GHzです。

2011年7月22日金曜日

サイボウズからエクスポートしたCSVをGoogle Calendarに同期させる方法

サイボウズの個人設定⇒スケジュールと設備から、CSVを書き出す
ヘッダ行を
"Start Date","Start Time","End Date","End Time","予定","Subject","Description","Meeting Organizer","Location"
に書き換える
Google Calendarでインポート

heartbeat 設定メモ

heartbeat スタートガイド

今回の構成
Node 1 (linuxha1):   192.168.85.1  (normal 192x net)
                     10.0.0.1 (ハートビート用プライベートネットワーク)
Node 2 (linuxha2):   192.168.85.2
                     10.0.0.2
クラスタ用アドレス:192.168.85.3


まず設定する必要のあるファイルは、/etc/ha.d/ha.cf


watchdog /dev/watchdog
Optional.  The watchdog function provides a way to have a system that is still minimally functioning, but not providing a heartbeat, reboot itself after a minute of being sick.  This could help to avoid a scenario where the machine recovers its heartbeat after being pronounced dead.  If that happened and a disk mount failed over, you could have two nodes mounting a disk simultaneously. If you wish to use this feature, then in addition to this line, you will need to load the "softdog" kernel module and create the actual device file.  To do this, first type "insmod softdog" to load the module. Then, type "grep misc /proc/devices" and note the number it reports (should be 10).  Next, type "cat /proc/misc | grep watchdog" and note that number (should be 130).  Now you can create the device file with that info typing, "mknod /dev/watchdog c 10 130".
bcast eth1
Specifies to use a broadcast heartbeat over the eth1 interface (replace with eth0, eth2, or whatever you use).
keepalive 2
Sets the time between heartbeats to 2 seconds.
warntime 10
Time in seconds before issuing a "late heartbeat" warning in the logs.
deadtime 30
Node is pronounced dead after 30 seconds.
initdead 120
With some configurations, the network takes some time to start working after a reboot.   This is a separate "deadtime" to handle that case.  It should be at least twice the normal deadtime.
hopfudge 1
Optional.  For ring topologies, number of hops allowed in addition to the number of nodes in the cluster.
baud 19200
Speed at which to run the serial line (bps).
udpport 694
Use port number 694 for bcast or ucast communication. This is the default, and the official IANA registered port number.
auto_failback on
Required.  For those familiar with Tru64 Unix, heartbeat acts as if in "favored member" mode.  The master listed in the haresources file holds all the resources until a failover, at which time the slave takes over.  When auto_failback is set to on once the master comes back online, it will take everything back from the slave.  When set to off this option will prevent the master node from re-acquiring cluster resources after a failover. This option is similar to to the obsolete nice_failback option. If you want to upgrade from a cluster which had nice_failback set off, to this or later versions, special considerations apply in order to want to avoid requiring a flash cut. Please see the FAQ for details on how to deal with this situation.
node linuxha1.linux-ha.org

Mandatory.  Hostname of machine in cluster as described by `uname -n`.

node linuxha2.linux-ha.org

Mandatory.  Hostname of machine in cluster as described by `uname -n`.

respawn  userid  cmd

Optional:  Lists a command to be spawned  and monitored.  Eg:  To spawn ccm daemons the following line has to be added:
        respawn hacluster /usr/lib/heartbeat/ccm
Informs heartbeat to spawn the command with the credentials of that of userid (hacluster, in this example) and monitors the health of the process, respawning it if dead.  For ipfail, the line would be:
          respawn hacluster /usr/lib/heartbeat/ipfail
NOTE
: If the process dies with exit code 100, the process is not respawned.


ping    ping1.linux-ha.org  ping2.linux-ha.org ....

Optional: Specify ping nodes.  These nodes are not considered as cluster nodes.  They are used to check  network connectivity for modules like ipfail.



ping_group    name  ping1.linux-ha.org  ping2.linux-ha.org ....

Optional: Specify a group ping nodes.  These are the similar to ping nodes, but if any node in a group is available then the group is considered available. The group name can be any string and is used to uniquely identify the group. Each group must appear on a separate line. Like ping nodes the group is not considered to be a cluster node. They appear to be the same as ping nodes and are used to check  network connectivity for modules like ipfail.
続いては /etc/ha.d/haresoureces の設定。このファイルは両方のノードで同じである必要がある。

例えば apache と samba をHAで構成したい場合
linuxha1 192.168.85.3 httpd smb
と設定する。このIPアドレスはクラスタのアドレスで、haresourece ファイルの中にのみ記述する。こうすることで、このアドレスでapacheとsmbのサービスが起動する。
httpd と smb は、当然ながら /etc/rc.d/init.d にスクリプトが存在する必要がある。
もしくは、 /etc/ha.d/resource.d でも構わない。
ちなみに、ネットマスクはIPアドレスのクラスを元に勝手にネットマスクが設定されるが、自分で設定したい場合は、192.168.85.3/24 とかで設定する。

Configuring ipfail
The ipfail plugin attempts to provide detection of network failures, and then intelligently react, directing the cluster to failover resources as necessary. In order to accomplish this goal, it uses ping nodes or ping groups which work as "dumb" third parties in the cluster. Provided both HA nodes can communicate with each other, ipfail can reliably detect when one of their network links has become unusable, and compensate.

To configure ipfail, the following steps must be performed.
  1. Select good ping node candidates.
    It is essential that good strategic ping nodes be selected. The better your choices, the stronger your HA cluster becomes. Choosing solid network devices like switches and routers is a good idea. Do not choose either of the members of the HA cluster. Nor should you select someone's workstation. It is also important to select ping nodes that reflect the connectivity of your HA nodes. If you wish to monitor the connectivity of two interfaces, it is wise to select a ping node for each interface, that is reachable exclusively from said interface. Consult ipfail-diagram.pdf for a graphical representation of this idea.
  2. Set auto_failback to on or off.
    ipfail will only operate if heartbeat has been configured to something other than legacy In ha.cf, set the auto_failback option to "on" or "off" like so:
    auto_failback on
    or
    auto_failback off
  3. Configure your ha.cf to start ipfail.
    Add a line like the following to ha.cf (assuming your compile PREFIX is /usr)
    respawn hacluster /usr/lib/heartbeat/ipfail
  4. Add the ping nodes to ha.cf.
    The ping nodes can be added to the cluster by using a line like the following:
    ping pnode1 pnode2 pnodeN
    Simply replace pnode1, pnode2, ... pnodeN with the IP addresses of your ping nodes.
Ensure that the above configuration directives are added to the ha.cf on both members of the cluster, and that they are identical.
NOTE: You will want to check on the availability of the ping nodes prior to using them. If you cannot ping them from both of the HA nodes, they are useless.

Selecting an Interface

One important aspect of configuring the haresources file for a machine which has multiple ethernet interfaces is to know how heartbeat selects which interface will wind up supporting the service addresses that are configured in haresources.  After all, no interface was specified in the haresources file. Heartbeat decides which interface will be used by looking at the routing table.  It tries to select the lowest cost route to the IP address to be taken over.  In the case of a tie, it chooses the first route found.  For most configurations this means the default route will be least preferred.
If you don't specify a netmask for the IP address in the haresources file, the netmask associated with the selected route will be used. Simmilarly, if an interface is not specivied, then the virtual ip address will be added to the interface associated with the selected route. If the broadcast address is omitted then the hightest address in the subnet is used.
 
Configuring Authkeys
The third file to configure determines your authentication keys.  There are three types of authentication methods available:  crc, md5, and sha1.  "Well, which should I use?", you ask.  Since this document is called "Getting Started", we'll keep it simple......
If your heartbeat runs over a secure network, such as the crossover cable in our example, you'll want to use crc.  This is the cheapest method from a resources perspective.  If the network is insecure, but you're either not very paranoid or concerned about minimizing CPU resources, use md5.  Finally, if you want the best authentication without regard for CPU resources, use sha1.  It's the hardest to crack.
The format of the file is as follows:
auth <number>
<number> <authmethod> [<authkey>]
SO, for sha1, a sample /etc/ha.d/authkeys could be:
auth 1
1 sha1 key-for-sha1-any-text-you-want
For md5, you could use the same as the above, but replace "sha1" with "md5".
Finally, for crc, a sample might be:
auth 2
2 crc
Whatever index you put after the keyword auth must be found below in the keys listed in the file. If you put "auth 4", then there must be an "4 signaturetype" line in the list below.
Make sure its permissions are safe, like 600.  And "any text you want" is not quite right.  There's a limit to the number of characters you can use.
That's it!

Starting and testing heartbeat

From Red Hat, or other distributions which use /etc/init.d startup files, simply type /etc/init.d/heartbeat start on both nodes.  I would recommend starting on the system master (in our example linuxha1) first. If you want heartbeat to run on startup, what to do will differ on your distribution.  You may need to place links to the startup script in the appropriate init level directories, but the RPM versions will do this for you.  I have heartbeat start at its default sequential priority (75, which means it starts after services 74 and lower and before services with priority 76-99), end at its default sequential priority (05), and only care about the 0(halt), 6(reboot), 3(text-only), 5(X) run levels.
So, if I had to do it by hand, I'd need to type in the following (as root, of course):
    cd /etc/rc.d/rc0.d ; ln -s ../init.d/heartbeat K05heartbeat
    cd /etc/rc.d/rc3.d ; ln -s ../init.d/heartbeat S75heartbeat
    cd /etc/rc.d/rc5.d ; ln -s ../init.d/heartbeat S75heartbeat
    cd /etc/rc.d/rc6.d ; ln -s ../init.d/heartbeat K05heartbeat
The last time I ran slackware, there was no /etc/rc.d/init.d directory (may have changed by now) and to do the same thing, I would have placed in /etc/rc.d/rc.local:
    /etc/ha.d/heartbeat start
***This assumes you copy the file ha.rc to /etc/ha.d/heartbeat.  If you can't find /etc/rc.d/init.d with your distribution and you're unsure of how processes start, you can use the rc.local method.  But you're on your own for shutdown, I just don't remember...
Note:  If you use the watchdog function, you'll need to load its module at bootup as well.  You can put the following command at the bottom of the /etc/rc.d/rc.sysinit file:
    /sbin/insmod softdog
For the rc.local method, just put the same line right above where you start heartbeat.
 
Once you've started heartbeat, take a peek at your log file (default is /var/log/ha-log) before testing it.  If all is peachy, the service owner's log (linuxha1 in our example) should look something like this:
heartbeat: 2003/02/10_13:52:22 info: Neither logfile nor logfacility found.
heartbeat: 2003/02/10_13:52:22 info: Logging defaulting to /var/log/ha-log
heartbeat: 2003/02/10_13:52:22 info: **************************
heartbeat: 2003/02/10_13:52:22 info: Configuration validated. Starting heartbeat 0.4.9f
heartbeat: 2003/02/10_13:52:22 info: nice_failback is in effect.
heartbeat: 2003/02/10_13:52:22 info: heartbeat: version 0.4.9f
heartbeat: 2003/02/10_13:52:22 info: Heartbeat generation: 17
heartbeat: 2003/02/10_13:52:22 info: Starting serial heartbeat on tty /dev/ttyS0 (19200 baud)
heartbeat: 2003/02/10_13:52:22 info: UDP Broadcast heartbeat started on port 694 (694) interface eth1
heartbeat: 2003/02/10_13:52:23 info: pid 28140 locked in memory.
heartbeat: 2003/02/10_13:52:23 info: pid 28137 locked in memory.
heartbeat: 2003/02/10_13:52:23 info: pid 28139 locked in memory.
heartbeat: 2003/02/10_13:52:23 notice: Using watchdog device: /dev/watchdog
heartbeat: 2003/02/10_13:52:23 info: pid 28141 locked in memory.
heartbeat: 2003/02/10_13:52:23 info: Local status now set to: 'up'
heartbeat: 2003/02/10_13:52:23 info: pid 28138 locked in memory.
heartbeat: 2003/02/10_13:52:23 info: pid 28134 locked in memory.
heartbeat: 2003/02/10_13:52:25 info: Link linuxha1.linux-ha.org:eth1 up.
heartbeat: 2003/02/10_13:53:23 WARN: node linuxha2.linux-ha.org: is dead
heartbeat: 2003/02/10_13:53:23 info: Dead node linuxha2.linux-ha.org held no resources.
heartbeat: 2003/02/10_13:53:23 info: Resources being acquired from linuxha2.linux-ha.org.
heartbeat: 2003/02/10_13:53:23 info: Local status now set to: 'active'
heartbeat: 2003/02/10_13:53:23 info: Running /etc/ha.d/rc.d/status status
heartbeat: 2003/02/10_13:53:23 info: /usr/lib/heartbeat/mach_down: nice_failback: acquiring foreign resources
heartbeat: 2003/02/10_13:53:23 info: mach_down takeover complete.
heartbeat: 2003/02/10_13:53:23 info: mach_down takeover complete for node linuxha2.linux-ha.org.
heartbeat: 2003/02/10_13:53:23 info: Acquiring resource group: linuxha1.linux-ha.org 192.168.85.3 datadisk::drbd0 datadisk::drbd1 mirror
heartbeat: 2003/02/10_13:53:23 info: Running /etc/ha.d/resource.d/IPaddr 192.168.85.3 start
heartbeat: 2003/02/10_13:53:23 info: /sbin/ifconfig eth0:0 192.168.85.3 netmask 255.255.255.0  broadcast 192.168.85.255
heartbeat: 2003/02/10_13:53:23 info: Sending Gratuitous Arp for 192.168.85.3 on eth0:0 [eth0]
heartbeat: 2003/02/10_13:53:23 /usr/lib/heartbeat/send_arp eth0 192.168.85.3 00304823BD48 192.168.85.3 ffffffffffff
heartbeat: 2003/02/10_13:53:24 info: Running /etc/ha.d/resource.d/datadisk drbd0 start
heartbeat: 2003/02/10_13:53:24 info: Running /etc/ha.d/resource.d/datadisk drbd1 start
heartbeat: 2003/02/10_13:53:25 info: Running /etc/ha.d/resource.d/mirror  start
heartbeat: 2003/02/10_13:53:25 /usr/lib/heartbeat/send_arp eth0 192.168.85.3 00304823BD48 192.168.85.3 ffffffffffff
heartbeat: 2003/02/10_13:53:26 info: Resource acquisition completed.
heartbeat: 2003/02/10_13:53:28 /usr/lib/heartbeat/send_arp eth0 192.168.85.3 00304823BD48 192.168.85.3 ffffffffffff
heartbeat: 2003/02/10_13:53:30 /usr/lib/heartbeat/send_arp eth0 192.168.85.3 00304823BD48 192.168.85.3 ffffffffffff
heartbeat: 2003/02/10_13:53:32 /usr/lib/heartbeat/send_arp eth0 192.168.85.3 00304823BD48 192.168.85.3 ffffffffffff
heartbeat: 2003/02/10_13:53:33 info: Local Resource acquisition completed. (none)
heartbeat: 2003/02/10_13:53:33 info: local resource transition completed.
heartbeat: 2003/02/10_13:56:30 info: Link linuxha2.linux-ha.org:eth1 up.
heartbeat: 2003/02/10_13:56:30 info: Status update for node linuxha2.linux-ha.org: status up
heartbeat: 2003/02/10_13:56:30 info: Running /etc/ha.d/rc.d/status status
heartbeat: 2003/02/10_13:56:30 info: Status update for node linuxha2.linux-ha.org: status active
heartbeat: 2003/02/10_13:56:30 info: remote resource transition completed.
heartbeat: 2003/02/10_13:56:30 info: Running /etc/ha.d/rc.d/status status
heartbeat: 2003/02/10_13:56:31 info: Link linuxha2.linux-ha.org:/dev/ttyS0 up.
NOTE:  Your log may differ depending on when you started heartbeat on linuxha2!!!  I started heartbeat on the linuxha2 @13:56:30...


OK, now try to ping your cluster's IP (192.168.85.3 in the example). If this works, ssh to it and verify you're on linuxha1.
Next, make sure your services are tied to the .3 address.  Bring up netscape and type in 192.168.85.3 for the URL.  For Samba, try to map the drive "\\192.168.85.3\test"  assuming you set up a share called "test".  See Samba docs to get that going.  As an aside, however, you'll want to use the "netbios name" parameter to have your Samba share listed under the cluster name and not the hostname of your cluster member!
NOTE: If you can't bring up the service IP address and you get ha-log entries similar to this:
        SIOCSIFADDR: No such device
        SIOCSIFFLAGS: No such device
        SIOCSIFNETMASK: No such device
        SIOCSIFBRDADDR: No such device
        SIOCSIFFLAGS: No such device
        SIOCADDRT: No such device
It may mean that you need to enable IP aliasing in your kernel build.  Check /usr/src/linux/.config for "CONFIG_IP_ALIAS=y" if you don't have it, you'll have the line "CONFIG_IP_ALIAS is not set".  Rebuild your kernel with IP aliasing enabled.
If this all works, you've got availability.  Now let's see if we have High Availability :-) Take down linuxha1.  Kill power, kill heartbeat, whatever you have the stomach for, but don't just yank both the serial and eth1 heartbeat cables.  If you do that, you'll have services running on both nodes and when you re-connect the heartbeat, a bit of chaos....
Now ping the cluster IP. Approximately 5-10 seconds later it should start responding again. Telnet again and verify you're on linuxha2.  If it happens but takes more like 30 seconds, something is wrong.
If you get this far, it's probably working, but you should probably check all your heartbeats, too.
First, check your serial heartbeat.  Unplug the crossover cable from your eth1 NIC that you're using for your bcast heartbeat.  Wait about 10 seconds.
Now, look at /var/log/ha-log on linuxha2 and make sure there's no line like this:
    1999/08/16_12:40:58 node linuxha1.linux-ha.org: is dead
If you get that, your serial heartbeat isn't working and your second node is taking over.  To avoid any problems, shut down heartbeat on the first node, then test your null modem cable.  Run the above serial tests again.
If your log is clean, great.  Re-connect the crossover cable.  Once that's done, disconnect the serial cable, wait 10 seconds and check the linuxha2 log again.
If it's clean, congrats!  If not, you can check /var/log/ha-log and /var/log/ha-debug for more clues.
 

2011年7月21日木曜日

lvm 作成メモ

・pvcreate でPhysical Volumeを作成
・vgcreate でVolume Groupを作成
# vgcreate -s 32m VG_NAME /dev/sdb1

・lvcreate でLogical Volumeを作成
# lvcreate -L 49.8G -n Vol_NAME VG_NAME

awk 使い方メモ

apacheのログからアクセス元だけ抽出したい場合
awk '{ print $1 }' /var/log/httpd/access.log
みたいにやればオッケー。ダブルクオートとか使うとダメみたい。

if 文は、条件のみ書けばできる。
awk ' $1 > 100 {print} ' /var/log/httpd/access.log
だと、1カラム目が100より大きければ出力。

セパレータは-Fオプションで指定する。例えば"-"を指定したい場合、

awk -F - '{print $5}'

など。

2011年7月15日金曜日

公開鍵方式でsshログインする

A⇒Bにsshログインしたい場合、
Aで秘密鍵と公開鍵をつくって、公開鍵のほうをBに設定すると、
sshでパスワードをいちいち入力せずにログインできる。
#  ssh-keygen -t rsa
 とかやると、ホームの .ssh ディレクトリに id_rsa.pub というファイルができあがるので、
それをBサーバのログインユーザーの .ssh ディレクトリに authorized_keys というファイルとして作成。

これでめでたし。

2011年7月14日木曜日

aixの /etc/fstab

linux の起動時のマウントは/etc/fstabで管理するんだけど、
AIXは /etc/filesystems らしい。

サンプル
/ftp/test:
        dev             = "/vol/test"
        vfs             = nfs
        nodename        = netappx
        mount           = true
        options         = rw,bg,hard,intr,sec=sys
        account         = false

2011年7月12日火曜日

OpenCVのインストール

インストールガイド

これだとpythonが古いとエラーになるので、

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_NEW_PYTHON_SUPPORT=OFF ..

みたいに-D BUILD_NEW_PYTHON_SUPPORT=OFFのオプションを追加。
これでとりあえずインストールはOK.

2011年7月11日月曜日

cisco catalystのパスワード変更

パスワード変更のメモ
router>enable
Password:
router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
router(config)#line vty 0 4
router(config-line)#password PASSWD
上記の手順で、vtyのパスワード変更ができる。
line vtyの引数は、0から4までを一気に操作する、という意味。
enableは、enable secret コマンドで変更する。

2011年7月8日金曜日

画像をペーストするとexcelのファイルサイズがでかい件

トリミング後の不要領域を削除したいときは、リボンインターフェースから、図の書式設定のところで圧縮して保存する。

2011年7月5日火曜日

proftpd 1.3.3e NLSTオプションのpatch

proftpdは1.2.10以降から、NLSTコマンドに対するオプションを受け付けなくなっている。
それ自体はRFCに準拠する動作なんだけど、それだと困るクライアントやらプログラムやらがあるので、1.2.10以降、いろいろとそれ用に非公式でpatchが作成されている。

で、1.3.3eには対応したものが無かったので書いた。
ProFTPD1.3.3e NLST patch for FFFTP
                              created by http://www.hayasoft.com/haya/
                              date 2007/10/27 21:27 (Japan)
                        modified 2011/07/01 for 1.3.3e by takat33 http://takatlog.blogspot.com/
--- proftpd-1.3.3e/modules/mod_ls.c     2007-09-28 09:53:59.000000000 +0900
+++ proftpd-1.3.3e/modules/mod_ls_new.c 2011-07-01 00:23:59.000000000 +0900
@@ -1279,10 +1279,8 @@
           break;

         case 'C':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_l = 0;
-            opt_C = 1;
-          }
+          opt_l = 0;
+          opt_C = 1;
           break;

         case 'd':
@@ -1290,15 +1288,11 @@
           break;

         case 'F':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_F = 1;
-          }
+          opt_F = 1;
           break;

         case 'h':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_h = 1;
-          }
+          opt_h = 1;
           break;

         case 'L':
@@ -1302,16 +1296,12 @@
           break;

         case 'l':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_l = 1;
-            opt_C = 0;
-          }
+          opt_l = 1;
+          opt_C = 0;
           break;

         case 'n':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_n = 1;
-          }
+          opt_n = 1;
           break;

         case 'R':
@@ -2313,6 +2303,10 @@
   list_nfiles.curr = list_ndirs.curr = list_ndepth.curr = 0;
   list_nfiles.logged = list_ndirs.logged = list_ndepth.logged = FALSE;

+  /* In case the client used NLST instead of LIST. */
+  if (cmd->argc > 1 && cmd->argv[1][0] == '-')
+    return genericlist(cmd);
+
   tmp = get_param_ptr(TOPLEVEL_CONF, "ShowSymlinks", FALSE);
   if (tmp != NULL)
     list_show_symlinks = *tmp;
上のパッチファイルを適当な名前で保存して、proftpd-1.3.3eを展開したディレクトリと同じとこに置く。んで、以下のコマンドでパッチ適用。
# patch -p0 < proftpd-1.3.3e-nlst.patch
これで、NLSTコマンドをオプションつきで実行できるように。めでたし。

2011年7月1日金曜日

telnetでftpのプロトコルベースでの確認

telnetでFTPを確認したいときメモ

とりあえずターミナルを2つひらいて開始。

1> telnet ftpserver 21
220
user Username
331 Password required for Username
pass Password
230 ftpserver.domain.com
PASV
227 Entering Passive Mode (192,168,0,1,182,28)
これで、パッシヴモードでサーバ側が46620port(182*256+28)で待ち受けたので、2つめのターミナルで接続しにいく
2> telnet  localhost 46620
で、1つ目のターミナルで実行したいコマンドを入力
LIST
 そうすると2つ目のターミナルに実行結果が出力される。
めでたし。

2011年6月24日金曜日

tripwire 設定メモ

改ざん検知ツールのtripwireの設定メモ。

インストールしたら、とりあえずポリシーファイルを編集して、監視対象を決める。
普通にインストールすると、/usr/local/etc/twpol.txt にデフォルトのファイルがあるので、中身を編集、
tripwire -m p -Z low twpol.txt
で、ポリシーファイルをアップデート。
# tripwire --init
で、DBを初期化する。
# tripwire --check
で動作確認。ちなみにレポートをメールで送りたい場合は、
# tripwire --check --email-report
で送る。全然設定しないと、なんか化けた感じでメールが来るので、tw.cfgにMAILLENCODING=ISO-2022-JPの設定を追加。twadminコマンドでconfigを再生成する。

tripwireのインストール手順メモ

linuxで使えるフリーの改ざん検知ツール、tripwireのインストールメモ。

ここから最新版をダウンロード。
# ./configure
# make
# make install
で、インストール。同意書を読まされるので、同意してポンポン進む。
サイトのパスフレーズと、ローカルパスフレーズをそれぞれ8文字以上で入力。
Enter the site keyfile passphrase:
Verify the site keyfile passphrase:
 Enter the local keyfile passphrase:
Verify the local keyfile passphrase:
 署名ファイル作成のために、何度か上で入力したパスフレーズを入力して終了。

2011年6月23日木曜日

phpのコンパイルで/usr/bin/ld: cannot find -lltdl

やたらとコンパイル依頼が来るphp。crypt関連のオプションを追加したら以下のエラー。
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
どうやらlibtoolが古いらしいので、libtoolをインストール。
↓ここから
http://www.gnu.org/software/libtool/

64bit環境で共有ライブラリのエラー error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory

64bit環境でなにかをインストールすると、たまにshared objectが見つからなくてエラーになる。
error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory
今回はlibtoolをアップデートした時に起きた。
そんな時は、おとなしく--libdir=/usr/lib64とかのオプションをつけるといいかも。

rpmの『ファイルと競合しています』エラー

mysqlをrpmでアップグレードしようとしてエラー。
     ファイル /usr/bin/mysql_config (パッケージ MySQL-devel-5.5.13-1.rhel5.x86_64 から) は、パッケージ mysql-5.0.77-4.el5_6.6.x86_64 からのファイルと競合しています。
だいたいの場合は、rpm の -U オプションとかでアップデートできるんだけど、たまに競合エラーが出る。
しかたないので、
--force オプションで強制アップデート。
元のファイルは消されるんだけど、しかたないよね。

2011年6月20日月曜日

pecl config-setでエラー config-set (http_proxy, proxy:8080, user) failed, channel pecl.php.net

peclのconfig-setをいくらやってもエラーになる。

# pecl config-set http_proxy proxy:8080
config-set (http_proxy, proxy:8080, user) failed, channel pecl.php.net
こんな感じ。なんかpeclで設定しようとするとダメっぽくて、pearで設定すればうまくいくみたい。めんどくさいから理由は調べてません。

pear config-set http_proxy proxy:8080

phpのmemcacheモジュールインストール

phpのmemcacheモジュールはpeclなので、別途インストールが必要。手順メモ。

configureのオプションに、--with=pearをつけて、pearを有効にする。
で、

pecl install memcache
とかでインストール。
php.iniに
extension=/usr/lib64/20090626/memcache.so
とかの設定を追加すれば使える。

2011年6月16日木曜日

openvpnのインストール・構築手順

OpenVPNのインストールメモ

0. configure && make && make install
1. マスタCA証明書と鍵の作成

tarballを解凍した直下に、easy-rsaというディレクトリがあるので、その中で作業。
まず環境変数読み込み用のファイルを編集。

# vi vars
...
export KEY_COUNTRY="JP"
export KEY_PROVINCE="Tokyo"
export KEY_CITY="Shinagawa"
export KEY_ORG="organization"
export KEY_EMAIL="address"
みたいな感じでKEY_COUNTRYとかを編集する。

で、CA秘密鍵を生成

. ./vars
./clean-all
./build-ca

2. サーバ用証明書と鍵の作成

./build-key-server server
を実行して、ポンポンEnterを押していく
A challenge password []:
An optional company name []:
とかは空でOK。最後にコミットしていいかy/nを聞かれるので、yを入力して終了。

3.クライアントの証明書と鍵の生成
./build-key-pass クライアント名
を実行して、さっきと同じように証明書を生成。最初に鍵とかを保護するためのパスワードを入力する。これで証明書と鍵がそろった。

4. DHパラメータファイルの作成
./build-dh
 を実行

5.サーバの設定

ソースツリー直下のsample-config-filesディレクトリにある、server.confを使って作成。これでだいたいオッケーなので、
# openvpn --cd DIR --config CONF
とかで実行する。クライアントにはconfigとか鍵とかをおくる。

ちなみにクライアントに置くファイルは、
/etc/openvpn/easy-rsa/keys の中の、
・クライアント名.crt
・クライアント名.key
・ca.crt
・クライアント用設定ファイル(つくる)

クライアント用設定ファイルは、クライアントのインストールフォルダのsample-configの中にあるので、それを使うとよいかも。

2011年6月15日水曜日

apache httpd.confのlog設定

最近のapache(2.2.19とか)だと、LogFormatで新しい書式を定義して、CustomLogでログファイルと書式を指定する、みたいな書き方が多いっぽい。

たとえばUserAgentとか処理時間を出力したいときはこんな感じで書く。

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D %X" combined
CustomLog "logs/access_log" combined
%Dはマイクロ秒単位の処理時間、%{User-Agent}i は、HTTPヘッダに含まれるUserAgentの出力。

参考:mod_log_config

2011年6月14日火曜日

windowsのstatic routeの設定

windowsでのstatic routeをたまに設定するときに毎回調べてる気がするので、メモ。

route -p add [NETWORK] mask [NETMASK] [GATEWAY] if [INTERFACE]

これで、NETWORKに対しては、INTERFACEで指定したデバイスから、GATEWAY経由で通信できる。インターフェースは、route printコマンドで表示される数字を指定。

指定しなくても設定はできるけど、2つ目以降のデバイスから接続したい場合はちゃんと指定したほうが無難。

2011年6月9日木曜日

phpのeAcceleratorをインストール

phpのアクセラレータを使いたいと言われたので、eAcceleratorをいれてみた。
インストールと簡単な設定方法とかのメモ。

とりあえず公式サイトから拾ってくる

アーカイブを展開したら、
# phpize
# ./configure
# make install
で、俺の環境(Cent5.6 64bit)だと/usr/lib64/20090626/に出来上がったので、 /usr/lib64/php/modules/とかにコピー。
phpには、zend拡張かphp拡張で読み込ませるんだけど、それはどっちでもいいっぽい。
php拡張として読み込ませる場合は、php.ini に以下のような感じで設定する。
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

winscpでproxyを使いたい

そんなときは、起動時のメニューの左下にある[Advanced options]にチェックを入れると、Connectionメニューが追加されるので、そこからproxyを設定できる。
調べないと気づかなかったのでメモ。

マニュアルはここ

2011年6月8日水曜日

cisco catalystのflexlinkについて

L2で動作するSTP(スパツリ)の代替機能で、STPを使いたくない場合に使用する。
アクティブリンクに対して、バックアップリンクを設定することで、アクティブリンクがダウンした場合にバックアップ側が転送を行う。

# configure terminal
# interface interface-id
# switchport backup interface interface-id
# end
# show interface [ interface-id ] switchport backup

設定はこんな感じ。これでループをおこさずに迂回路が作れる。

phpのconfigureと拡張モジュールのメモ

php.iniのextensionの項目って最近(5.x系)あんまり見ないけど、なんでいろいろ使えるんだろう、と思ってたら、configureのときにsharedつけないと、バイナリに埋め込まれるみたい。

./configure  --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-libdir=lib64 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --with-curl --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-pcre-regex=/usr --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-wddx --with-kerberos --enable-shmop --enable-calendar --without-sqlite --with-libxml-dir=/usr --with-apxs2=/usr/sbin/apxs --with-mysql --with-gd --enable-dom --enable-dba --without-unixODBC --with-pdo-mysql --enable-mbstring --enable-zip --with-db4
 ちなみに今使ってるオプションはこんな感じ。

2011年6月6日月曜日

sudoの設定

sudoの設定は、visudoコマンドで行う。

ユーザーに対する許可の書式は以下の通り。

ユーザー名 ホスト=(権限)コマンド, コマンド...

ホストはほとんどの場合でALLを設定。権限は、省略するとrootになる。コマンドはカンマで複数記述可能。
以上。

2011年6月3日金曜日

logrotateの使い方

logrotateの使い方俺メモ。

オプションメモ
create mode owner group

create 644 apache apache

とかやると、644のパーミッションでapacheユーザー、グループでログをローテーションしてくれる。

圧縮のオプションは
compress

圧縮方式をbzip2とかに変えたいときは
compresscmd /usr/bin/bzip2
compressext .bz2

とかやるとできる。

で、configの検証は logrotate -d /etc/logrotate.d/httpd

とか。

apache が httpd: Could not reliably determine the server's fully qualified domain name, using 172.24.1.1 for ServerName

apache が起動の度になんかうるさい。
httpd: Could not reliably determine the server's fully qualified domain name, using 172.24.1.1 for ServerName
とか。別に動くんだけど、httpd.confのServerNameディレクティブをちゃんと設定してないことが原因らしいので、ちゃんと設定した。
めでたし。

BIG-IPのVIP作成メモ

BIG-IPでVIP(Virtual Server)作る。
・pool の作成
Local Traffic -> Pools -> Create
・Virtual Serverの作成
Local Traffic -> Virtual Servers -> Create

これでめでたし。

windows7 高速化 いらないサービスを停止する

よくあるwindows高速化の手法で、いらないサービスを停止するなんてのがあります。
というわけで、止めたwindows7のサービスのメモ。

IP Helper:ipv6関連サービス
seaport:Microsoftへの情報提供サービス
Windows Live ID Sign-in Assistant: windows live id関連サービス
wlan autoconfig:無線LAN関連のサービス

あんまりなかった。仕事用だし仕方ないか。

2011年6月2日木曜日

phpからmail送信

phpからメール送信を行う場合は、mb_send_mail関数を使うといいかも。

<?php
mb_language("Ja") ;
mb_internal_encoding("EUC-JP") ;
$mailto="test@test.com";
$subject="件名";
$content="本文";
$mailfrom="From:" .mb_encode_mimeheader("フロム") ."<from@test.com>";
mb_send_mail($mailto,$subject,$content,$mailfrom);
?>

で、
$ php mailtest.php

とかで実行してみたり

apache httpd.confのphpの設定

apache上でmod_phpで動かすときの最低限の設定

LoadModule php5_module        /usr/lib64/httpd/modules/libphp5.so
AddType application/x-httpd-php .php

これで動く。IfModuleの設定とかもしたほうがいいっちゃいいかも。

2011年5月31日火曜日

openvpnの設定ファイル

OpenVPNで、たまにアカウントを追加すると、クライアントに置くファイルがどれだかわからなくなる。っていうんでこの表が便利かも。

Filename Needed By Purpose Secret
ca.crt server + all clients Root CA certificate NO
ca.key key signing machine only Root CA key YES
dh{n}.pem server only Diffie Hellman parameters NO
server.crt server only Server Certificate NO
server.key server only Server Key YES
client1.crt client1 only Client1 Certificate NO
client1.key client1 only Client1 Key YES
client2.crt client2 only Client2 Certificate NO
client2.key client2 only Client2 Key YES

アカウント追加したときは、クライアントに.keyファイルと.crtファイル、ca.crt, ta.keyファイルを置く必要がある。
それと、設定ファイルとしてconfig.ovpnが必要。

apacheとsubversionの連携

■やること
・subversionのインストール
・リポジトリ作成
・mod_dav_svn.soのインストール
・httpd.confの設定

# yum install subversion
# svnadmin create /var/svn/repos
# chown -R apache:apache /var/svn/repos

これでsubversion側の準備は完了。
続いてapache側

# yum install mod_dav_svn

で、httpd.conf に以下の設定を追加

LoadModule dav_svn_module       modules/mod_dav_svn.so
<Location /svn>
 DAV svn
 SVNPath /var/svn/repos
</Location>

これでapacheの再起動をして、http://hostname/svn
とかでリポジトリが参照できればおしまい。

2011年5月30日月曜日

memcachedのmake testでエラー

前回とは違う環境下でmemcachedをrpmbuildしてたんだけど、以下のエラーが。
プロジェクトサイトにもIssueとして報告があがってて、 どうやらシングルコアのcpuだとbinary.tのテストに失敗するっぽい。
マルチコア環境だとエラーは出ないので、原因はCPUのコア数みたい・・・。勘弁してよって感じ。
#   Failed test 'Expected read length'
#   in t/binary.t at line 539.
#          got: '10'
#     expected: '24'
Use of uninitialized value in multiplication (*) at t/binary.t line 545.
Use of uninitialized value in addition (+) at t/binary.t line 545.
Use of uninitialized value in numeric eq (==) at t/binary.t line 547.
t/binary.............NOK 243
#   Failed test 'Expected read length'
#   in t/binary.t at line 539.
#          got: '14'
#     expected: '24'
t/binary.............NOK 244
#   Failed test 'Got proper response magic'
#   in t/binary.t at line 543.
#          got: '0'
#     expected: '129'
Use of uninitialized value in multiplication (*) at t/binary.t line 545.
Use of uninitialized value in addition (+) at t/binary.t line 545.
t/binary.............NOK 251
#   Failed test 'Flags is set properly'
#   in t/binary.t at line 63.
#          got: undef
#     expected: '19'
Argument "somevalue" isn't numeric in numeric eq (==) at t/binary.t line 64.
Argument "" isn't numeric in numeric eq (==) at t/binary.t line 64.
t/binary.............NOK 255
#   Failed test 'Expected opaque'
#   in t/binary.t at line 560.
#          got: '38518301'
#     expected: '3628040576'
t/binary.............NOK 258
#   Failed test 'Didn't get a result from get'
#   in t/binary.t at line 76.
#          got: '3'
#     expected: '0'
Can't call method "not_found" without a package or object reference at t/binary.t line 77.
# Looks like you planned 3361 tests but only ran 258.
# Looks like you failed 6 tests of 258 run.
# Looks like your test died just after 258.
t/binary.............dubious
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 240, 243-244, 251, 255, 258-3361
        Failed 3109/3361 tests, 7.50% okay

linuxのstatic routeの設定

linuxのスタティックルートの設定は以下のファイルにする。

/etc/sysconfig/network-script/route-ethX(Xはデバイスの数字)

構文は以下の通り

172.24.0.0/24 via 172.24.0.254
"linux static route"とかで調べると、/etc/sysconfig/static-routes に設定とかって書いてあるサイトもあるけど、古い情報なので気を付けて。

ちなみに、OSがどっちに対応してるかわからない場合は、
/etc/sysconfig/network-script/ifup-routes
を見るといいことがあるかも。

2011年5月25日水曜日

1台のサーバにapacheを複数動かすメモ

$ ./configure --prefix=/usr/local/apacheSub/
$ make
$ make install
とかすると、とりあえず準備は整う。
んで、起動は
$ /usr/local/apacheSub/bin/httpd -f /usr/local/apacheSub/conf/httpd.conf
ちなみに、既に80番で他のapacheが起動してる場合は、confのListenPortを8000とかに変えないと動かない。

phpでPHP Warning: PHP Startup: Unable to load dynamic library

webサーバを引き継いだんだけど、phpがどうも調子悪い。変なエラーでるし。

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mbstring.so' - /usr/lib64/php/modules/mbstring.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysql.so' - /usr/lib64/php/modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysqli.so' - /usr/lib64/php/modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo.so' - /usr/lib64/php/modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_mysql.so' - /usr/lib64/php/modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
 みたいな。なんだかなあ、と思っていたら、/etc/php.d の中にextensionの設定がどっさり入っていた。全部削ってかいけつー。

2011年5月24日火曜日

memcachedのrpmbuildでcan't run as root without the -u switch

memcachedを検証する必要があったので、1.4.5を拾ってきて試しにrpmbuildしてみたんだけど、以下のエラーが出てテストが通らない。。。

t/issue_67...........can't run as root without the -u switch
Failed to start server. at t/issue_67.t line 59
        main::run_server('-p 11212') called at t/issue_67.t line 65
        main::when('specifying tcp port', '-p 11212', 11212, 11212) called at t/issue_67.t line 74
# Looks like your test died before it could output anything.
 仕方ないのでマニュアルっぽいものを読み直すと、Do not run this as rootの文字が。

rootじゃrpmbuildできないんですね。あと実行もできないみたい。

というわけで、memcachedユーザーを作って以下の手順でrpmbuild。めでたし。


echo "%_topdir /home/memcached/rpmbuild" >> ~/.rpmmacros
mkdir -p /home/memcached/rpmbuild/{SPECS,BUILD,SRPMS,RPMS,SOURCES}
wget http://memcached.org/latest
rpmbuild -ta memcached-1.4.5.tar.gz

2011年5月18日水曜日

terastationのレプリケーションでI33ReplicateFailure

terastationの検証。

フェイルオーバー機能は残念ながら使いものになる感じじゃなかったので、レプリケーション機能を使って冗長性を確保することに。

でもレプリケーションがどうもうまく機能しない。

May 18 10:10:51 TS-QVHL702 errormon[2265]: Information situation detected! Replication  I33ReplicateFailure
May 18 10:10:58 TS-QVHL702 linkstation: Replication error occured.
こんな感じ。

結局全然わからなくて、サポートに問い合わせたところ、フェイルオーバー機能を構成した場合は、たとえ構成解除してもレプリケーションがエラーになるとのこと。
システムの初期化をしてやっと使えるようになりました。

2011年5月12日木曜日

tomcatのクラスタリングのはなし

tomcat のクラスタリングについての自分メモ。

・ロードバランス
・フェイルオーバー
・ファーミング

の機能がある。ファーミングってよく知らないけど、農場ってこと?
牧畜かな?まあそれはよくて、1個デプロイすると他のサーバーにもデプロイしてくれる機能らしい。

で、そのうちのロードバランスを実現する方法として3つくらいあって、

・JKコネクタ
・mod_proxyとかmod_rewrite
・balancerアプリケーション

JKコネクタっていうのは、webサーバとtomcat間、つまりロードバランサとAPサーバ間をHTTPじゃなくて、AJPというプロトコルで通信させるものらしい。
Apacheだとmod_jkとか使う。

mod_proxyとかはまあ普通にApacheでロードバランスするよ、という感じのもの。

で、balancerはtomcat単体でロードバランシングしてくれるものっぽい。よくわからんけど。

まあロードバランシングはtomcatじゃなくてLBにまかせる話なのでおいておいて、フェイルオーバー機能のメモをのこすよ。

フェイルオーバー機能には、セッションレプリケーションが不可欠というか、イコールなので、そのあたりの設定をすればよいみたい。で、レプリケーション機能なんだけど


・PersistenceManager
・JDBCManager
・catalina-cluster.jar
 
の3つがあるみたい。
 
Persistence Managerは、セッションの保存先を共有ファイルにするしくみ。
JDBC Managerは同じくDBに保存するしくみ。
で、catalina-cluster.jarっていうのは、インメモリレプリケーション。tomcat同士が勝手に通信してレプリケーションしてくれるしくみ。
 
次回はこれについてメモ。
---
 参考:tomcatによるクラスタリングの実現

2011年5月11日水曜日

linux版antivirusのlivepudateをがんばる

LinuxでAntivirusを動かしたいという話で、SymantecのAntivirusをいれて動かしたんだけど、Liveupdateがproxy越しでできない・・・

Exception in thread "main" java.lang.NullPointerException
   at jluej.b(DashoA5380)
   at jluce.a(DashoA5380)
   at jluce.a(DashoA5380)
   at jluf7.c(DashoA5380)
   at jluf7.b(DashoA5380)
   at com.symantec.liveupdate.LiveUpdate.computeAvailableUpdates(DashoA5380)
   at com.symantec.liveupdate.LiveUpdate.run(DashoA5380)
   at com.symantec.liveupdate.LiveUpdate.main(DashoA5380)
   at LiveUpdate.main(DashoA5380)
Command failed: Problem with LiveUpdate.
Check that java directory is in PATH
Unable to perform update
いくらがんばってもこんな感じのエラー。
結局、liveupdate.confがあんまりよくなかったみたいで、マニュアルからコピペしたらすんなり動いた。rpmで入れたんだからそのくらい作ってよ。。。

サンプル
# LiveUpdate.conf
AllowConfigurationOverride=true
hosts/0/url=http://liveupdate.symantecliveupdate.com:80
hosts/1/url=http://liveupdate.symantec.com:80
hosts/2/login:ENC=cbea173305fc49908a4663bb377ab28c
hosts/2/mode=passive
hosts/2/password:ENC=ac7cb5f8f847be7efe8ca1084fde41c4
hosts/2/url=ftp://update.symantec.com/opt/content/onramp
jar=/opt/Symantec/LiveUpdate/jlu.jar
logfile=/opt/Symantec/LiveUpdate/liveupdt.log
maxPackageContentSize=734003200
maxPackageSize=734003200
maxTriFileSize=10485760
maxZipFileSize=614400
maximumLogFileSize=512
proxy=192.168.0.1:8080
urls=1
workdir=/tmp

2011年5月6日金曜日

proftpdのrpmbuildでエラー

環境
Cent5.6 64bit 
 
proftpd1.3.3eのrpmbuildがいくらやってもうまくいかない。 
エラーメッセージは以下の通り。
RPM build errors:
    File not found by glob:
/var/tmp/proftpd-1.3.3e-root/usr/lib64/pkgconfig/*.pc
    Installed (but unpackaged) file(s) found:
   /usr/lib/pkgconfig/proftpd.pc
わけわかんねー、と思ってたんだけど、なんか調べたらspecファイルの バグっぽかったので、proftpdのbugzillaで聞いてみた

specファイルのpkgconfigの指定が悪かったみたい。優しい外人が解決してくれました。

2011年5月2日月曜日

tcpdumpの使い方

tcpdumpでパケットキャプチャする時のメモ

だいたいのコマンド
# tcpdump -Xi eth0 host HONTNAME
 15:01:27.673120 IP myhost.60792 > ldaphost.ldap: S 740785676:740785676(0) win 5840 <mss 1460,sackOK,timestamp 1721577951 0,nop,wscale 7>
        0x0000:  4500 003c 4fd3 4000 4006 8c92 ac18 8211  E..<O.@.@.......
        0x0010:  ac18 8414 ed78 0185 2c27 7e0c 0000 0000  .....x..,'~.....
        0x0020:  a002 16d0 a12b 0000 0204 05b4 0402 080a  .....+..........
        0x0030:  669d 31df 0000 0000 0103 0307            f.1.........

16進数は4ビットなので、最初のフィールド4500は
・バージョン番号
・ヘッダ長
・サービスタイプ
になる。
次の003cはパケット長、次の4fd3はIPパケットの識別子。フラグメントすると、同じ識別子が並ぶことになる。次の4000がフラグメント用のフィールド。

次の4006はTTLとプロトコル番号。TTLは64秒、プロトコルはTCP(6)になっている。次の8c92はヘッダのチェックサム。

次の32ビットは送信元IPアドレス。
ac18 8211なので、172.24.130.17を指す。
これで0x0000のフィールドはおしまい。

0x0010の最初は宛先IPアドレス。ac18 8414なので172.24.132.20。ヘッダ長に5が指定されていれば、32ビットx5のヘッダが出てきたので、ここでヘッダはおしまい。実データになる。

実データといっても、TCPなので、次はTCPヘッダがでてくる。
ed78は送信元のポート番号で60792。0185は宛先のポートで、389(LDAP)になる。

次の32bitはTCPのシーケンス番号。2c27 7e0cがシーケンス番号。その次はACK番号。今回はSYNパケットなので、0000 0000になる。これに対するACK応答の時に、シーケンス番号+1が返ってくる。

次の16bitはデータオフセット(TCPデータの開始位置)と、TCPのフラグになっている。a002なので、
10x4byte(32bit)、SYNパケット。

これがSYN/ACKになると、a012とかになる。

2011年4月30日土曜日

db2クライアントの設定

DB2クライアントの設定が結構複雑なのでメモ。

少なくともOracleとかMySQLよりは全然わけがわからんぜ。

  • インストールしたら、まずクライアント用のインスタンスを作る
  • リモートノードをCATALOGする
  • リモートノードを使ったDBをCATALOGする

# /opt/IBM/db2/V8.1/instance/db2icrt -a SERVER -d  -s client -w 64 INSTANCENAME
# . /home/INSTANCENAME/sqllib/db2profile
# db2
db2> CATALOG TCPIP NODE ノード名 REMOTE ホスト名 SERVER サービス名
db2> CATALOG DB データベース名 [AS 別名 ] AT NODE ノード名
db2> connect to DBNAME user USERNAME

みたいなかんじ。めんどくさ。

2011年4月28日木曜日

INFO: task nfsd:4005 blocked for more than 120 seconds.

環境
ESXi4.1
CentOS5.6 64bit
で動かしてるNFSがどうも遅い。
/var/log/messagesには以下のエラーが。


Apr 28 10:32:56 myhost kernel: INFO: task nfsd:4005 blocked for more than 120 seconds.
Apr 28 10:32:56 myhost kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Apr 28 10:32:56 myhost kernel: nfsd          D ffff81003fe247e0     0  4005      1          4006  4004 (L-TLB)
Apr 28 10:32:56 myhost kernel: ffff81003acc5c00 0000000000000046 ffff81003acc5c10 ffffffff80062ff0
Apr 28 10:32:56 myhost kernel: ffff81003acc5b90 000000000000000a ffff81003de9b0c0 ffff81003fe247e0
Apr 28 10:32:56 myhost kernel: 000036f3fb0bf9d4 00000000000005d0 ffff81003de9b2a8 000000000004a0d1
Apr 28 10:32:56 myhost kernel: Call Trace:
Apr 28 10:32:56 myhost kernel: [<ffffffff80062ff0>] thread_return+0x62/0xfe
Apr 28 10:32:56 myhost kernel: [<ffffffff88036d8a>] :jbd:log_wait_commit+0xa3/0xf5
Apr 28 10:32:56 myhost kernel: [<ffffffff800a28b4>] autoremove_wake_function+0x0/0x2e
Apr 28 10:32:56 myhost kernel: [<ffffffff8803178a>] :jbd:journal_stop+0x1cf/0x1ff
Apr 28 10:32:56 myhost kernel: [<ffffffff8002fcd8>] __writeback_single_inode+0x1d9/0x318
Apr 28 10:32:56 myhost kernel: [<ffffffff800f5992>] sync_inode+0x24/0x33
Apr 28 10:32:56 myhost kernel: [<ffffffff8804c370>] :ext3:ext3_sync_file+0xcc/0xf8
Apr 28 10:32:56 myhost kernel: [<ffffffff884fc608>] :nfsd:nfsd_sync+0x7a/0xa4
Apr 28 10:32:56 myhost kernel: [<ffffffff884fcf70>] :nfsd:nfsd_commit+0x57/0x7a
Apr 28 10:32:56 myhost kernel: [<ffffffff8850347a>] :nfsd:nfsd3_proc_commit+0xbb/0xc8
Apr 28 10:32:56 myhost kernel: [<ffffffff884f91db>] :nfsd:nfsd_dispatch+0xd8/0x1d6
Apr 28 10:32:56 myhost kernel: [<ffffffff8848a649>] :sunrpc:svc_process+0x44c/0x713
Apr 28 10:32:56 myhost kernel: [<ffffffff80064604>] __down_read+0x12/0x92
Apr 28 10:32:56 myhost kernel: [<ffffffff884f95a1>] :nfsd:nfsd+0x0/0x2cb
Apr 28 10:32:56 myhost kernel: [<ffffffff884f9746>] :nfsd:nfsd+0x1a5/0x2cb
Apr 28 10:32:56 myhost kernel: [<ffffffff8005dfb1>] child_rip+0xa/0x11
Apr 28 10:32:56 myhost kernel: [<ffffffff884f95a1>] :nfsd:nfsd+0x0/0x2cb
Apr 28 10:32:56 myhost kernel: [<ffffffff884f95a1>] :nfsd:nfsd+0x0/0x2cb
Apr 28 10:32:56 myhost kernel: [<ffffffff8005dfa7>] child_rip+0x0/0x11
 Apr 28 10:44:27 myhost kernel: mptscsih: ioc0: attempting task abort! (sc=ffff81003c7e9cc0)
Apr 28 10:44:27 myhost kernel: sd 0:0:1:0:
Apr 28 10:44:27 myhost kernel:        command: Write(10): 2a 00 00 03 84 9f 00 00 08 00
Apr 28 10:44:27 myhost kernel: mptscsih: ioc0: task abort: SUCCESS (sc=ffff81003c7e9cc0)
 
 調べると、死ぬほど長いディスカッションがされてた。
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=516374
http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-01/msg10184.html
2.6系kernelのバグなのかな?

うーん。。。
exportsをasyncにして知らないふりをすることにした。