最近さわったProxy設定まとめ

Ubuntu11.10全体設定

System Settings => Network => Network proxyで全体のプロキシ設定ができる。

synaptic

設定 => 設定 => ネットワークタブで設定可能

ただしUbuntu11.10の全体設定で行けるとおもう

Firefox

Firefoxのメニューから

編集 => オプション => 詳細 => ネットワーク => 接続設定

bash

~/.bashrcに以下を記載


export http_proxy="http://example.com:8080"
export ftp_proxy="http://example.com:8080"

除外ルールは以下を記載


no_proxy="localhost,127.0.0.0/8,*.local"

apt-get

Ubuntu11.10の全体設定や、~/.bashrcに設定があれば問題ない。

yum

/etc/yum.confに以下を記載


proxy=http://example.com:8080

wget

/etc/wgetrcに以下を記載


https_proxy = http://example.com:8080
http_proxy = http://example.com:8080
ftp_proxy = http://example.com:8080
use_proxy = on

使わないときは--no-proxyオプションで止められる。

gem

~/.bashrcにhttp_proxy設定してあればOK

rvm

以下で説明

http://d.hatena.ne.jp/yotena/20120106

curl

~/.curlrcに以下を記載


proxy-user = "username:password"
proxy = "http://proxy.domain.com:8080"

ntp

基本はできない。

NICTでは以下のようにあるので、これを利用することは可能。

> https/http を介してアクセスされる場合、次のURLをご利用ください。
> 各種タイムスタンプ(NTP/POSIX/JSON/JSONP/時分秒形式)を文字列で提供しています。
http://www2.nict.go.jp/w/w114/tsp/PubNtp/clients.html

参考)http://husky.mydns.jp/huskysmemo/2010/02/ntpproxy.html

w3m

$http_proxyを設定しておけばよい。

オプションで以下のようなものもある。


-no-proxy
プロキシを利用しない.
-pauth user:pass
プロキシ認証用のユーザ名とパスワードを指定する.

RVMを使ってProxy越しでrubyをインストールする

プロキシ環境下でRVMを使ってrubyをインストールしてたらハマったので色々調べた情報。
Ubuntu11.10のrvmをapt-getでインストールした場合、ライブラリをFetchするコードは、/usr/share/ruby-rvm/scripts/fetchにある。

抜粋すると


if ! command -v curl > /dev/null ; then
rvm_error "rvm requires curl. curl was not found in your active path."
exit 1
elif ! -z ${rvm_proxy} ; then
fetch_command="curl -x${rvm_proxy} -L --create-dirs -C - " # -s for silent
else
fetch_command="curl -L --create-dirs -C - " # -s for silent
fi

curlを使ってるので、対応方法は以下だと思う。

  1. .bashrcにrvm用のproxy設定(export rvm_proxy=http://example.com:8080/ みたいな)を入れるか
  2. .curlrcにcurl用のproxy設定を入れるか

前者を試したけどダメでした。

後者~/.curlrcに以下を追加。


proxy-user = "username:password"
proxy = "http://proxy.domain.com:8080"

1行目のほうは不要ならいらない。


$ sudo rvm package install openssl
Fetching openssl-0.9.8n.tar.gz to /usr/share/ruby-rvm/archives
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3681k 100 3681k 0 0 10.7M 0 --:--:-- --:--:-- --:--:-- 10.8M
 --no-same-owner
Configuring openssl in /usr/share/ruby-rvm/src/openssl-0.9.8n.
Compiling openssl in /usr/share/ruby-rvm/src/openssl-0.9.8n.
Installing openssl to /usr/share/ruby-rvm/usr

これでproxy越しでもいけるようになりました。

ウィンドウを勝手に半分にフィットする機能を無かったことにしたい

Ubuntu11.10でウィンドウサイズを変更した時に、勝手に最大化したり半分にフィットする機能を無かったことにしたい。

症状

  • 画面サイズを上に伸ばしたりすると最大化される。
  • 画面サイズを横に伸ばしたりすると画面の半分にされる。

特に、画面の半分にフィットする方。小さい画面のノートPCだとものすごく邪魔。

やりかた。

  1. Ubuntuソフトウェアセンターかsynapticで、CompizConfig設定マネージャー(compizconfig-setting-manager)をインストールする。
  2. CompizConfig設定マネージャーを開く
  3. ウィンドウマネジメント > Gridのチェックを外す。

以上。

関連情報
Ubuntu 11.10:オーバーレイ・スクロールバーを無かった事にしたい
http://viva-ubuntu.com/viva-ubuntu/system/custom/no-overlay.html
Ubuntu 11.10:グローバル・メニューを無かった事にしたい
http://viva-ubuntu.com/viva-ubuntu/system/custom/ubuntu-11-10%EF%BC%9A%E3%82%B0%E3%83%AD%E3%83%BC%E3%83%90%E3%83%AB%E3%83%BB%E3%83%A1%E3%83%8B%E3%83%A5%E3%83%BC%E3%82%92%E7%84%A1%E3%81%8B%E3%81%A3%E3%81%9F%E4%BA%8B%E3%81%AB%E3%81%97%E3%81%9F.html

Ruby on Rails 3でwill_paginateを使ってみた。

インストール

GemFileに以下を追加

gem 'will_paginate', '>=3.0.pre2'

bundleでインストール

$ <span style="font-weight:bold;">sudo bundle install</span>
[sudo] password for xxxx: 
Fetching source index for http://rubygems.org/
Using rake (0.8.7) 
Using RedCloth (4.2.3) 
Using abstract (1.0.0) 
Using activesupport (3.0.3) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.3) 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.13) 
Using rack-test (0.5.6) 
Using tzinfo (0.3.23) 
Using actionpack (3.0.3) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.8) 
Using mail (2.2.12) 
Using actionmailer (3.0.3) 
Using arel (2.0.6) 
Using activerecord (3.0.3) 
Using activeresource (3.0.3) 
Using bundler (1.0.0.rc.3) 
Using mysql2 (0.2.6) 
Using thor (0.14.6) 
Using railties (3.0.3) 
Using rails (3.0.3) 
Installing will_paginate (3.0.pre2) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

