■CentOS/ScientificLinux6でMyNETSを動かす
ということで、試行錯誤してなんとか動かせたのでメモっておきます。
使ったのはScientificLinux6.7です。
標準ではphp5.3.3、mysql5.1.6ですが、不具合の問題で以下の対応をしました。
・全文検索用にmroongaを使う都合でoracle版mysql5.6導入
・MyNETSで日記投稿時エラーのためphpをius版5.3.29導入
■mroonga&oracle版mysqlインストール
$ yum install -y http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
$vi /etc/yum/yum.repos.d/groonga.repo
以下修正
/centos/$releasever/ → /centos/6/
$ yum install -y http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
$ yum makecache
$ yum install -y mysql-community-server
$ /sbin/service mysqld start
$ yum install -y mysql-community-mroonga
$ yum install -y groonga-tokenizer-mecab
$mysql -uroot
mysql> show engines;
mroongaを確認
# vi /etc/my.cnf
互換性のため以下を追記
character-set-server = utf8
skip-host-cache
skip-name-resolve
sql_mode=”
old_passwords=0
以下の設定はエラーになるので廃止
default-character-set=
table_cache=
log-slow-querie=
log=
■ius版php導入
# vi /etc/yum.repos.d/ius.repo
以下の内容で作成
[ius]
name=IUS Community Packages for Enterprise Linux 6 – $basearch
baseurl=http://dl.iuscommunity.org/pub/ius/archive/CentOS/6/$basearch
#mirrorlist=http://dmirr.iuscommunity.org/mirrorlist?repo=ius-el6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
# cd /etc/pki/rpm-gpg/
# wget http://dl.iuscommunity.org/pub/ius/IUS-COMMUNITY-GPG-KEY
# yum update
# yum install yum-plugin-replace
# yum replace php –replace-with php53u
# vi /etc/php.ini
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
■全文検索用データ修正
mysqlのダンプデータを以下のように書き換え
FULLTEXT KEY `fullindex` (`body`) /*!50100 WITH PARSER `mecab` */
) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;
↓
FULLTEXT INDEX (`body`)
) ENGINE=mroonga AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;
たぶん、これでOK
centos, mynets, mysql, scientific

Loading...
■wordpressの管理ページの一部が開けない対処
wordpressのコンテンツをSL5.9からSL6.5のサーバに移行したら、通常ページは問題なく動作するのに、管理ページの一部のみが表示できない(真っ白になる)問題が発生した。
WP_DEBUGにもmessegaeにもapacheのerror.logにも何もでないのでおかしいなぁと思っていろいろ調べてみると、どうやらphpのcache系でそういう現象が起きることがあるらしい。eAcceleratorを入れていたので.htaccessでキャッシュを無効化したところ適切に表示できるようになった。
やったのは以下。
# vi /var/www/<wordpresspath>/wp-admin/.htaccess
php_flag eaccelerator.enable 0
php_flag eaccelerator.optimizer 0
エラーがうまく出てこない時にはとりあえず試してみるといいかもしれない。
eaccelerator, php, scientific, tips, wordpress

Loading...
■CommuniGateProのIPアドレスブロックの解除
CommuniGate Proで意図しないIPアドレスブロックが発生した場合に、サービスの再起動をしないでIPアドレスブロックを解除する方法。PWDのアクセスがクローズされていないことが条件。「←」がついているところがユーザの入力部分。
1)PWDコマンドでアクセスする
# telnet 127.0.0.1 106 ←
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
2)管理者でログイン
200 CommuniGate Pro PWD Server 5.4.x ready <1.1366768425@localhost.localdomain>
user postmaster ←
300 please send the PASS
pass userpassword ←
200 login OK, proceed
3)現在一時的にブロックされているIPアドレスを表示する(IPアドレスの後ろは残秒数)
GETTEMPBLACKLISTEDIPS ←
200 data follow
"[192.168.1.1]-2669"
4)ブロック解除したいIPアドレスの時間(秒数)を書き換えで対処する
SETTEMPBLACKLISTEDIPS "[192.168.1.1]-10" ←
200 OK
5)秒数が書き換わったことを確認する
GETTEMPBLACKLISTEDIPS ←
200 data follow
"[192.168.1.1]-6"
6)指定時間経過後リストから消えたことが確認できる
GETTEMPBLACKLISTEDIPS ←
200 data follow
""
communigate, tips

