Tuesday, April 28, 2009

pgpool-II install and setting(インストールと設定)

pgpool-II 2.0.1のインストール in PostgreSQL 8.3.5

PostgreSQL

# : rootユーザ

$ : postgresユーザ


■pgpool-IIのDL / 展開、postgresユーザへの権限付与

DL先 : /usr/local/src/

展開先 : /usr/local/src/pgpool-II-2.0.1/

インスト先 : /usr/local/pgpool2/

# mkdir /usr/local/pgpool2

# chown postgres.postgres -R /usr/local/pgpool2/

# cd /usr/local/src/

# wget http://pgfoundry.org/frs/download.php/1521/pgpool-II-2.0.1.tar.gz

# tar -zxvf pgpool-II-2.0.1.tar.gz

# chown postgres.postgres -R /usr/local/src/pgpool-II-2.0.1/


■pgpool-IIのインストール(実行ユーザ:postgres)

# su - postgres

$ cd /usr/local/src/pgpool-II-2.0.1/

$ ./configure --prefix=/usr/local/pgpool2

$ make

$ make install



参考

* FrontPage - pgpool Wiki(pgpool-II/tutorial - pgpool Wiki)

Permalink | コメント(0) | トラックバック(0) | 15:32 このエントリーを含むブックマーク
レプリケーション in pgpool-II 2.0.1 / PostgreSQL 8.2.5 / CentOs5CommentsAdd StarCommentsAdd StarCommentsAdd Star

PostgreSQL

# : rootユーザ

$ : postgresユーザ


■ネットワークの設定

# vi /etc/hosts

-> 192.168.xxx.xx1 ecshopping-guide1.localdomain ecshopping-guide1

-> 192.168.xxx.xx2 ecshopping-guide2.localdomain ecshopping-guide2

※TAB区切り

hostname:ecshopping-guide1の場合

# vi /etc/sysconfig/network

-> #NETWORKING_IPV6=yes

-> HOSTNAME=ecshopping-guide1.localdomain


■PostgreSQLの設定

$ vi /usr/local/pgsql/data/postgresql.conf

-> listen_addresses = '*'

-> port = 5432        # default

$ vi /usr/local/pgsql/data/pg_hba.conf

-> local all all trust

-> host all postgres 192.168.xxx.0/24 trust

※半角スペース区切り

■pgpool-IIの設定

$ cp -p /usr/local/pgpool2/etc/pgpool.conf.sample /usr/local/pgpool2/etc/pgpool.conf

$ vi /usr/local/pgpool2/etc/pgpool.conf

-> listen_addresses = '*'

-> port = 9999       # default

-> replication_mode = true

-> load_balance_mode = true

-> enable_pool_hba = false # default

-> # データベースノードの設定(hostname:ecshopping-guide1)

-> backend_hostname0 = 'ecshopping-guide1'

-> backend_port0 = 5432

-> backend_weight0 = 1

-> # データベースノードの設定(hostname:ecshopping-guide1)

-> backend_hostname1 = 'ecshopping-guide1'

-> backend_port1 = 5432

-> backend_weight1 = 1


■レプリケーションの確認(pgbenchを使用)

$ cd /usr/local/src/postgresql-8.2.5/contrib/pgbench

$ make

$ make install

$ /usr/local/pgpool2/bin/pgpool -n &

$ /usr/local/pgsql/bin/createdb -p 9999 bench_replication

$ /usr/local/pgsql/bin/pgbench -i -p 9999 bench_replication


データベースノードに設定したサーバのPostgreSQLを確認。

List of databases
Name | Owner | Encoding
-------------------+----------+----------
bench_replication | postgres | UTF8       <- が、各PostgreSQLに追加されているはず



多分、いまは構成はこんなかんじ。

 ┌─────┐ ┌─────┐  ┌───────────┐
 │client  ├─┤pgpool-II ├─┬┤PostgreSQL(ecshopping-guide1:5432)│
 └─────┘ └─────┘ │└───────────┘
                 │┌───────────┐
                 └┤PostgreSQL(ecshopping-guide2:5432)│
                  └───────────┘



# 最初、レプリケーションされなかったのはPostgreSQLにユーザ作成していなかったから…。

http://www.ecshopping-guide.com

ludia 1.5.1 and senna (search fulltext) install and configure for postgresql(ludia とsenna インストールと設定)

LudiaはSennaを使ったPostgresSQL用の組み込み型全文検索インデックスエンジンです。
ダウンロード

下記サイトからダウンロード。

http://sourceforge.jp/projects/ludia/

Mecab、MeCab辞書、Sennaが含まれているludia-withdepsのパッケージをDLします。
インストール
解凍

$tar -zxvf ludia-withdeps-1.5.1.tar.gz
$cd ludia-1.51/deps

MeCabのインストール

分かち書き方式に形態素解析を利用しない場合は、 MeCab(と辞書)をインストールする必要はありません。その場合はSennaのインストールに進んでください。 (MeCabをインストールしない場合はSennaのインストールの際に、 --without-mecabオプションを指定する必要あり)