さらにサーバが起動中の場合は再起動する。
サーバの停止はctrl+C
サーバの起動は

$ rails server

利用

コントローラでのモデルの検索はこんな感じ。@booksとかBookは例。

@books = Book.paginate(:page => params[:page], :order => 'created_at desc', :per_page => 4)

Viewでのナビゲーションの表示はこんな感じで出来る。

<%= will_paginate @youtubes %>

こんな感じのができるので、あとはCSSなどで見た目の修正とかすると良い。

← Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next →

(参考)will_paginateのgithubは以下
https://github.com/mislav/will_paginate/wiki

ServersMan@VPSで最初にやること

ServersMan@VPSを借りてみたのだが、申し込みから使えるようになるまで何日かかかった。で、使えるようになったのに気づいてなかったので、その後しばらく放置してた。


で、ようやく時間と気力が戻ってきたので、設定等に取りかかろうとサーバに初接続してみた。したら、iptablesはノーガード設定、起動状態、SSHがID/PASS認証で引き渡されていて軽く萎えた


プライベートなディスクスペースとして、これからいろいろと大事なものを保存する場所にするかもしれないので、すでに汚染されてたらシャレにならないので、全部クリーニングした。


ちなみに、自分が最初に申し込んだのは、ServersMan@VPS proのエンジニアセットというものでした。


というわけで、以下、タイトルどおりの内容。

adminでsshログインする

最初はこのアカウントでしかログインできない。

まっさきにiptablesの設定を変える。

要望があれば&気が向いたらコマンドのっけます。

管理用アカウントを作成して管理ユーザにする。

$ su -
# useradd hoge
# passwd hoge
# usermod -G wheel hoge
# vi /etc/pam.d/su
"auth required pam_wheel.so use_uid"の行のコメントアウト"#"を外す
# visudo
"%wheel  ALL=(ALL)  ALL"の行のコメントアウト"#"を外す

この時点でsudoが出きるようになっているので、確認する。
ちなみに提供された状態だと、sudoする度に、
「audit_log_user_command(): 接続を拒否されました」というエラーがでる。これはCentOSの問題。sudoをアップデートすると直る。

$ sudo yum update sudo

sshの設定を変える

クライアント側で先にDSAキーペアを作っておき、管理ユーザのホームディレクトリに公開鍵の方をコピーする。上記の場合/home/hoge/.ssh/authorized_keysというファイルに公開鍵を書き込む。その後、sshdサーバの設定を変更。

# vi /etc/ssh/sshd_config
"Protocol 2" にする
"PermitRotLogin no" にする
"PasswordAuthentication no" にする
"PermitEmptyPasswords no" にする
"PubkeyAuthentication yes" にする
"AuthorizedKeysFile  .ssh/authorized_keys" にする
保存する。
# /etc/rc.d/init.d/sshd reload

こんぐらいが最低限かな。
なんか、全体的にCentOSの初期設定とかが違っていて、なんかいじった形跡が見られます。本格的に使う前にはいろいろチェックしていらないものは殺すとか、手を打つか、シンプルセット(あまり何も入ってないパッケージ)にしてしまう方がいい気がします。

自分が気づいたのは、

  • インストール済みのMySQlに普通は存在しない変なtestアカウントとか残っている。
  • /etc/配下にいろいろとバックアップと思われる、設定ファイルが残ってる。
  • /root配下にネットワーク設定スクリプトがいろいろある。
  • 444と81ポートが使用されて、BlueOnyxだかコンパネっぽいもので使われている。

など。

ちなみに

MySQL上に初期状態で作られていたユーザはというと

mysql> select Host, User, Password from user;
+----------------------------+------+----------+
| Host                       | User | Password |
+----------------------------+------+----------+
| localhost                  | root |          | 
| OpenVZ-test.intraoffice.jp | root |          | 
| 127.0.0.1                  | root |          | 
| localhost                  |      |          | 
| OpenVZ-test.intraoffice.jp |      |          | 
+----------------------------+------+----------+

こういうよくわからんアカウントが残っているっていうのは、あんまり気持ちいいもんじゃないよね。

まあ、今後に期待しつつも、しばらくプライベートユースで、商用は様子見します。

とりあえず、
gitリポジトリ作る会
http://d.hatena.ne.jp/shunsuk/20100803/1280830065
とかかな。

Zabbixの設定

しばらく放置してましたが、久々にZabbixをいじる時間が出来たので、前回の続きの設定をします。

インストール

ひとまず、zabbix インストールメモ にあるようにインストールがおこなわれていて、Zabbixのページにアクセスできることが前提です。バージョンは1.6.4みたいです。

日本語化

右上の[profile]リンクから言語を変更できます。

設定ファイルの編集

設定しなければならない主な設定は

  • zabbix_agent.conf 監視対象のサーバ
  • zabbix_agentd.conf 監視対象のサーバ
  • zabbix_server.conf 監視サーバ
  • dbconfig.php 監視サーバ

以下、順に。
すべての監視対象の /etc/zabbix/zabbix_agent.conf を編集します。

# This is config file for zabbix_agent
# To get more information about ZABBIX, 
# go http://www.zabbix.com

# IP address of ZABBIX server
# Connections from other hosts will be denied