Loading...
■Debian v7 でCommuniGateProのdebパッケージを調べる
CommuniGate Proのdebパッケージが非公式ながら作成されていたので、どんな構成になっているのか調べてみたメモ。ちなみにCommuniGate ProとしてはLinuxではrpmでパッケージされたものが公式ということらしい。
■パッケージ情報を取得
# dpkg-deb --info cgatepro-linux_6.0-5a_i386.deb
新形式 debian パッケージ、バージョン 2.0。
サイズ 51972190 バイト: コントロールアーカイブ = 709 バイト。
24 バイト、 1 行 conffiles
293 バイト、 9 行 control
511 バイト、 22 行 * postinst #!/bin/sh
77 バイト、 5 行 * postrm #!/bin/sh
156 バイト、 7 行 * prerm #!/bin/sh
Package:cgatepro-linux
Version: 6.0-5a
Priority: optional
Architecture: i386
Depends:
Section: non-free/comm
Maintainer: CommuniGate Systems <support@communigate.com>
Description: THE Integrated Communication Server.
SIP, XMPP, ESMTP, POP3, IMAP4, MAPI, List, Web Email, poppwd, LDAP, ACAP.
■パッケージ内のdata部分を表示
# dpkg-deb -c cgatepro-linux_6.0-5a_i386.deb
drwxr-xr-x root/root 0 2013-04-05 21:54 ./
drwxr-xr-x root/root 0 2013-04-05 21:54 ./etc/
drwxr-xr-x root/root 0 2013-04-05 21:54 ./etc/init.d/
-rwxr-xr-x root/root 2806 2013-04-05 21:54 ./etc/init.d/CommuniGate
drwxr-xr-x root/root 0 2013-04-05 21:54 ./usr/
drwxr-xr-x root/root 0 2013-04-05 21:54 ./usr/share/
drwxr-xr-x root/root 0 2013-04-05 21:54 ./usr/share/doc/
drwxr-xr-x root/root 0 2013-04-05 21:54 ./usr/share/doc/cgatepro-linux/
-rw-r--r-- root/root 2738 2013-04-05 21:54 ./usr/share/doc/cgatepro-linux/copyright
drwxr-xr-x root/root 0 2013-04-05 21:54 ./opt/
drwxr-xr-x root/root 0 2013-04-05 21:54 ./opt/CommuniGate/
...以下略
■パッケージのコントロール情報を展開して中身を確認する
# dpkg-deb -e cgatepro-linux_6.0-5a_i386.deb
# cd DEBIAN (DEBIANというディレクトリが生成される)
# ls -al
合計 28
drwxr-xr-x 2 root root 4096 4月 5 21:54 .
drwx------ 5 root root 4096 5月 22 14:12 ..
-rw-r--r-- 1 root root 24 4月 5 21:54 conffiles
-rw-r--r-- 1 root root 293 4月 5 21:54 control
-rwxr-xr-x 1 root root 511 4月 5 21:54 postinst
-rwxr-xr-x 1 root root 77 4月 5 21:54 postrm
-rwxr-xr-x 1 root root 156 4月 5 21:54 prerm
# less でそれぞれ確認
■パッケージ内のdata部分を展開して確認する
# mkdir test
# dpkg-deb --extract cgatepro-linux_6.0-5a_i386.deb test
# cd test
# ls -al (などして確認)
communigate, debian

