- 2010/09/03 CentOS
CentOS内のユーザ一覧を確認する方法です。
良く忘れるのでメモ。
/etc/passwdにあります。
[root@localhost ~]# cat /etc/passwd
cakephp/wordpress/flash/flex/iPhone/mixiアプリの開発しています。
CentOS内のユーザ一覧を確認する方法です。
良く忘れるのでメモ。
/etc/passwdにあります。
[root@localhost ~]# cat /etc/passwd
WEBサーバーのOSを再インストールした際にMacのSSHクライアントから接続できなくなってしまいました。
クライアントにはiTermとJellySSHを使用しています。
SSHのアクセス制限にイーモバイルからのアクセスを許可する方法のメモ。
とあるサーバーのメンテの際にSSH接続する必要があったのですが、イーモバイルは接続するたびにIPアドレスが変更されるためイーモバイルは全て許可するように設定しました。
Tripwireをインストールする際にエラーが、、、
configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details.
viのチートシートがダウンロードできる「VI Editor / Linux Terminal Cheat Sheet (PDF)」というエントリーをご紹介。

オープンソースの現在の状況やマーケットをまとめたOpen Source Open Worldというエントリーのご紹介。
オープンソースの歴史やLinuxの世界の使用状況などをまとめたシートになっています。
英語ですが、興味のある方はぜひ。

「Sypex Dumper」はMySQLデータベースを自動的にバックアップしてくれるオープンソースのウェブアプリケーションです。
PHPとAjaxで作成されており、Webインターフェースを使ってMySQLのバックアップを作成する事ができます。
自動バックアップにはタスク・スケジューラかcronの設定が必要ですが、それ以外はWEB上から設定可能になっています。
ファイル圧縮(GzipとBzip2)のサポートをしており、多言語インタフェースあり。ただし日本語はないみたいです。
ダウンロードページへアクセスします。

ポチッとダウンロードします。

設置は簡単でファイルをサーバーにアップするだけです。
早速自動バックアップを設定してみます。まずは設置したURLにアクセスします。

バックアップしたいユーザーでログインします。今回はローカルでのテストなのでrootユーザーでログインしました。

バックアップしたいデータベースとテーブルを指定を選択します。

自動バックアップのJobに名前をつけてあげます。ここでつけた名前を後で使うので忘れないようにしましょう。
今回は「my_job」という名前にしました。
あとはconsoleやcronで指定のコマンドを実行するだけです。
コマンドはこんな感じです。
php Sypex Dumperへのパス/index.php -j=ジョブ名
最後のジョブ名は先ほど入力した値(ここではmy_job)を指定します。
実行するとこんな感じで表示されます。
C:\>php c:\xampp\htdocs\SypexDumper\index.php -j=my_job 2010.02.15 21:29:12 1 Start export DB `wordpress` 2010.02.15 21:29:12 1 Export table `wp_cimy_uef_data` 2010.02.15 21:29:12 1 Export table `wp_cimy_uef_fields` 2010.02.15 21:29:12 1 Export table `wp_cimy_uef_wp_fields` 2010.02.15 21:29:12 1 Export table `wp_commentmeta` 2010.02.15 21:29:12 1 Export table `wp_comments` 2010.02.15 21:29:12 1 Export table `wp_links` … …
実行後にSypex Dumperの下の「backup」フォルダを見てみます。

圧縮ファイルになったデータが保存されています。これでバックアップは完了です。
結構簡単にできましたね。

もちろん、ブラウザ上からバックアップする事も可能です。
便利ですねー。早速自分のサイトにも設定してみました!
サーバーの定期バックアップをやられている方は、使ってみてもよいかもしれません。

yum-fastestmirrorはCentOSでyumを実行する際に接続が速いミラーサーバに接続してくれるパッケージです。
FedoraとCentOSで使用可能です。
CentOS4の場合、プラグインを有効にする設定が必要になります。
# vi /etc/yum.conf
プラグンを有効にする1文を追加します。
plugins=1
CentOS5 の場合
# yum -y install yum-fastestmirror
CentOS4 の場合
yum -y install yum-plugin-fastestmirror
これだけでインストール作業は完了です。
yum-fastestmirrorが実際に動作しているかどうかはcheck-updateコマンドで確認する事が可能です。
# yum check-update Loading "fastestmirror" plugin Setting up repositories Determining fastest mirrors
通常は上記設定だけで高速化されるはずですが、何度かyumを実行しているとキャッシュファイルがたまり、以前ははやかったけど今は遅いミラーを使用してしまう場合があります。
そんな時はキャッシュファイルを削除してあげましょう。まずはキャッシュファイルの場所を調べます。
cat /etc/yum/pluginconf.d/fastestmirror.conf … hostfilepath=/var/cache/yum/timedhosts.txt
hostfilepathにキャッシュファイルが格納されています。
こちらをリネームしてあげれば新しくミラーを探しにいってくれます。
# mv /var/cache/yum/timedhosts.txt /var/cache/yum/timedhosts.txt.bak
以下のサイトを参考にさせていただきました。感謝!
[Linux]# yum -y install yum-fastestmirrorでyum高速化 : うえちょこ@ぼろぐ