#Server=localhost <= オリジナル
Server=192.168.10.100 # <= ZabbixサーバのIPアドレスを設定。

# Spend no more than Timeout seconds on processing
# Must be between 1 and 30

Timeout=3

####### USER-DEFINED MONITORED PARAMETERS #######
# Format: UserParameter=<key>,<shell command>
# Note that shell command must not return empty string or EOL only
#UserParameter=system.test,who|wc -l
### Set of parameter for monitoring MySQL server (v3.23.42 and later)
### Change -u<username> and add -p<password> if required
#UserParameter=mysql.ping,mysqladmin -uroot ping|grep alive|wc -l
#UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
#UserParameter=mysql.threads,mysqladmin -uroot status|cut -f3 -d":"|cut -f1 -d"Q"
#UserParameter=mysql.questions,mysqladmin -uroot status|cut -f4 -d":"|cut -f1 -d"S"
#UserParameter=mysql.slowqueries,mysqladmin -uroot status|cut -f5 -d":"|cut -f1 -d"O"
#UserParameter=mysql.qps,mysqladmin -uroot status|cut -f9 -d":"
#UserParameter=mysql.version,mysql -V


すべての監視対象の /etc/zabbix/zabbix_agentd.conf を編集します。

$ more zabbix_agentd.conf 
# This is config file for zabbix_agentd
# To get more information about ZABBIX, go http://www.zabbix.com

############ GENERAL PARAMETERS #################

# List of comma delimited IP addresses (or hostnames) of ZABBIX servers. 
# No spaces allowed. First entry is used for sending active checks.
# Note that hostnames must resolve hostname->IP address and
# IP address->hostname.

#Server=localhost <= オリジナル
Server=192.168.10.100 # <= ZabbixサーバのIPアドレスを設定。

# Server port for sending active checks

#ServerPort=10051

# Unique hostname. Required for active checks.

Hostname=localhost

# Listen port. Default is 10050

#ListenPort=10050

# IP address to bind agent
# If missing, bind to all available IPs

#ListenIP=127.0.0.1

# Number of pre-forked instances of zabbix_agentd.
# Default value is 5
# This parameter must be between 1 and 16

StartAgents=5

# How often refresh list of active checks. 2 minutes by default.

#RefreshActiveChecks=120

# Disable active checks. The agent will work in passive mode listening server.

#DisableActive=1

# Enable remote commands for ZABBIX agent. By default remote commands disabled.

#EnableRemoteCommands=1

# Specifies debug level
# 0 - debug is not created
# 1 - critical information
# 2 - error information
# 3 - warnings
# 4 - information (default)
# 5 - for debugging (produces lots of information)

DebugLevel=3

# Name of PID file

PidFile=/var/run/zabbix-agent/zabbix_agentd.pid

# Name of log file.
# If not set, syslog will be used

LogFile=/var/log/zabbix-agent/zabbix_agentd.log

# Maximum size of log file in MB. Set to 0 to disable automatic log rotation.
#LogFileSize=1

# Spend no more than Timeout seconds on processing
# Must be between 1 and 30

Timeout=3

####### USER-DEFINED MONITORED PARAMETERS #######
# Format: UserParameter=<key>,<shell command>
# Note that shell command must not return empty string or EOL only
#UserParameter=system.test,who|wc -l
### Set of parameter for monitoring MySQL server (v3.23.42 and later)
### Change -u<username> and add -p<password> if required
#UserParameter=mysql.ping,mysqladmin -uroot ping|grep alive|wc -l
#UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
#UserParameter=mysql.threads,mysqladmin -uroot status|cut -f3 -d":"|cut -f1 -d"Q"
#UserParameter=mysql.questions,mysqladmin -uroot status|cut -f4 -d":"|cut -f1 -d"S"
#UserParameter=mysql.slowqueries,mysqladmin -uroot status|cut -f5 -d":"|cut -f1 -d"O"
#UserParameter=mysql.qps,mysqladmin -uroot status|cut -f9 -d":"
#UserParameter=mysql.version,mysql -V


/etc/zabbix/zabbix_server.conf と /etc/zabbix/dbconfig.php もありますが、マニュアルによると小規模なサーバにおいて zabbix_server.conf を編集する必要はないとあります。また、dbconfig.php は zabbix-frontend のプログラムの一部なのであまりいじらないほうがいいでしょう。ただし、DBのサーバが変更になったなど、設定が変わったりするといじらないといけないです。とりあえず、参考までにオリジナルのまま載っけておきます。DBの接続設定がじかにかかれているので、パーミッション等は変更しないほうがいいですね。

/etc/zabbix/zabbix_server.conf

$ sudo more zabbix_server.conf
# This is config file for ZABBIX server process
# To get more information about ZABBIX, 
# go http://www.zabbix.com

############ GENERAL PARAMETERS #################

# This defines unique NodeID in distributed setup,
# Default value 0 (standalone server)
# This parameter must be between 0 and 999
#NodeID=0

# Number of pre-forked instances of pollers
# Default value is 5
# This parameter must be between 0 and 255
#StartPollers=5

# Number of pre-forked instances of pollers for unreachable hosts
# Default value is 1
# This parameter must be between 0 and 255
#StartPollersUnreachable=1

# Number of pre-forked instances of trappers
# Default value is 5
# This parameter must be between 0 and 255
#StartTrappers=5

# Number of pre-forked instances of ICMP pingers
# Default value is 1
# This parameter must be between 0 and 255
#StartPingers=1

# Number of pre-forked instances of discoverers
# Default value is 1
# This parameter must be between 0 and 255
#StartDiscoverers=1

# Number of pre-forked instances of HTTP pollers
# Default value is 1
# This parameter must be between 0 and 255
#StartHTTPPollers=1