Loading...
■Debian v7 に sipp v3.3 を導入したメモ
Debianにはsippがsip-testerとして用意されているが、aptで導入できるバージョンがv3.2なので、v3.3を導入したメモ。
■依存性解決のためv3.2を先に導入しておく
# apt-get install sip-tester
# sipp -v
3.2-PCAP
■v3.3を導入する(RTP再生できるようにpcapplayオプション付きでmake)
# wget http://downloads.sourceforge.net/project/sipp/sipp/3.3/sipp-3.3.tar.gz
# tar zxvf sipp-3.3.tar.gz
# cd sipp-3.3
# apt-get install automake gcc g++ libpcap-dev libncurses5-dev libncursesw5-dev
# make pcapplay
# ./sipp -v
3.3-PCAP
debian, sip, sipp

Loading...
■Debian環境でネットワークI/Fを追加するメモ
VirtualBoxで後からホストオンリーネットワークI/Fを固定IPで追加した時のメモ。重要なのはauto行を正しく追加すること。
# vi /etc/network/interfaces
ーー
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0 eth1
allow-hotplug eth0
iface eth0 inet dhcp
iface eth1 inet static
address 192.168.56.xxx
netmask 255.255.255.0
debian, tips

Loading...
■Debian v6 squeezeからv7 wheezyへのアップグレード
Debian v6(6.0.7)からDebian v7へのアップグレードしたメモ。アップグレード手順はほぼDebianのドキュメント通り。(バックアップ等の手順は今回無視)
■環境の最新化
# apt-get update
# apt-get upgrade
■アップグレード準備
# vi /etc/apt/sources.list
squeeze を全て wheezy に置き換え
■アップグレードする
# apt-get update
# apt-get dist-upgrade
※注意
マシン再起動後はPAE必須のKernel3.2ベースで起動するので、CPUはPAE対応であることを必ず確認しておくこと。
PAE無しかkernel2.6系を引き続き使用する場合には
# vi /boot/grub/grub.cfg
を編集。
debian, tips, update

Loading...
■Debian wheezy にCommuniGateProをインストールしたメモ
Debian v7 wheezyでのCGPのインストール方法をチェック。6.xも手順は同様。rpmでもdeb化でも以下の手順で5.4.xが適切に動作することを確認。
■パッケージの入手
# wget http://www.communigate.com/pub/CGatePro/5.4/CGatePro-Linux_5.4-10.i386.rpm
■rpmでインストール場合
# apt-get install rpm
# rpm -ivh –nodeps CGatePro-Linux_5.4-10.i386.rpm
起動scriptを修正
# vi /etc/init.d/CommuniGate
・ulimit -u から始まる1行を削除する
・touch /var/lock/subsys/CommuniGate
↓
mkdir /var/lock/subsys
touch /var/lock/subsys/CommuniGate
起動
# /etc/init.d/CommuniGate start
停止
# /etc/init.d/CommuniGate stop
アンインストール
# rpm -e –nodeps CGAtePro-Linux
■debでインストールする場合(alienで変換する)
# apt-get install alien
# alien -d –scripts CGatePro-Linux_5.4-10.i386.rpm
# dpkg -i cgatepro-linux_5.4-11_i386.deb
起動scriptを修正
# vi /etc/init.d/CommuniGate
・ulimit -u から始まる1行を削除する
・touch /var/lock/subsys/CommuniGate
↓
mkdir /var/lock/subsys
touch /var/lock/subsys/CommuniGate
起動
# /etc/init.d/CommuniGate start
停止
# /etc/init.d/CommuniGate stop
アンインストール
# dpkg -r cgatepro-linux
communigate, debian