APCはPHPの中間コードのキャッシュや最適化を行う拡張モジュールです。基本的にPHPを使うサーバーに全て入れてよいようです。
本日とあるサーバーにインストールしたのでやり方をメモ。
まずは環境ですが、CentOS 4.4 + PHP 5.1.6 です。
まず、peclが入っているかどうか調べます。
# pecl list-all apc All packages: ============= Package Latest Local pecl/KTaglib 0.2.0 Library to edit audio properties and tags on MPEG and OGG files pecl/FliteTTS Text to speech voice synthesis for PHP pecl/Ovrimos Ovrimos interface pecl/DTrace 1.0.3 A Solaris Dtrace provider pecl/inclued 0.1.0 Clued-in about your inclueds pecl/zookeeper 0.1.0 PHP extension for interfacing with Apache ZooKeeper … … … …
インストールされているパッケージが表示されれば、このSTEPは読み飛ばしてOKです。
なければインストールます。
# yum install -y php-pear Setting up Install Process Setting up repositories update 100% |=========================| 951 B 00:00 base 100% |=========================| 1.1 kB 00:00 … … …
phpizeもインストールします。
# yum install -y php-devel
apxsも無ければインストール
# yum install -y httpd-devel
これでやっとpeclがインストールできます。
peclコマンドでインストールできます。
# pecl install APC
無事にインストールが完了すると以下のようなメッセージがでます。
Build process completed successfully Installing '/var/tmp/pear-build-root/install-APC-3.0.19//usr/lib/php/modules/apc.so' install ok: channel://pecl.php.net/APC-3.0.19 You should add "extension=apc.so" to php.ini
ふむふむ。php.iniに追加しろって事ですね。
って事でphp.iniに以下の行を追加。場所はどこでもかまいません。
extension=apc.so
iniファイルを編集したらapacheを再起動します。
これでとりあえず作業は完了です。
phpinfoの画面でapcの項目があるか確認します。

apcのアップグレードは以下のコマンドで。
# pecl upgrade apc
ApacheBenchでどのくらい効果が変わったか測定します。
1000件のリクエストを100の同時接続で計測した結果です。
# ab -n 1000 -c 100 http://127.0.0.1/*****/test.php
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.0.63
Server Hostname: 127.0.0.1
Document Path: /*****/test.php
Document Length: 1257 bytes
Concurrency Level: 100
Time taken for tests: 13.193656 seconds
Complete requests: 1000
Failed requests: 557
(Connect: 0, Length: 557, Exceptions: 0)
Write errors: 0
Total transferred: 1897728 bytes
HTML transferred: 1504335 bytes
Requests per second: 75.79 [#/sec] (mean)
Time per request: 1319.366 [ms] (mean)
Time per request: 13.194 [ms] (mean, across all concurrent requests)
Transfer rate: 140.45 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 5 17.9 0 80
Processing: 74 923 879.0 498 5931
Waiting: 56 919 880.2 497 5930
Total: 102 929 877.3 502 5931
Percentage of the requests served within a certain time (ms)
50% 502
66% 974
75% 1209
80% 1371
90% 2181
95% 2667
98% 3048
99% 4531
100% 5931 (longest request)
トータルで13秒でした。
ふーむ。早くなってるんですかね。念のためapcを無効にして再度ベンチを図ってみました。
# ab -n 1000 -c 100 http://127.0.0.1/*****/test.php
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.0.63
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /*****/test.php
Document Length: 1257 bytes
Concurrency Level: 100
Time taken for tests: 32.801446 seconds
Complete requests: 1000
Failed requests: 3
(Connect: 0, Length: 3, Exceptions: 0)
Write errors: 0
Total transferred: 1651341 bytes
HTML transferred: 1258341 bytes
Requests per second: 30.49 [#/sec] (mean)
Time per request: 3280.145 [ms] (mean)
Time per request: 32.801 [ms] (mean, across all concurrent requests)
Transfer rate: 49.14 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 62 171.8 0 599
Processing: 288 2895 1431.8 2741 22702
Waiting: 8 2886 1441.0 2740 22701
Total: 616 2958 1410.4 2760 23294
Percentage of the requests served within a certain time (ms)
50% 2760
66% 2896
75% 2959
80% 2987
90% 3437
95% 4084
98% 6956
99% 9495
100% 23294 (longest request)
トータルで32秒でした。おお!19秒も違いますね。
まさか、倍以上違うとは、、、
まだ入れてない方はぜひ。
ちなみに高速化モジュールは他にも以下のようなものがあります。
今回はyumから入れたいという理由でAPCを採用しました。
導入にあたっては以下の記事を参考にさせていただきました。ありがとうございます。
APC(Alternative PHP Cache)再び – Do You PHP?
PHP(というかWordPress)高速化のためにAPC(Alternatice PHP Cache)入れた – IDEA*IDEA ~ 百式管理人のライフハックブログ
以下のコマンドで調べる事が出来ました。
# cat /etc/redhat-release
CentOS release 5 (Final)とか表示されます。
いっつも忘れるのでメモメモ。
0