# Listen port for trapper. Default port number is 10051. This parameter 
# must be between 1024 and 32767

#ListenPort=10051

# Listen interface for trapper. Trapper will listen all network interfaces
# if this parameter is missing.

#ListenIP=127.0.0.1

# How often ZABBIX will perform housekeeping procedure
# (in hours)
# Default value is 1 hour
# Housekeeping is removing unnecessary information from
# tables history, alert, and alarms
# This parameter must be between 1 and 24

#HousekeepingFrequency=1

# How often ZABBIX will try to send unsent alerts
# (in seconds)
# Default value is 30 seconds
SenderFrequency=30

# Uncomment this line to disable housekeeping procedure
#DisableHousekeeping=1

# Specifies debug level
# 0 - debug is not created
# 1 - critical information
# 2 - error information
# 3 - warnings (default)
# 4 - for debugging (produces lots of information)

DebugLevel=3

# Specifies how long we wait for agent response (in sec)
# Must be between 1 and 30 
Timeout=5

# Specifies how many seconds trapper may spend processing new data
# Must be between 1 and 30 
#TrapperTimeout=5

# After how many seconds of unreachability treat a host as unavailable
#UnreachablePeriod=45

# How ofter check host for availability during the unreachability period
#UnavailableDelay=15

# How ofter check host for availability during the unavailability period
#UnavailableDelay=60

# Name of PID file

PidFile=/var/run/zabbix-server/zabbix_server.pid

# Name of log file
# If not set, syslog is used

LogFile=/var/log/zabbix-server/zabbix_server.log

# Maximum size of log file in MB. Set to 0 to disable automatic log rotation.
#LogFileSize=1

# Location for custom alert scripts
AlertScriptsPath=/etc/zabbix/alert.d/

# Location of 'fping. Default is /usr/sbin/fping
# Make sure that fping binary has root permissions and SUID flag set
FpingLocation=/usr/bin/fping

# Frequency of ICMP pings (item keys 'icmpping' and 'icmppingsec'). Defauls is 60 seconds.
#PingerFrequency=60

# Database host name
# Default is localhost

DBHost=localhost

# Database name
# SQLite3 note: path to database file must be provided. DBUser and DBPassword are ignored.
DBName=zabbix

# Database user

DBUser=zabbix

# Database password
# Comment this line if no password used

DBPassword=xxxxx

# Connect to MySQL using Unix socket?

#DBSocket=/tmp/mysql.sock

/etc/zabbix/dbconfig.php

>||$ sudo more dbconfig.php

|


ここで、おもむろにサーバとエージェントを起動!なんてマニュアルには書いてあるけど、

$ chkconfig --list | grep zabbix
zabbix-agent              0:off  1:off  2:on   3:on   4:on   5:on   6:off
zabbix-server             0:off  1:off  2:on   3:on   4:on   5:on   6:off


とあるので、おそらくディストリのインストールコマンドでインストールしているようなものぐさな自分のサーバでは既に動いています。
たぶん。Zabbixサーバが動いているサーバでは下記のようなプロセスが動いてるはずだし、

$ ps -A | grep zabbix
 1020 ?        00:00:00 zabbix_server
  〜〜 全部で20個動いてるけど省略 〜〜
 1075 ?        00:00:00 zabbix_server
 1694 ?        00:00:00 zabbix_agentd
  〜〜 全部で8個動いてるけど省略 〜〜
 1701 ?        00:00:00 zabbix_agentd


たぶん。Zabbixエージェントが動いているサーバでは下記のようなプロセスが動いてるはず。

$ ps -A | grep zabbix
  778 ?        00:00:00 zabbix_agentd
  〜〜 全部で8個動いてるけど省略 〜〜
  787 ?        00:00:00 zabbix_agentd


普通に動いているみたいなので、あまり考えず大人な対応をしておきます。

$ sudo service zabbix-agent restart
Stopping Zabbix agent: zabbix_agentd
Starting Zabbix agent: zabbix_agentd
$ sudo service zabbix-server restart
Stopping Zabbix server: zabbix_server
Starting Zabbix server: zabbix_server

設定

メール通知

まず、基本のメール通知の設定は、[管理]>[メディアタイプ]>[Email]を選択し、適切なSMTPサーバを設定します。

エージェントを使用するホストの追加

ホストの追加は、[設定]>[ホスト]を選択し、[ホストの作成]ボタンを押します。

ひとまず、ここでは、テスト用のホストを追加してみます。IPアドレスは192.168.10.101と192.168.10.102のUbuntu9.10を用意しています。あと、監視サーバ自身。

やることは、

  • ホスト名
  • グループ名
  • DNS
  • IPアドレス
  • 接続方法
  • テンプレートとのリンク

グループ名はあった方がいい程度かもしれません。DNS名かIPアドレスのどちらか片方は設定して、接続方法を設定したほうに合わせます。テンプレートとのリンクで、Template linuxというのがあるのでそれを設定すると、ある程度、基本的な監視項目が追加されます。最終的にはサーバの目的に合わせて、それぞれテンプレートを作成しそれをあてます。

ダッシュボードにアクセスすると、監視が始まってるようすが分かります。

以上、簡単でしたが、Zabbixの設定でした。

zabbix インストールメモ

Zabbixと言えば、フリーで高機能なサーバ監視ツールです。


いましている仕事で、基本、私は実装とか構築とかを直接触る立場にはないのですが、案件中でzabbixが使われる可能性が高くなった。というわけで、いろんな検討でも役に立つだろうし、「ふーん、Zabbixね。」みたいな感じ(どんな感じだ?)で知ったかできる程度にとりあえず使ってみることにする。