MeCabをインストールする場合は、アーカイブを展開し、以下の要領でビルドとインストールを行います。:

$ tar -zxvf mecab-0.97.tar.gz
$ cd mecab-0.97
$ ./configure --with-charset=utf8
$ make
$ su
# make install

MeCab辞書のインストール

アーカイブを展開し、以下の要領でビルドとインストールを行います。:

$ tar -zxvf mecab-ipadic-2.7.0-20070801.tar.gz
$ cd mecab-ipadic-2.7.0-20070801
$ ./configure --with-charset=utf8
$ make
$ su
# make install

Sennaのインストール

アーカイブを展開し、以下の要領でビルドとインストールを行います。:

$ tar -zxvf senna-1.13.tar.gz
$ cd senna-1.13
$ ./configure
$ make
$ su
# make install

MeCabをインストールしていない場合には、以下のように --without-mecab オプションの指定が必要

$ ./configure --without-mecab

Ludiaのインストール

アーカイブを展開し、以下の要領でビルドとインストールを行います。:

$ ./../../
$ ./configure
$ make
$ su
# make install

pg_configコマンド、senna-cfgコマンドのインストール先にPATHが設定されていない場合、以下のようにそれぞれのpathをconfigureオプションで指定してください。:

$ ./configure --with-pg-config=/usr/local/pgsql/bin/pg_config --with-senna-cfg=/usr/local/bin/senna-cfg

インデックスアクセスメソッドの登録

$ psql -f /usr/share/pgsql/pgsenna2.sql testdb -u

postgreSQLの設定ファイル編集

postgresql.confに下記の設定を追加

custom_variable_classes = 'ludia'
ludia.max_n_sort_result = 10000
ludia.enable_seqscan = on
ludia.seqscan_flags = 1
ludia.sen_index_flags = 31
ludia.max_n_index_cache = 16
ludia.initial_n_segments = 512

インデックスの作成

インデックス作成例:

CREATE INDEX student_fulltext_index_name
ON student
USING fulltext(studentname);

検索クエリ

SELECT * FROM student WHERE studentname %% 'もも';

Monday, April 27, 2009

postgresql log setting postgresql ログ 設定

syslogにログをはく

vi /usr/local/pgsql/data/postgresql.conf

log_destination = 'syslog'
log_statement = 'all'

syslogの設定にも追加

vi /etc/syslog.conf

local0.* /var/log/postgresql.log

syslog再起動

/etc/init.d/syslog restart

Saturday, April 25, 2009

perl pdf encode utf8 and shift_jis(japanese font)

#!/usr/bin/perl -w
use strict;
use PDF::API2;
my $pdf = PDF::API2->new;
$pdf = PDF::API2->open('/tmp/old.pdf');
my $page = $pdf->openpage(1);
my $gfx = $page->gfx;
#my $jfs = $pdf->cjkfont( 'KozGo', -encode=>'utf8' );
my $jfs = $pdf->cjkfont( 'KozGo', -encode=>'shiftjis' );
my $text = "T03 2007/1/23 どんなかんじでしょうかね";
$gfx->textlabel(30, 800, $jfs, 20, $text, -color=>'red');
$pdf->saveas("new_file.pdf");

Friday, April 24, 2009

add more package for apache httpd アパッシュは、モジュール追加

add more package for apache httpd アパッシュは、モジュール追加
インストーラされてるモジュールの確認

# /usr/local/apache2/bin/httpd -l

これでモジュールの一覧が見える。ここに mod_so.c が無いともう駄目らしい。
コンパイル

ソースがあるディレクトリを探して移動する。
rewrite module は httpd-2.0.59/modules/mappers にあった。

# /usr/local/apache-2.0/bin/apxs -c mod_rewrite.c

インストール

そしてインストール

# /usr/local/apache-2.0/bin/apxs -ian rewrite mod_rewrite.la

設定を確認して apache をリロード

httpd.conf には勝手に追加されるらしい。

LoadModule rewrite_module modules/mod_rewrite.so

なので後は再ロードする。

# /etc/init.d/httpd reload

Thursday, April 23, 2009

perl pdf table and image

#!usr/bin/perl -w
use PDF::API2;
use PDF::Table;

# PDFつくる
my $pdf = PDF::API2->new;
my $pdftable = new PDF::Table;


# ページつくる
my $page = $pdf->page(0); # 0 は最後に追加

#ページのサイズ決める
$page->mediabox( 'A4');
#ピクセルでサイズ指定
#$page->mediabox( 512, 512 );
# mm で指定。PDF::API2 は 72dpiらしいので
#$page->mediabox( 210 / 25.4 * 72 , 297 / 25.4 * 72 );

# 画像を入れる
my $image = $pdf->image_jpeg('bill.jpg');
my $gfx = $page->gfx;
# 左下スミが原点
my $xpos = 100 ; my $ypos = 500;
my $image_resolution = 350 ;
my $scale = 400 / $image_resolution ;
$gfx->image( $image, $xpos, $ypos, $scale );

