freebsdだと、デフォルトがcshなので、使いなれたbashに変更する
#cd /usr/ports/shell/bash/
#make
#make install
でインストールまでは完了。おそらく
/usr/local/bin/bash
ができているはず。
あとは、
# chsh -s /usr/local/bin/bash
chsh: user information updated
で変更してあげれば完了。
念のため、新規接続でつなげてみて
#echo $SHELL
とかで /usr/local/bin/bash とでればOK
ホームディレクトリに
.bashrc とか .bash_profile とか作ってもOK
portsからインストールする前に、
csvup コマンド等で最新にしておくのが、better
ports collection は、
/usr/ports
にあります。
アプリケーションのインストールは簡単で、port をダウンロードし、それを展開し、その port のディレクトリで make と打つだけです。
今回、postgresql8.2を例にすると
# su – (rootになります)
# cd /usr/ports/databases/postgresql82-server
# make
もしくは
# make configure
# make
をおこなう。
で、最後にインストール
# make install
最後に掃除で
# make clean
としてもOKです。
その他引数もろもろ
make fetch FTPなどのサイトからソースコードをダウンロードする
make checksum ダウンロードしたファイルが正常かどうか確かめる
make deinstall インストールしたportの削除
make depands このportsに依存関係(インストールするために必要なports)があるportsをインストールする
make extract ソースコードを展開する
make patch 展開したソースコードにFreeBSD用のパッチを当てる
make configure コンパイルするオプションなどを指定してコンパイルするための準備を整える(configure)
make build コンパイルする
make install はコンパイルしたバイナリをOSにインストールする
make package はコンパイルしたバイナリをpackageにする
redhat系 と freebsdでおこないました。
福大のサーバーのNTPを利用するのはよしましょう。(ソースはいろんなところ)
クーロンで 「ntpdate」を設定してないか事前チェックする。
おこなってない -> そのままntpdの設定へ
おこなってる -> クーロンの設定を削除して設定へ
なお、現在の時間とサーバーの時間があまりにづれている場合は一度
[root@www root]# ntpdate ntp.xxx.xxx.xx.xx
などで、時間をあわせておく
以後は、rpm で ntpが入っている事が前提
/etc/ntp.conf
の修正
restrict default ignore
restrict 127.0.0.1
#ローカルからの問い合わせ
restrict 192.168.xxx.0 mask 255.255.255.0 nopeer nomodify notrap
#外部サーバへの許可
restrict 210.173.160.27 nomodify notrap noquery
restrict 210.173.160.57 nomodify notrap noquery
restrict 210.173.160.87 nomodify notrap noquery
#外部サーバーの指定
server ntp1.jst.mfeed.ad.jp
server ntp2.jst.mfeed.ad.jp
server ntp3.jst.mfeed.ad.jp
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
#同期ファイルの指定
driftfile /etc/ntp/drift
broadcastdelay 0.008
authenticate yes
keys /etc/ntp/keys
設定値を書き出すとこんな感じ、大事なのは、ntpサーバーを指定しているところ
server ntp1.jst.mfeed.ad.jp
の部分かな
後は、
[root@www root]# /etc/init.d/ntp start
をしてあげて起動
サービスのチェックは
[root@www root]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 50 64 3 0.000 0.000 0.008
ntp1.jst.mfeed. fs-monntp1.mfee 2 u 44 64 3 2.093 189.550 5.384
ntp2.jst.mfeed. fs-monntp1.mfee 2 u 36 64 3 2.184 190.306 5.384
ntp3.jst.mfeed. fs-monntp1.mfee 2 u 35 64 3 3.108 190.801 6.073
としてあげてチェック
ntp3.jst.mfeed. とかの前に * や + がついてないのは同期がとれてない
しばらくすると
+ntp3.jst.mfeed. fs-monntp1.mfee 2 u 35 64 3 3.108 190.801 6.073
とかなります。
最後に、自動起動のチェック
[root@www root]# chkconfig –list | grep ntp
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@www root]# chkconfig ntpd on
[root@www root]# chkconfig –list | grep ntp
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
で、とりあえず完了。
free bsd にて
基本的には同じ、
自動起動は
/etc/rc.conf に
[root@www /root]# vi /etc/rc.conf
# ntpd
ntpd_enable=”YES”
ntpd_program=”/usr/sbin/ntpd -c /etc/ntp.conf”
ntpd_flags=”-p /var/run/ntpd.pid”
などを書き込む
freebsd に標準でついているログ管理ツール
/etc/newsyslog.conf を編集して管理する。
今回修正したいのは、apacheのログ
ログは、
/var/log/httpd/host_name/host_name-access.log
/var/log/httpd/host_name/host_name-error.log
の形式で保存
【newsyslog.confの書式】
logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
ログファイル名 所有者:グループ 権限 バックアップ数 ファイルサイズ いつ実行するか 圧縮形式 pidファイル
になってる。
logfilename は、ログ管理するファイルまでのパス
size と when は、それぞれ指定のサイズかくるか指定の時間がきたらログのローテーションを実行します。
apacheの場合、ログファイルを切り分けると、pidに対してシグナルを送ってあげないといけないので、 pid_file sig_num もあわせて設定します。
【具体的な設定例】
・日曜日の24時(月曜日の0時)にログの切り分けを行う。
・週に一回、48週間ログをためる。
・ログのパーミッションは644。
・gzipで圧縮する。
/var/log/httpd/host_name/host_name-access.log 644 48 * $W1D0 Z /var/run/httpd.pid 30
初期チューニング編
ポストグレスの場合重要になる。
shared memory 共有メモリ
semaphore セマフォ
ファイルテーブル
について、チューニングです。参考はシーラカンス本
今回のマシンのメモリが512Mなので、
128MBを共有メモリとして割り当てる予定で。
-su-2.05b# ipcs -M
shminfo:
shmmax: 33554432 (max shared memory segment size)
shmmin: 1 (min shared memory segment size)
shmmni: 192 (max number of shared memory identifiers)
shmseg: 128 (max shared memory segments per process)
shmall: 8192 (max amount of shared memory in pages)
shmmax: 33554432 = 32MB
なので、
options “SHMMAX=(SMMAXPGS*PAGE_SIZE+1)”
options SHMMAXPGS = n
とするために
PAGE_SIZE は通常4096らしいので
SHMMAX を 128M(1024*1024*128=134217728)にするために
134217728 = n * 4096+1
をといて(1はとりあえず無視します。)
n = 32768
なので、 n = 32768
を設定します。
ユーザー数は、
確認(便宜上上から数値をつけてます。)
-su-2.05b# ipcs -S
seminfo:
1 semmap: 30 (# of entries in semaphore map)
2 semmni: 10 (# of semaphore identifiers)
3 semmns: 60 (# of semaphores in system)
4 semmnu: 30 (# of undo structures in system)
5 semmsl: 60 (max # of semaphores per id)
6 semopm: 100 (max # of operations per semop call)
7 semume: 10 (max # of undo entries per process)
8 semusz: 92 (size in bytes of undo structure)
9 semvmx: 32767 (semaphore maximum value)
10 semaem: 16384 (adjust on exit max value)
3の、セフォマの数(semmns)が、PostgreSQLのユーザー
semmni:
semmns: 60 (# of semaphores in system)
http://d.hatena.ne.jp/kztmk/20051124
のサイトを参考に、比べながらやってみた。
セットアップしてもらったサーバーは /var 以下に容量がさかれている
ので、
# initdb data=/var/pgsql とする。
freebsd は、共有メモリをカーネルレベルから変更する必要が
あるので、シーラカンス本を参考に
http://d.hatena.ne.jp/kztmk/20051124
======================================================================
For procedural languages and postgresql functions, please note that
you might have to update them when updating the server.
If you have many tables and many clients running, consider raising
kern.maxfiles using sysctl(8), or reconfigure your kernel
appropriately.
You should vacuum and backup your database regularly. There is a
periodic script, ${LOCALBASE}/etc/periodic/daily/502.pgsql, that you
may find useful. Per default, it perfoms vacuum on all databases
nightly. See the script for instructions.
To allow many simultaneous connections to your PostgreSQL server, you
should raise the SystemV shared memory limits in your kernel. Here are
example values for allowing up to 180 clients (configurations in
postgresql.conf also needed, of course):
options SYSVSHM
options SYSVSEM
options SYSVMSG
options SHMMAXPGS=65536
options SEMMNI=40
options SEMMNS=240
options SEMUME=40
options SEMMNU=120
If you plan to access your PostgreSQL server using ODBC, please
consider running the SQL script /usr/local/share/postgresql/odbc.sql
to get the functions required for ODBC compliance.
======================================================================
To initialize the database, run
/usr/local/etc/rc.d/010.pgsql.sh initdb
You can then start PostgreSQL by running:
/usr/local/etc/rc.d/010.pgsql.sh start
For postmaster settings, see ~pgsql/data/postgresql.conf
NB. FreeBSD’s PostgreSQL port now by default logs to syslog
See ~pgsql/data/postgresql.conf for more info
======================================================================
To run PostgreSQL at startup, add
‘postgresql_enable=”YES”‘ to /etc/rc.conf
======================================================================
===> Registering installation for postgresql-server-8.1.3
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/bin/postgres
This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/010.pgsql.sh
If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type ‘make deinstall’
to deinstall the port if this is a concern.
For more information, and contact details about the security
status of this software, see the following webpage:
http://www.postgresql.org/
とかいろいろ言われます。
fetch: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/php-5.1.4.tar.bz2: File unavailable (e.g., file not found, no access)
=> Couldn’t fetch it – please try to retrieve this
=> port manually into /usr/ports/distfiles/ and try again.
*** Error code 1
とか、「Couldn’t fetch it – please try to retrieve this」と出た場合、
この場合、(e.g., file not found, no access) で、上記のファイルが
ないと言われているので、別途取得して
/usr/ports/distfiles/
へ、置けばOKです。
ipf でFWをかけている場合にその設定を反映させるには
/etc/ipf.rules
が設定ファイルとして、
$ ipf -Fa -Z -f /etc/ipf.rules
で反映させます。反映は
$ ipfstat -i
で、inputを
$ ipfstat -o
で outputを確認できます。
まとめてなら
$ ipfstat -io
で大丈夫です。