インストールは監視対象サーバ側に入れるエージェントと監視サーバ用のソフトに分けてインストールされます。インストール自体は至って簡単。エージェント、サーバそれぞれ、以下のとおり。


監視対象サーバ(エージェント)側
$ sudo apt-get install zabbix-agent


監視サーバ側
$ sudo apt-get install zabbix-server-mysql zabbix-frontend-php


以下、インストールの途中経過。

パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の特別パッケージがインストールされます:
  apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common
  dbconfig-common defoma fontconfig-config fping libapache2-mod-php5 libapr1
  libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  libdbi-perl libfontconfig1 libgd2-xpm libhtml-template-perl libiksemel3
  libjpeg62 libmysqlclient15off libmysqlclient16 libnet-daemon-perl
  libopenipmi0 libperl5.10 libplrpc-perl libpng12-0 libsensors3 libsnmp-base
  libsnmp15 libsysfs2 libt1-5 libxpm4 mysql-client-5.1 mysql-common
  mysql-server mysql-server-5.1 mysql-server-core-5.1 php5 php5-common php5-gd
  php5-mysql snmpd ssl-cert ttf-dejavu ttf-dejavu-core ttf-dejavu-extra
提案パッケージ:
  apache2-doc apache2-suexec apache2-suexec-custom virtual-mysql-client
  mysql-client postgresql-client defoma-doc psfontmgr x-ttcidfont-conf
  dfontmgr libft-perl php-pear dbishell libgd-tools libipc-sharedcache-perl
  lm-sensors tinyca mailx php5-suhosin
以下のパッケージが新たにインストールされます:
  apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common
  dbconfig-common defoma fontconfig-config fping libapache2-mod-php5 libapr1
  libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  libdbi-perl libfontconfig1 libgd2-xpm libhtml-template-perl libiksemel3
  libjpeg62 libmysqlclient15off libmysqlclient16 libnet-daemon-perl
  libopenipmi0 libperl5.10 libplrpc-perl libpng12-0 libsensors3 libsnmp-base
  libsnmp15 libsysfs2 libt1-5 libxpm4 mysql-client-5.1 mysql-common
  mysql-server mysql-server-5.1 mysql-server-core-5.1 php5 php5-common php5-gd
  php5-mysql snmpd ssl-cert ttf-dejavu ttf-dejavu-core ttf-dejavu-extra
  zabbix-frontend-php zabbix-server-mysql
アップグレード: 0 個、新規インストール: 50 個、削除: 0 個、保留: 37 個。
41.2MB のアーカイブを取得する必要があります。
この操作後に追加で 110MB のディスク容量が消費されます。
続行しますか [Y/n]? 


yを押すと、大量にインストールが始まるんだけど、
ディストリ用にちゃんとパッケージが提供されているなんて、すごくいい時代だ。ちなみにUbuntuの場合9.04でも確か入っていたけど、バグがあって、起動スクリプトを編集しなければいけないなどいろいろあったっぽい。


MySQLがまだインストールされていない場合は、下のような画面がでるので、ここでMySQLのrootパスワードを設定する。



 

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.1.37-1ubuntu5 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
+--------------------+
2 rows in set (0.00 sec)
mysql> use mysql

Database changed
mysql> select User from user;
+------------------+
| User             |
+------------------+
| root             | 
| debian-sys-maint | 
| root             | 
| root             | 
+------------------+
4 rows in set (0.00 sec)


zabbix-frontend-phpがアクセスするDBの種類。MySQLを選択。


zabbix-frontend-phpがアクセスするDBパスワードの設定。


パスワード確認


zabbix-serverの設定をしますか?という画面。


zabbix-server用のDBを作成するDBユーザのパスワード(かな?)


zabbix-serverがアクセスするDBのDBユーザのパスワード


詳しい使い方とか、パスワード類の違い分析はとりあえず今の目的(お試し)から外れているので、全部同じ脆弱パスワードを設定したことは内緒。(もちろんテスト環境のみです。)


一通り質問に答えると、Zabbix関連のDBユーザやDBの作成などが走りはじめる。
ここまでくるとDBの中身は以下のとおり。

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
| zabbix             | 
+--------------------+
3 rows in set (0.00 sec)

mysql> select User from mysql.user;
+------------------+
| User             |
+------------------+
| root             | 
| debian-sys-maint | 
| root             | 
| zabbix           | 
| root             | 
+------------------+
5 rows in set (0.00 sec)

mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------------+
| Tables_in_zabbix      |
+-----------------------+
| acknowledges          | 
| actions               | 
| alerts                | 
| applications          | 
| auditlog              | 
| conditions            | 
| config                | 
| dchecks               | 
| dhosts                | 
| drules                | 
| dservices             | 
| escalations           | 
| events                | 
| functions             | 
| graphs                | 
| graphs_items          | 
| groups                | 
| help_items            | 
| history               | 
| history_log           | 
| history_str           | 
| history_str_sync      | 
| history_sync          | 
| history_text          | 
| history_uint          | 
| history_uint_sync     | 
| hosts                 | 
| hosts_groups          | 
| hosts_profiles        | 
| hosts_profiles_ext    | 
| hosts_templates       | 
| housekeeper           | 
| httpstep              | 
| httpstepitem          | 
| httptest              | 
| httptestitem          | 
| ids                   | 
| images                | 
| items                 | 
| items_applications    | 
| mappings              | 
| media                 | 
| media_type            | 
| node_cksum            | 
| nodes                 | 
| opconditions          | 
| operations            | 
| profiles              | 
| proxy_dhistory        | 
| proxy_history         | 
| rights                | 
| screens               | 
| screens_items         | 
| scripts               | 
| service_alarms        | 
| services              | 
| services_links        | 
| services_times        | 
| sessions              | 
| slides                | 
| slideshows            | 
| sysmaps               | 
| sysmaps_elements      | 
| sysmaps_link_triggers | 
| sysmaps_links         | 
| trends                | 
| trends_uint           | 
| trigger_depends       | 
| triggers              | 
| users                 | 
| users_groups          | 
| usrgrp                | 
| valuemaps             | 
+-----------------------+
73 rows in set (0.00 sec)