my $some_data =[
["1 Lorem ipsum dolor",
"Donec odio neque, faucibus vel",
"consequat quis, tincidunt vel, felis."],
["Nulla euismod sem eget neque.",
"Donec odio neque",
"Sed eu velit."],
#... and so on
];

$left_edge_of_table = 50;
# build the table layout
$pdftable->table(
# required params
$pdf,
$page,
$some_data,
x => $left_edge_of_table,
w => 495,
start_y => 750,
next_y => 700,
start_h => 300,
next_h => 500,
# some optional params
padding => 5,
padding_right => 10,
background_color_odd => "gray",
background_color_even => "lightblue", #cell background color for even rows
);


# 既存のPDFのページを1ページ追加する
# 既存のPDFを開く
my $mypdf = PDF::API2->open('aaa.pdf');
# 16ページ目を追加する
$pdf->importpage( $mypdf, 16);

# 保存する
$pdf->saveas('ddd.pdf');

Monday, April 20, 2009

LINUXスワッピングを追加(add extra swap)

SWAP space under RHEL/CentOS

Adding a 250 MB swap file to the system

Create an empty 250M file :
dd if=/dev/zero of=/swapfile bs=1024 count=2097152

Create the swap on the newly created file :
mkswap /swapfile

Enable the new swap file :
swapon /swapfile

Edit fstab and add :
/swapfile swap swap defaults 0 0

Verify if the new swap space is enabled :
cat /proc/swaps
free -m


分からないから、質問して下さい。

PHP GD インストールと設定

PHP 公式サイト から PHP のソースファイルをダウンロードしてインストールを行う。
PHP のインストールと実行には flex と libxml2 が必要。
また PostgreSQL や MySQL といったデーターベースサーバーとの連携を有効にするためには PostgreSQL、MySQL が必要。
PHP を使った CMS や BLOG システムでよく利用される GD ライブラリ(画像を動的に生成する機能)を有効にする。
このためには zlib と libpng が必要。
# yum -y install flex libxml2-devel

MySQL との連携を有効にするためには MySQL のインストールが完了している必要がある。
GD ライブラリを有効にするためには zlib と libpng が必要。

yum を使って zlib と libpng をインストールする場合は以下のように実行する。
yum を使って libxml2 をインストールした場合 zlib はすでにインストールされている。
# yum -y install zlib-devel libpng-devel

また GD で JPEG を扱う場合は JPEG 画像ライブラリである libjpeg が必要。
# yum -y install libjpeg-devel

PHP のソースファイルを PHP 公式サイト から/usr/local/srcへダウンロードしてコンパイル、インストールを行う。
但し、そのままPHP5をソースからインストールすると/(Apacheインストールディレクトリ)/modules/----に作成されるべきモジュールである

libphp5.so

が作成されない。これは、バグらしいので、以下バグに対応させたインストール方法を記載する。

<バグ対策済みインストール方法>
# mkdir /usr/local/php-5.2.6
# cd /usr/loca/src
# tar zxf php-5.2.6.tar.gz
# cd php-5.2.6
# ./configure --prefix=/usr/local/php-5.2.6
# make
# make install
# make clean
# make distclean
# ./configure --prefix=/usr/local/php-5.2.6 --enable-mbstring --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-gd --with-zlib --with-jpeg-dir
# make
# make install

<-- configure オプションの解説>
① インストール先のディレクトリを設定。
--prefix=/usr/local/php-5.2.1

② マルチバイト文字を有効(マルチバイト文字列関数である mbstring 関数を有効にする)。
--enable-mbstring

③ Apache の動的モジュールとして組み込む設定。
--with-apxs2=/usr/local/httpd/bin/apxs

④ MySQL データーベース、PostgreSQL データーベースとの連携を有効にする。
--with-pgsql=/usr/local/pgsql
--with-mysql=/usr/local/mysql

⑤ GDライブラリを有効にする。
--with-gd
--with-zlib

⑥ JPEG 画像ライブラリを有効にする。
--with-jpeg-dir

PHP のディレクトリを /usr/local/php としてアクセスできるようにシンボリックリンクを作成。
# ln -sfn /usr/local/php-5.2.6 /usr/local/php5

httpd.confにPHPファイルタイプ情報追加
AddType application/x-httpd-php.php  ← 追記

PHP とMySQLとphpMyAdmin間の通信はソケット(ファイル)で行われるためソケットファイルのパスは3者の各設定ファイルで統一したものを指定し ておく必要がある。以下、PHPの設定のファイルである/etc/php.iniにソケットのパスを指定する方法を記載する。

/etc/php.ini
[MySQl]セクション内
mysql.default_socket = /var/lib/mysql/mysql.sock  ← 追記