Loading...
■侵入改竄検知システム AIDE を使うメモ
長くIDSとしてOsirisを使ってきたが時勢に合わなくなってしまったので、CentOS/ScientificLinuxに標準装備されているAIDEを使ってみたメモ。
■インストールと簡単な使い方
# yum install aide
設定編集(コメント充実)
# vi /etc/aide.conf
R = p+l+i+n+u+g+s+m+acl+selinux+xattrs+md5
初期化
# aide -i
比較用DB作成
# cp /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
比較
# aide -C
通常用途
# aide -u
■CentOS5系でselinuxで問題が出るケースの設定変更例
# vi /etc/aide.conf
R = p+l+i+n+u+g+s+m+acl+xattrs+md5
L = p+l+i+n+u+g+acl+xattrs
> = p+l+u+g+i+n+S+acl+xattrs
DIR = p+l+i+n+u+g+acl+xattrs
PERMS = p+l+i+u+g+acl
DATAONLY = p+l+n+u+g+s+acl+xattrs+md5+sha256+rmd160+tiger
■Prelink関連のエラーが出る場合の設定変更例
# sed -i '/^PRELINKING=yes$/s/yes/no/' /etc/sysconfig/prelink
# /usr/sbin/prelink -ua
■cron用script例
# vi /root/script/aide.sh
#!/bin/bash
/usr/sbin/aide -u
/bin/cp -fr /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
■MyNETS用改竄検知設定例(/var/www/sns/wwwをSNS rootとする)
# vi /etc/aide.conf
# MyNETS SNS DIR
/var/www/sns/www NORMAL
!/var/www/sns/www/img
!/var/www/sns/www/var
■参考リンク
http://pooh.gr.jp/?p=9633
http://blog.cecily.jp/kotou/51/
http://aikotobaha.blogspot.jp/2011/11/rhel-aide.html
aide, centos, ids, scientific, sns

Loading...
■CentOS6/ScientificLinux6にmroongaを導入する
CentOS6/ScientificLinux6にはmysql5.1.xが導入されていて、日本語全文検索にtritonnが利用できないので、後継プロジェクトになっているmroongaを導入し、日本語全文検索を可能にする。実際の手順はほぼmroongaの公式HPの通り。
mroonga
http://mroonga.github.io/ja/
■インストール(mysqlは導入済み)
# rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
※ScientificLinux6は以下のbaseurl修正を行う
# vi /etc/yum.repos.d/groonga.repo
baseurl=http://packages.groonga.org/centos/6/$basearch/
# yum makecache
# yum install -y mysql-mroonga groonga-tokenizer-mecab
# mysql -u root -p
mysql> show engines;
mysql> INSTALL PLUGIN mroonga SONAME 'ha_mroonga.so';
■動作確認方法
# mysql -u root -p
mysql> show engines;
mysql> use test;
mysql> create table diaries ( id INT primary key auto_increment, content varchar(255), fulltext index (content) ) engine = mroonga default charset utf8;
mysql> INSERT INTO diaries (content) VALUES ("明日の天気は晴れでしょう。");
mysql> INSERT INTO diaries (content) VALUES ("明日の天気は雨でしょう。");
mysql> SELECT * FROM diaries WHERE MATCH(content) AGAINST("晴れ");
検索できればOK。
検索スコアでソートは以下で確認。
mysql> INSERT INTO diaries (content) VALUES ("今日は晴れました。明日も晴れるでしょう。");
mysql> INSERT INTO diaries (content) VALUES ("今日は晴れましたが、明日は雨でしょう。");
mysql> SELECT *, MATCH (content) AGAINST ("晴れ") FROM diaries WHERE MATCH (content) AGAINST ("晴れ") ORDER BY MATCH (content) AGAINST ("晴れ") DESC;
■tritonnデータからの移行
tritonnでダンプしたデータのうち以下の部分を修正する(ストレージモードで利用)
FULLTEXT KEY `fullindex` (`body`) /*!50100 WITH PARSER `mecab` */
) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;
↓
FULLTEXT INDEX (`body`)
) ENGINE=mroonga AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;
これで新しいDBへインポートすればOK。
centos, mroonga, mysql, scientific, tritonn

Loading...