なんか、テーブル名見てるだけでもいろんなことができそうな気がしてきますね。


何してんのかとか、どこに設定ファイルがあるかの情報が結構流れてるので、非常に冗長ですが、インストールログも記録しとこ。
ちなみに、途中、populating database via sql...のところで結構待たされるので失敗したのかと不安になります。PCスペックにも夜でしょうが、20〜30分ぐらいはじっと待ちましょう。

(インストールログ。ここまでは省略)
......................................
パッケージからテンプレートを展開しています: 100%
パッケージを事前設定しています ...
未選択パッケージ mysql-common を選択しています。
(データベースを読み込んでいます ... 現在 40366 個のファイルとディレクトリがインストールされています。)
(.../mysql-common_5.1.37-1ubuntu5_all.deb から) mysql-common を展開しています...
未選択パッケージ libnet-daemon-perl を選択しています。
(.../libnet-daemon-perl_0.43-1_all.deb から) libnet-daemon-perl を展開しています...
未選択パッケージ libplrpc-perl を選択しています。
(.../libplrpc-perl_0.2020-2_all.deb から) libplrpc-perl を展開しています...
未選択パッケージ libdbi-perl を選択しています。
(.../libdbi-perl_1.609-1_amd64.deb から) libdbi-perl を展開しています...
未選択パッケージ libmysqlclient16 を選択しています。
(.../libmysqlclient16_5.1.37-1ubuntu5_amd64.deb から) libmysqlclient16 を展開しています...
未選択パッケージ libdbd-mysql-perl を選択しています。
(.../libdbd-mysql-perl_4.011-1ubuntu1_amd64.deb から) libdbd-mysql-perl を展開しています...
未選択パッケージ mysql-client-5.1 を選択しています。
(.../mysql-client-5.1_5.1.37-1ubuntu5_amd64.deb から) mysql-client-5.1 を展開しています...
未選択パッケージ mysql-server-core-5.1 を選択しています。
(.../mysql-server-core-5.1_5.1.37-1ubuntu5_amd64.deb から) mysql-server-core-5.1 を展開しています...
man-db のトリガを処理しています ...
mysql-common (5.1.37-1ubuntu5) を設定しています ...
未選択パッケージ mysql-server-5.1 を選択しています。
(データベースを読み込んでいます ... 現在 40720 個のファイルとディレクトリがインストールされています。)
(.../mysql-server-5.1_5.1.37-1ubuntu5_amd64.deb から) mysql-server-5.1 を展開しています...
未選択パッケージ libapr1 を選択しています。
(.../libapr1_1.3.8-1_amd64.deb から) libapr1 を展開しています...
未選択パッケージ libaprutil1 を選択しています。
(.../libaprutil1_1.3.9+dfsg-1ubuntu1_amd64.deb から) libaprutil1 を展開しています...
未選択パッケージ libaprutil1-dbd-sqlite3 を選択しています。
(.../libaprutil1-dbd-sqlite3_1.3.9+dfsg-1ubuntu1_amd64.deb から) libaprutil1-dbd-sqlite3 を展開しています...
未選択パッケージ libaprutil1-ldap を選択しています。
(.../libaprutil1-ldap_1.3.9+dfsg-1ubuntu1_amd64.deb から) libaprutil1-ldap を展開しています...
未選択パッケージ apache2.2-bin を選択しています。
(.../apache2.2-bin_2.2.12-1ubuntu2.1_amd64.deb から) apache2.2-bin を展開しています...
未選択パッケージ apache2-utils を選択しています。
(.../apache2-utils_2.2.12-1ubuntu2.1_amd64.deb から) apache2-utils を展開しています...
未選択パッケージ apache2.2-common を選択しています。
(.../apache2.2-common_2.2.12-1ubuntu2.1_all.deb から) apache2.2-common を展開しています...
未選択パッケージ apache2-mpm-prefork を選択しています。
(.../apache2-mpm-prefork_2.2.12-1ubuntu2.1_all.deb から) apache2-mpm-prefork を展開しています...
未選択パッケージ apache2 を選択しています。
(.../apache2_2.2.12-1ubuntu2.1_all.deb から) apache2 を展開しています...
未選択パッケージ dbconfig-common を選択しています。
(.../dbconfig-common_1.8.41_all.deb から) dbconfig-common を展開しています...
未選択パッケージ defoma を選択しています。
(.../defoma_0.11.10-0.2ubuntu1_all.deb から) defoma を展開しています...
未選択パッケージ ttf-dejavu-core を選択しています。
(.../ttf-dejavu-core_2.29-2_all.deb から) ttf-dejavu-core を展開しています...
未選択パッケージ ttf-dejavu-extra を選択しています。
(.../ttf-dejavu-extra_2.29-2_all.deb から) ttf-dejavu-extra を展開しています...
未選択パッケージ ttf-dejavu を選択しています。
(.../ttf-dejavu_2.29-2_all.deb から) ttf-dejavu を展開しています...
未選択パッケージ fontconfig-config を選択しています。
(.../fontconfig-config_2.6.0-1ubuntu12_all.deb から) fontconfig-config を展開しています...
未選択パッケージ fping を選択しています。
(.../fping_2.4b2-to-ipv6-16_amd64.deb から) fping を展開しています...
未選択パッケージ php5-common を選択しています。
(.../php5-common_5.2.10.dfsg.1-2ubuntu6.3_amd64.deb から) php5-common を展開しています...
未選択パッケージ libapache2-mod-php5 を選択しています。
(.../libapache2-mod-php5_5.2.10.dfsg.1-2ubuntu6.3_amd64.deb から) libapache2-mod-php5 を展開しています...
未選択パッケージ libfontconfig1 を選択しています。
(.../libfontconfig1_2.6.0-1ubuntu12_amd64.deb から) libfontconfig1 を展開しています...
未選択パッケージ libjpeg62 を選択しています。
(.../libjpeg62_6b-14build1_amd64.deb から) libjpeg62 を展開しています...
未選択パッケージ libpng12-0 を選択しています。
(.../libpng12-0_1.2.37-1_amd64.deb から) libpng12-0 を展開しています...
未選択パッケージ libxpm4 を選択しています。
(.../libxpm4_1%3a3.5.7-2_amd64.deb から) libxpm4 を展開しています...
未選択パッケージ libgd2-xpm を選択しています。
(.../libgd2-xpm_2.0.36~rc1~dfsg-3ubuntu1.9.10.1_amd64.deb から) libgd2-xpm を展開しています...
未選択パッケージ libhtml-template-perl を選択しています。
(.../libhtml-template-perl_2.9-1_all.deb から) libhtml-template-perl を展開しています...
未選択パッケージ libiksemel3 を選択しています。
(.../libiksemel3_1.2-4build1_amd64.deb から) libiksemel3 を展開しています...
未選択パッケージ libmysqlclient15off を選択しています。
(.../libmysqlclient15off_5.1.30really5.0.83-0ubuntu3_amd64.deb から) libmysqlclient15off を展開しています...
未選択パッケージ libopenipmi0 を選択しています。
(.../libopenipmi0_2.0.14-2ubuntu2_amd64.deb から) libopenipmi0 を展開しています...
未選択パッケージ libperl5.10 を選択しています。
(.../libperl5.10_5.10.0-24ubuntu4_amd64.deb から) libperl5.10 を展開しています...
未選択パッケージ libsysfs2 を選択しています。
(.../libsysfs2_2.1.0-5_amd64.deb から) libsysfs2 を展開しています...
未選択パッケージ libsensors3 を選択しています。
(.../libsensors3_1%3a2.10.8-1_amd64.deb から) libsensors3 を展開しています...
未選択パッケージ libsnmp-base を選択しています。
(.../libsnmp-base_5.4.1~dfsg-12ubuntu7_all.deb から) libsnmp-base を展開しています...
未選択パッケージ libsnmp15 を選択しています。
(.../libsnmp15_5.4.1~dfsg-12ubuntu7_amd64.deb から) libsnmp15 を展開しています...
未選択パッケージ libt1-5 を選択しています。
(.../libt1-5_5.1.2-3_amd64.deb から) libt1-5 を展開しています...
未選択パッケージ mysql-server を選択しています。
(.../mysql-server_5.1.37-1ubuntu5_all.deb から) mysql-server を展開しています...
未選択パッケージ php5 を選択しています。
(.../php5_5.2.10.dfsg.1-2ubuntu6.3_all.deb から) php5 を展開しています...
未選択パッケージ php5-gd を選択しています。
(.../php5-gd_5.2.10.dfsg.1-2ubuntu6.3_amd64.deb から) php5-gd を展開しています...
未選択パッケージ php5-mysql を選択しています。
(.../php5-mysql_5.2.10.dfsg.1-2ubuntu6.3_amd64.deb から) php5-mysql を展開しています...
未選択パッケージ snmpd を選択しています。
(.../snmpd_5.4.1~dfsg-12ubuntu7_amd64.deb から) snmpd を展開しています...
未選択パッケージ ssl-cert を選択しています。
(.../ssl-cert_1.0.23ubuntu2_all.deb から) ssl-cert を展開しています...
未選択パッケージ zabbix-frontend-php を選択しています。
(.../zabbix-frontend-php_1%3a1.6.4-2build1_all.deb から) zabbix-frontend-php を展開しています...
未選択パッケージ zabbix-server-mysql を選択しています。
(.../zabbix-server-mysql_1%3a1.6.4-2build1_amd64.deb から) zabbix-server-mysql を展開しています...
man-db のトリガを処理しています ...
ufw のトリガを処理しています ...
libnet-daemon-perl (0.43-1) を設定しています ...
libplrpc-perl (0.2020-2) を設定しています ...
libdbi-perl (1.609-1) を設定しています ...
libmysqlclient16 (5.1.37-1ubuntu5) を設定しています ...