PHP 
'./configure' '--with-apxs2=/usr/sbin/apxs' '--with-pgsql' '--with-iconv' '--enable-mbstring' '--enable-ftp' --with-zlib --enable-mbstring --with-curl --with-curlwrappers --with-pdo-pgsql --with-gd --with-freetype-dir --with-jpeg-dir

make

make install

どこか分からないから、質問下さい!

Saturday, April 18, 2009

DICE for linux,インストール && 設定

This summary is not available. Please click here to view the post.

Linux basic and advance commands, Useful commands

if you have any question about linux or command need me help please post your question here! thank you!

*) check folder size on linux
$ du -hs /path/to/directory
very simple he he..............


*)check modulde already install on server
example
ldd `which ssh`
ldd `which postgres`

*) copy folder to other server
scp -rp /dest/ account@yourserverip(www.ecshopping-guide.com):/path/



*) Find & Replace across multiple files in linux

find . -name "*.php" -print | xargs sed -i 's/foo/bar/g'


*)check linux version
less /proc/version
check linux version
less /proc/version
Linux - Find string in files.

find . | xargs grep 'string' -sl

The -s is for summary and won't display warning messages such as grep: ./directory-name: Is a directory

The -l is for list, so we get just the filename and not all instances of the match displayed in the results.

Performing the search on the current directory I get:

./javascript_open_new_window_form.php
./excel_large_number_error.php
./linux_vi_string_substitution.php
./email_reformat.php

I find this useful for just quickly seeing which files contain a search time. I would normally limit the files searched with a command such as :
find . -iname '*php' | xargs grep 'string' -sl

Another common search for me, is to just look at the recently updated files:
find . -iname '*php' -mtime -1 | xargs grep 'string' -sl

would find only files edited today, whilst the following finds the files older than today:
find . -iname '*php' -mtime +1 | xargs grep 'string' -sl
list open files
lsof -i

*) check linux version
uname -v

xem kernel
rpm -q kernel

*) dispaly kernel on server
rpm -qa | egrep kernel