libdbd-mysql-perl (4.011-1ubuntu1) を設定しています ...
mysql-client-5.1 (5.1.37-1ubuntu5) を設定しています ...

mysql-server-core-5.1 (5.1.37-1ubuntu5) を設定しています ...
mysql-server-5.1 (5.1.37-1ubuntu5) を設定しています ...
 * Stopping MySQL database server mysqld                                 [ OK ] 
091213 19:22:12 [Note] Plugin 'FEDERATED' is disabled.
091213 19:22:12  InnoDB: Started; log sequence number 0 44233
091213 19:22:12  InnoDB: Starting shutdown...
091213 19:22:13  InnoDB: Shutdown completed; log sequence number 0 44233
091213 19:22:13 [Warning] Forcing shutdown of 1 plugins
 * Starting MySQL database server mysqld                                 [ OK ] 
 * Checking for corrupt, not cleanly closed and upgrade needing tables.

libapr1 (1.3.8-1) を設定しています ...

libaprutil1 (1.3.9+dfsg-1ubuntu1) を設定しています ...

libaprutil1-dbd-sqlite3 (1.3.9+dfsg-1ubuntu1) を設定しています ...
libaprutil1-ldap (1.3.9+dfsg-1ubuntu1) を設定しています ...
apache2.2-bin (2.2.12-1ubuntu2.1) を設定しています ...
apache2-utils (2.2.12-1ubuntu2.1) を設定しています ...
apache2.2-common (2.2.12-1ubuntu2.1) を設定しています ...
Enabling site default.
Enabling module alias.
Enabling module autoindex.
Enabling module dir.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module status.
Enabling module auth_basic.
Enabling module deflate.
Enabling module authz_default.
Enabling module authz_user.
Enabling module authz_groupfile.
Enabling module authn_file.
Enabling module authz_host.

apache2-mpm-prefork (2.2.12-1ubuntu2.1) を設定しています ...
 * Starting web server apache2                                           [ OK ] 

apache2 (2.2.12-1ubuntu2.1) を設定しています ...

dbconfig-common (1.8.41) を設定しています ...

defoma (0.11.10-0.2ubuntu1) を設定しています ...

ttf-dejavu-core (2.29-2) を設定しています ...

ttf-dejavu-extra (2.29-2) を設定しています ...

ttf-dejavu (2.29-2) を設定しています ...
fontconfig-config (2.6.0-1ubuntu12) を設定しています ...

fping (2.4b2-to-ipv6-16) を設定しています ...
php5-common (5.2.10.dfsg.1-2ubuntu6.3) を設定しています ...
libapache2-mod-php5 (5.2.10.dfsg.1-2ubuntu6.3) を設定しています ...

Creating config file /etc/php5/apache2/php.ini with new version
 * Reloading web server config apache2                                   [ OK ] 

libfontconfig1 (2.6.0-1ubuntu12) を設定しています ...

libjpeg62 (6b-14build1) を設定しています ...

libpng12-0 (1.2.37-1) を設定しています ...

libxpm4 (1:3.5.7-2) を設定しています ...

libgd2-xpm (2.0.36~rc1~dfsg-3ubuntu1.9.10.1) を設定しています ...

libhtml-template-perl (2.9-1) を設定しています ...
libiksemel3 (1.2-4build1) を設定しています ...

libmysqlclient15off (5.1.30really5.0.83-0ubuntu3) を設定しています ...

libopenipmi0 (2.0.14-2ubuntu2) を設定しています ...

libperl5.10 (5.10.0-24ubuntu4) を設定しています ...

libsysfs2 (2.1.0-5) を設定しています ...

libsensors3 (1:2.10.8-1) を設定しています ...
.udevdb or .udev presence implies active udev.  Aborting MAKEDEV invocation.

Creating config file /etc/sensors.conf with new version

libsnmp-base (5.4.1~dfsg-12ubuntu7) を設定しています ...
libsnmp15 (5.4.1~dfsg-12ubuntu7) を設定しています ...

libt1-5 (5.1.2-3) を設定しています ...

mysql-server (5.1.37-1ubuntu5) を設定しています ...
php5 (5.2.10.dfsg.1-2ubuntu6.3) を設定しています ...
php5-gd (5.2.10.dfsg.1-2ubuntu6.3) を設定しています ...

php5-mysql (5.2.10.dfsg.1-2ubuntu6.3) を設定しています ...

snmpd (5.4.1~dfsg-12ubuntu7) を設定しています ...
update-rc.d: warning: snmpd stop runlevel arguments (1) do not match LSB Default-Stop values (0 1 6)
 * Starting network management services:                                 [ OK ] 

ssl-cert (1.0.23ubuntu2) を設定しています ...

zabbix-frontend-php (1:1.6.4-2build1) を設定しています ...
dbconfig-common: writing config to /etc/dbconfig-common/zabbix-frontend-php.conf

Creating config file /etc/dbconfig-common/zabbix-frontend-php.conf with new version

Creating config file /etc/zabbix/dbconfig.php with new version
dbconfig-common: flushing administrative password
 * Restarting web server apache2                                                 ... waiting                                                             [ OK ]

zabbix-server-mysql (1:1.6.4-2build1) を設定しています ...
dbconfig-common: writing config to /etc/dbconfig-common/zabbix-server-mysql.conf

Creating config file /etc/dbconfig-common/zabbix-server-mysql.conf with new version

Creating config file /etc/zabbix/zabbix_server.conf with new version
chown: 無効なユーザ: `zabbix'
granting access to database zabbix for zabbix@localhost: success.
verifying access for zabbix@localhost: success.
creating database zabbix: success.
verifying database zabbix exists: success.
populating database via sql...  done.
dbconfig-common: flushing administrative password
update-rc.d: warning: zabbix-server start runlevel arguments (2 3 4 5) do not match LSB Default-Start values (S)
update-rc.d: warning: zabbix-server stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (0 6)
Starting Zabbix server: zabbix_server

libc-bin のトリガを処理しています ...
ldconfig deferred processing now taking place


これでZabbixにアクセスできます。アクセスURLは以下のとおり。
http://[ホスト名]/zabbix/



「Timezone for PHP is not set. Please set "date.timezone" option in php.ini.」
という警告が出ているので、/etc/php5/apache2/php.iniのdate.timezoneの場所を探して、修正します。


デフォルトではコメントアウトしてあるので、コメントを外して、

$ sudo vi /etc/php5/apache2/php.ini

date.timezone = Asia/Tokyo


などとし、その後Apacheをに設定を読み込ませます。

$ sudo service apache2 reload



デフォルトのアカウントはAdminでパスワードがzabbixです。以下はログイン後の画面。


ちなみに設定はこれからです。ひとまずインストールまで。