ommand Description
• apropos whatis Show commands pertinent to string. See also threadsafe
• man -t man | ps2pdf - > man.pdf make a pdf of a manual page
which command Show full path name of command
time command See how long a command takes
• time cat Start stopwatch. Ctrl-d to stop. See also sw
• nice info Run a low priority command (The "info" reader in this case)
• renice 19 -p $$ Make shell (script) low priority. Use for non interactive tasks
dir navigation
• cd - Go to previous directory
• cd Go to $HOME directory
(cd dir && command) Go to dir, execute command and return to current dir
• pushd . Put current dir on stack so you can popd back to it
file searching
• alias l='ls -l --color=auto' quick dir listing
• ls -lrt List files by date. See also newest and find_mm_yyyy
• ls /usr/bin | pr -T9 -W$COLUMNS Print in 9 columns to width of terminal
find -name '*.[ch]' | xargs grep -E 'expr' Search 'expr' in this dir and below. See also findrepo
find -type f -print0 | xargs -r0 grep -F 'example' Search all regular files for 'example' in this dir and below
find -maxdepth 1 -type f | xargs grep -F 'example' Search all regular files for 'example' in this dir
find -maxdepth 1 -type d | while read dir; do echo $dir; echo cmd2; done Process each item with multiple commands (in while loop)
• find -type f ! -perm -444 Find files not readable by all (useful for web site)
• find -type d ! -perm -111 Find dirs not accessible by all (useful for web site)
• locate -r 'file[^/]*\.txt' Search cached index for names. This re is like glob *file*.txt
• look reference Quickly search (sorted) dictionary for prefix
• grep --color reference /usr/share/dict/words Highlight occurances of regular expression in dictionary
archives and compression
gpg -c file Encrypt file
gpg file.gpg Decrypt file
tar -c dir/ | bzip2 > dir.tar.bz2 Make compressed archive of dir/
bzip2 -dc dir.tar.bz2 | tar -x Extract archive (use gzip instead of bzip2 for tar.gz files)
tar -c dir/ | gzip | gpg -c | ssh user@remote 'dd of=dir.tar.gz.gpg' Make encrypted archive of dir/ on remote machine
find dir/ -name '*.txt' | tar -c --files-from=- | bzip2 > dir_txt.tar.bz2 Make archive of subset of dir/ and below
find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents Make copy of subset of dir/ and below
( tar -c /dir/to/copy ) | ( cd /where/to/ && tar -x -p ) Copy (with permissions) copy/ dir to /where/to/ dir
( cd /dir/to/copy && tar -c . ) | ( cd /where/to/ && tar -x -p ) Copy (with permissions) contents of copy/ dir to /where/to/
( tar -c /dir/to/copy ) | ssh -C user@remote 'cd /where/to/ && tar -x -p' Copy (with permissions) copy/ dir to remote:/where/to/ dir
dd bs=1M if=/dev/sda | gzip | ssh user@remote 'dd of=sda.gz' Backup harddisk to remote machine
rsync (Use the --dry-run option for testing)
rsync -P rsync://rsync.server.com/path/to/file file Only get diffs. Do multiple times for troublesome downloads
rsync --bwlimit=1000 fromfile tofile Locally copy with rate limit. It's like nice for I/O
rsync -az -e ssh --delete ~/public_html/ remote.com:'~/public_html' Mirror web site (using compression and encryption)
rsync -auz -e ssh remote:/dir/ . && rsync -auz -e ssh . remote:/dir/ Synchronize current directory with remote one
ssh (Secure SHell)
ssh $USER@$HOST command Run command on $HOST as $USER (default command=shell)
• ssh -f -Y $USER@$HOSTNAME xeyes Run GUI command on $HOSTNAME as $USER
scp -p -r $USER@$HOST: file dir/ Copy with permissions to $USER's home directory on $HOST
ssh -g -L 8080:localhost:80 root@$HOST Forward connections to $HOSTNAME:8080 out to $HOST:80
ssh -R 1434:imap:143 root@$HOST Forward connections from $HOST:1434 in to imap:143
wget (multi purpose download tool)
• (cd cmdline && wget -nd -pHEKk http://www.pixelbeat.org/cmdline.html) Store local browsable version of a page to the current dir
wget -c http://www.example.com/large.file Continue downloading a partially downloaded file
wget -r -nd -np -l1 -A '*.jpg' http://www.example.com/dir/ Download a set of files to the current directory
wget ftp://remote/file[1-9].iso/ FTP supports globbing directly
• wget -q -O- http://www.pixelbeat.org/timeline.html | grep 'a href' | head Process output directly
echo 'wget url' | at 01:00 Download url at 1AM to current dir
wget --limit-rate=20k url Do a low priority download (limit to 20KB/s in this case)
wget -nv --spider --force-html -i bookmarks.html Check links in a file
wget --mirror http://www.example.com/ Efficiently update a local copy of a site (handy from cron)
networking (Note ifconfig, route, mii-tool, nslookup commands are obsolete)
ethtool eth0 Show status of ethernet interface eth0
ethtool --change eth0 autoneg off speed 100 duplex full Manually set ethernet interface speed
iwconfig eth1 Show status of wireless interface eth1
iwconfig eth1 rate 1Mb/s fixed Manually set wireless interface speed
• iwlist scan List wireless networks in range
• ip link show List network interfaces
ip link set dev eth0 name wan Rename interface eth0 to wan
ip link set dev eth0 up Bring interface eth0 up (or down)
• ip addr show List addresses for interfaces
ip addr add 1.2.3.4/24 brd + dev eth0 Add (or del) ip and mask (255.255.255.0)
• ip route show List routing table
ip route add default via 1.2.3.254 Set default gateway to 1.2.3.254
• tc qdisc add dev lo root handle 1:0 netem delay 20msec Add 20ms latency to loopback device (for testing)
• tc qdisc del dev lo root Remove latency added above
• host pixelbeat.org Lookup DNS ip address for name or vice versa
• hostname -i Lookup local ip address (equivalent to host `hostname`)
• whois pixelbeat.org Lookup whois info for hostname or ip address
• netstat -tupl List internet services on a system
• netstat -tup List active connections to/from system
windows networking (Note samba is the package that provides all this windows specific networking support)
• smbtree Find windows machines. See also findsmb
nmblookup -A 1.2.3.4 Find the windows (netbios) name associated with ip address
smbclient -L windows_box List shares on windows machine or samba server
mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share Mount a windows share
echo 'message' | smbclient -M windows_box Send popup to windows machine (off by default in XP sp2)
text manipulation (Note sed uses stdin and stdout, so if you want to edit files, append newfile)
sed 's/string1/string2/g' Replace string1 with string2
sed 's/\(.*\)1/\12/g' Modify anystring1 to anystring2
sed '/ *#/d; /^ *$/d' Remove comments and blank lines
sed ':a; /\\$/N; s/\\\n//; ta' Concatenate lines with trailing \
sed 's/[ \t]*$//' Remove trailing spaces from lines
sed 's/\([\\`\\"$\\\\]\)/\\\1/g' Escape shell metacharacters active within double quotes
• seq 10 | sed "s/^/ /; s/ *\(.\{7,\}\)/\1/" Right align numbers
sed -n '1000p;1000q' Print 1000th line
sed -n '10,20p;20q' Print lines 10 to 20
sed -n 's/.*\(.*\)<\/title>.*/\1/ip;T;q' Extract title from HTML web page
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n Sort IPV4 ip addresses
• echo 'Test' | tr '[:lower:]' '[:upper:]' Case conversion
• tr -dc '[:print:]' < /dev/urandom Filter non printable characters • history | wc -l Count lines set operations (Note you can export LANG=C for speed. Also these assume no duplicate lines within a file) sort file1 file2 | uniq Union of unsorted files sort file1 file2 | uniq -d Intersection of unsorted files sort file1 file1 file2 | uniq -u Difference of unsorted files sort file1 file2 | uniq -u Symmetric Difference of unsorted files join -a1 -a2 file1 file2 Union of sorted files join file1 file2 Intersection of sorted files join -v2 file1 file2 Difference of sorted files join -v1 -v2 file1 file2 Symmetric Difference of sorted files math • echo '(1 + sqrt(5))/2' | bc -l Quick math (Calculate φ). See also bc • echo 'pad=20; min=64; (100*10^6)/((pad+min)*8)' | bc More complex (int) e.g. This shows max FastE packet rate • echo 'pad=20; min=64; print (100E6)/((pad+min)*8)' | python Python handles scientific notation • echo 'pad=20; plot [64:1518] (100*10**6)/((pad+x)*8)' | gnuplot -persist Plot FastE packet rate vs packet size • echo 'obase=16; ibase=10; 64206' | bc Base conversion (decimal to hexadecimal) • echo $((0x2dec)) Base conversion (hex to dec) ((shell arithmetic expansion)) • units -t '100m/9.74s' 'miles/hour' Unit conversion (metric to imperial) • units -t '500GB' 'GiB' Unit conversion (SI to IEC prefixes) • units -t '1 googol' Definition lookup • seq 100 | (tr '\n' +; echo 0) | bc Add a column of numbers. See also add and funcpy calendar • cal -3 Display a calendar • cal 9 1752 Display a calendar for a particular month year • date -d fri What date is it this friday. See also day • date --date='25 Dec' +%A What day does xmas fall on, this year • date --date '1970-01-01 UTC 2147483647 seconds' Convert number of seconds since the epoch to a date • TZ=':America/Los_Angeles' date What time is it on West coast of US (use tzselect to find TZ) echo "mail -s 'get the train' P@draigBrady.com < /dev/null" | at 17:45 Email reminder • echo "DISPLAY=$DISPLAY xmessage cooker" | at "NOW + 30 minutes" Popup reminder locales • printf "%'d\n" 1234 Print number with thousands grouping appropriate to locale • BLOCK_SIZE=\'1 ls -l get ls to do thousands grouping appropriate to locale • echo "I live in `locale territory`" Extract info from locale database • LANG=en_IE.utf8 locale int_prefix Lookup locale info for specific country. See also ccodes • locale | cut -d= -f1 | xargs locale -kc | less List fields available in locale database recode (Obsoletes iconv, dos2unix, unix2dos) • recode -l | less Show available conversions (aliases on each line) recode windows-1252.. file_to_change.txt Windows "ansi" to local charset (auto does CRLF conversion) recode utf-8/CRLF.. file_to_change.txt Windows utf8 to local charset recode iso-8859-15..utf8 file_to_change.txt Latin9 (western europe) to utf8 recode ../b64 <> file.b64 Base64 encode
recode /qp.. <> file.qp Quoted printable decode
recode ..HTML <> file.html Text to HTML
• recode -lf windows-1252 | grep euro Lookup table of characters
• echo -n 0x80 | recode latin-9/x1..dump Show what a code represents in latin-9 charmap
• echo -n 0x20AC | recode ucs-2/x2..latin-9/x Show latin-9 encoding
• echo -n 0x20AC | recode ucs-2/x2..utf-8/x Show utf-8 encoding
CDs
gzip < /dev/cdrom > cdrom.iso.gz Save copy of data cdrom
mkisofs -V LABEL -r dir | gzip > cdrom.iso.gz Create cdrom image from contents of dir
mount -o loop cdrom.iso /mnt/dir Mount the cdrom image at /mnt/dir (read only)
cdrecord -v dev=/dev/cdrom blank=fast Clear a CDRW
gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom - Burn cdrom image (use dev=ATAPI -scanbus to confirm dev)
cdparanoia -B Rip audio tracks from CD to wav files in current dir
cdrecord -v dev=/dev/cdrom -audio *.wav Make audio CD from all wavs in current dir (see also cdrdao)
oggenc --tracknum='track' track.cdda.wav -o 'track.ogg' Make ogg file from wav file
disk space (See also FSlint)
• ls -lSr Show files by size, biggest last
• du -s * | sort -k1,1rn | head Show top disk users in current dir. See also dutop
• df -h Show free space on mounted filesystems
• df -i Show free inodes on mounted filesystems
• fdisk -l Show disks partitions sizes and types (run as root)
• rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1nf List all packages by installed size (Bytes) on rpm distros
• dpkg-query -W -f='${Installed-Size;10}\t${Package}\n' | sort -k1,1n List all packages by installed size (KBytes) on deb distros
• dd bs=1 seek=2TB if=/dev/null of=ext3.test Create a large test file (taking no space). See also truncate
monitoring/debugging
• tail -f /var/log/messages Monitor messages in a log file
• strace -c ls >/dev/null Summarise/profile system calls made by command
• strace -f -e open ls >/dev/null List system calls made by command
• ltrace -f -e getenv ls >/dev/null List library calls made by command
• lsof -p $$ List paths that process id has open
• lsof ~ List processes that have specified path open
• tcpdump not port 22 Show network traffic except ssh. See also tcpdump_not_me
• ps -e -o pid,args --forest List processes in a hierarchy
• ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d' List processes by % cpu usage
• ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS List processes by mem usage. See also ps_mem.py
• ps -C firefox-bin -L -o pid,tid,pcpu,state List all threads for a particular process
• ps -p 1,2 List info for particular process IDs
• last reboot Show system reboot history
• free -m Show amount of (remaining) RAM (-m displays in MB)
• watch -n1 'cat /proc/interrupts' Watch changeable data continuously
system information (see also sysinfo) ('#' means root access is required)
• uname -a Show kernel version and system architecture
• head -n1 /etc/issue Show name and version of distribution
• cat /proc/partitions Show all partitions registered on the system
• grep MemTotal /proc/meminfo Show RAM total seen by the system
• grep "model name" /proc/cpuinfo Show CPU(s) info
• lspci -tv Show PCI info
• lsusb -tv Show USB info
• mount | column -t List mounted filesystems on the system (and align output)
# dmidecode -q | less Display SMBIOS/DMI information
# smartctl -A /dev/sda | grep Power_On_Hours How long has this disk (system) been powered on in total
# hdparm -i /dev/sda Show info about disk sda
# hdparm -tT /dev/sda Do a read speed test on disk sda
# badblocks -s /dev/sda Test for unreadable blocks on disk sda
interactive (see also linux keyboard shortcuts)
• readline Line editor used by bash, python, bc, gnuplot, ...
• screen Virtual terminals with detach capability, ...
• mc Powerful file manager that can browse rpm, tar, ftp, ssh, ...
• gnuplot Interactive/scriptable graphing
• links Web browser
miscellaneous
• alias hd='od -Ax -tx1z -v' Handy hexdump. (usage e.g.: • hd /proc/self/cmdline | less)
• alias realpath='readlink -f' Canonicalize path. (usage e.g.: • realpath ~/../$USER)
• set | grep $USER Search current environment
touch -c -t 0304050607 file Set file timestamp (YYMMDDhhmm)


squid インストールと設定とても簡単。

http_port 192.168.11.20:80 vhost
#vport=8080
# defaultsite=www.ecshopping-guide.com
cache_peer 127.0.0.1 parent 8080 0 no-query originserver name=server1
cache_peer 192.168.11.8 parent 3000 0 no-query originserver name=server2


acl site1 dstdomain .ecshopping-guide.com
acl site2 dstdomain .shopping-annai.com

cache_peer_access server1 allow site1
cache_peer_access server2 allow site2

# some restriction definitions
#acl all src 0.0.0.0/0.0.0.0
#acl manager proto cache_object
#acl localhost src 127.0.0.1/255.255.255.255
#acl webcluster src 87.233.132.114
#acl webcluster src 87.233.132.112/28
#acl purge method PURGE
#acl CONNECT method CONNECT

# Make sure that access to your accelerated sites is allowed
http_access allow site1
http_access allow site2

# Deny everything else
#http_access deny all


# Cache properties
cache_mem 50 MB
maximum_object_size_in_memory 2048 KB
cache_replacement_policy heap LRU
memory_replacement_policy heap LRU
cache_dir ufs /var/spool/squid 20000 16 256
access_log /var/log/squid/access.log squid
hosts_file /etc/hosts

すごい簡単、分からないから、質問ください。

CentOS5 Redmine インストール && 設定 && 無料説明

Redmine インストールと設定とても簡単ね。

インストールして見てください。分からないかったら、教えてください。私は教えます。無料へへへ。。。。

Ruby製のプロジェクト管理ソフトウェアRedmineのインストール手順。

Redmineの特徴

  • Ruby(Rails) + (MySQL | PostgreSQL | SQLite)
  • 複数プロジェクト管理
  • プロジェクト毎のWiki、リポジトリ、フォーラムなど
  • ユーザー認証、マイページ

など。

よくTracと比較され、Tracはプラグインで拡張しないと使いにくいと言われている、個人的にもデフォルトだとRedmineの方が圧倒的に使いやすかった。

インストール環境

  • CentOS 5
  • Ruby 1.8.5
  • RubyGems 1.1.0
  • Ruby on Rails 2.0.2
  • Mongrel 1.1.4
  • MySQL 5.0.22
  • Redmine Rev:1319

インストール手順

パッケージ管理で必要なものをインストール(Rootで作業)

$ yum install -y ruby rdoc ruby-devel mysql-server

Ruby用パッケージ管理RubyGrmsをインストール。最新版はここから確認

$ wget wget http://rubyforge.org/frs/download.php/34638/rubygems-1.1.0.tgz
$ tar -zxvf rubygems-1.1.0.tgz
$ ruby rubygems-1.1.0/setup.rb
$ rm -Rf rubygems-1.1.0*

Ruby on Railsインストール

$ gem install rails --include-dependencies

Mongrelインストール

$ gem install mongrel

MySQLにデータベースを用意

$ mysql -u root
> create database redmine;

インストールディレクトリを準備

$ mkdir -p /home/redmine

Redmineインストール from SVN

$ cd /home/redmine
$ svn checkout http://redmine.rubyforge.org/svn/trunk/ .

DBコンフィグを編集

$ cp config/database.yml.example config/database.yml

$ vi config/database.yml

# デフォルトだとsocketの場所が違うので合わせて指定する
# [production]のにsocket項目を追加

production:
adapter: mysql
database: redmine
host: localhost
username: root
password:
socket: /var/lib/mysql/mysql.sock

メールコンフィグを編集

$ vi config/environment.rb

# メール機能を使用する場合(SMTP)
# SMTP server configurationの項目を使用するSMTPサーバーの情報に変更

# 使用しない場合
config.action_mailer.perform_deliveries = false

データベースに初期データをセットアップ

$ rake db:migrate RAILS_ENV="production"

使用言語を登録

$ rake load_default_data RAILS_ENV="production"
> ja

Mongrel起動

mongrel_rails start -d -e production

# デフォルトで3000番ポートで起動
# 変更する場合は -p 8080 の様に -p オプションで指定

確認

設置したサーバーの3000番ポート(http://yourdomain:3000/)へアクセス

Apacheとの連携

今回は必要無かったのでそのまま動かせている。

ReverseProxyやSCGIを利用した方法があるらしいのでSSL使いたいとかでApacheにした場合は別途書きます。

PostgreSQL 8.3.5 インストール && 設定

インストール && 設定 とても簡単ね!

PostgreSQLの実行用グループとユーザーを作成します。
# groupadd postgres
# useradd -g postgres -d /usr/local/pgsql postgres
/usr/local/srcディレクトリでアーカイブを展開し、コンパイルおよびインストールを行います。
# cd /usr/local/src
# tar zxvf ダウンロード先/postgresql-8.3.5.tar.gz
# chown -R postgres.postgres /usr/local/src/postgresql-8.3.5

# su - postgres コンパイルはpostgresユーザーで行います
$ cd /usr/local/src/postgresql-8.3.5
$ ./configure \
> --enable-nls=ja \ 各国語サポートを有効にします
> --with-openssl SSL接続を有効にします
$ make
$ make check リグレッションテストを行います
$ make install-strip
$ exit

設定

データベースの格納先を作成します。
ここでは、/home/database/pgsql を格納先にしています。
# mkdir -p /home/database/pgsql
# chown -R postgres.postgres /home/database/pgsql
環境変数を追加します。
# vi /etc/profile

:
export PG_HOME=/usr/local/pgsql

# source /etc/profile 追加した環境変数を適用します
データベースを初期化します。
# su - postgres                                                  postgresユーザーで行います
$ initdb -D /home/database/pgsql -E UTF8 --no-locale
$ exit
ネットワーク上の他のマシンから直接PostgreSQLサーバにアクセスする場合は、下記の設定を行います。
(例は 192.168.10.0/24 からアクセスする場合)
# vi /home/database/pgsql/postgresql.conf
:
# - Connection Settings -

#listen_addresses = 'localhost' # what IP interface(s) to listen on;
# defaults to localhost, '*' = any
listen_addresses = 'localhost,192.168.10.0/24'
:

自動起動設定

自動起動用のスクリプトファイルをコピーし、編集します。
# cp /usr/local/src/postgresql-8.3.0/contrib/start-scripts/linux /etc/rc.d/init.d/pgsql

# vi /etc/rc.d/init.d/pgsql

:
## EDIT FROM HERE
# Source function library.
. /etc/init.d/functions
:
PGDATA="/home/database/pgsql"
:
start)
echo -n "Starting PostgreSQL: "
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo_success
echo
;;
stop)
echo -n "Stopping PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast" >/dev/null
echo_success
echo
;;
restart)
echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w" >/dev/null
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo_success
echo
;;
reload)
echo -n "Reload PostgreSQL: "
su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
echo_success
echo
;;
:

# chmod 755 /etc/rc.d/init.d/pgsql
# chkconfig pgsql on
# service pgsql start

パスワード接続設定

セキュリティを考慮し、データベースへの接続はパスワードを必須にします。
スーパーユーザ postgres にパスワードを設定します。
# su - postgres                                                  postgresユーザーで行います
$ psql
postgres=# ALTER USER postgres WITH PASSWORD 'パスワード';
postgres=# \q
$ exit
pg_hba.conf を編集し、パスワード接続を必須にします。
# vi /home/database/pgsql/pg_hba.conf

:
# "local" is for Unix domain socket connections only
#local all all trust
local all postgres md5
# IPv4 local connections:
#host all all 127.0.0.1/32 trust
host all postgres 127.0.0.1/32 md5
# IPv6 local connections:
#host all all ::1/128 trust
host all postgres ::1/128 md5

何か分からないから、私にお知らせください。