Zabbixをインストールする
Kodaiさんのブログの通りやればできるのだけれど、SELinuxを失念してはまった為、メモ。といっても、設定が良く分からなくて、SELinuxを無効にしただけなのですが。
http://kodai74.blogspot.jp/2012/05/zabbix-siarpm.html
環境
- CentOS 6.2
- Zabbix 2.0.5
- 同じOSにServerとAgentをインストールする
手順
- Zabbixのインストール
rpm -ivh http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-release-2.0-1.el6.noarch.rpm
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-agent zabbix-sender※zabbix-web-japanese, zabbix-agent, zabbix-senderは任意
- MySQLの設定
/etc/my.cnf の [mysqld] に次の内容を記述します。ただし、MySQL5.1の記述方法です。
innodb_file_per_table
innodb_buffer_pool_size=512M
innodb_log_file_size=64M
default-character-set=utf8 - データセットアップ
service mysqld start
mysql -uroot
mysql> create database zabbix;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixpass';
mysql> exit
cd /usr/share/doc/zabbix-server-mysql-2.0.5/create/
mysql -uroot zabbix < /schema.sql
mysql -uroot zabbix < images.sql
mysql -uroot zabbix < data.sql - Zabbixの設定
/etc/zabbix/zabbix_server.conf に次の記述をします。
DBPassword=zabbixpass
/etc/httpd/conf.d/zabbix.conf に次の記述をします。
php_value date.timezone Asia/Tokyo
- Firewallの設定
/etc/sysconfig/iptables に次の記述をして、iptablesを再起動します。
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT - SELinuxの設定
setsebool -P httpd_can_network_connect 1
- 起動
service zabbix-server start
http://localhost/zabbix にアクセスして、初期セットアップを行います。
service zabbix-agent start
service httpd start
初期管理ユーザ名/パスワードは Admin / zabbix です。
GitLabをインストールする
Ryuzeeさんのブログで公開されていますが、うまくいかなかったので自分なりの遣り方でインストールした方法を記録します。
http://www.ryuzee.com/contents/blog/5779
環境
手順
環境設定
- epelとremiのリポジトリを追加
epelはリリース番号が変わっているかもしれないので、実行できない場合は最新のリリース番号を調べてください。rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
- 必要なパッケージの追加
yum install -y gettext rpm-build httpd-devel libcurl-devel gdbm-devel libyaml-devel mysql-server mysql-devel git python-devel python-pip redis libicu libicu-devel postfix ruby gcc-c++ libxml2 libxml2-devel libxslt libxslt-devel pip-python install pygments
- サービスの追加
chkconfig --level 2345 redis on
chkconfig --level 2345 mysqld on
chkconfig --level 2345 httpd on
service redis start
service mysqld start
service httpd start - Rubyのインストール
githubからマスターブランチをインストールしたら2.0RCでした。Rubyのビルドにrubyがいるのであらかじめ1.8.xをインストールしておいて、ビルドが終わったら古いバージョンをアンインストールします。
git clone https://github.com/ruby/ruby.git
cd ruby
autoconf
./configure
make
make install
rpm -e --nodeps ruby
ln -s /usr/local/bin/* /usr/bin - Bundlerのインストール
これを書いてる時点でBundlerをインストールするとバージョンが1.2.3になりますが、Ruby2.0をインストールした場合は1.3でなければ動かないので、バージョンを指定する必要があります。最新版はgithubなどで調べてください。
https://github.com/carlhuda/bundler/
gem install bundler --version '1.3.0.pre.7'
- ファイヤーウォールを有効にしている場合は、ポートを有効にする
vi /etc/sysconfig/iptables
次の内容を追記する
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT
ユーザ登録
useradd git
useradd gitlab
usermod -G git gitlab
chmod g+rx /home/git
passwd git
passwd gitlab
su - gitlab
vi ~/.ssh/config
以下の内容を記述する
Host localhost
HostName localhost
User git
IdentityFile ~/.ssh/gitadmin
chmod 0600 ~/.ssh/config
git config --global user.email "gitadmin@example.com"
git config --global user.name "gitadmin"
ssh localhost
ssh-keygen -t rsa -P "" -f ~/.ssh/gitadmin
exit
exit
Gitoliteのインストール
su - git
git clone git://github.com/sitaramc/gitolite
gitolite/install
gitolite/src/gitolite setup -pk .ssh/gitadmin.pub
vi /home/git/.gitolite.rc
次のように内容を変更する
UMASK => 0007,
exit
GitLabのインストール
su - gitlab
git clone https://github.com/gitlabhq/gitlabhq.git
cd gitlabhq/
bundle install --deployment --without development test postgres
cp config/database.yml.mysql config/database.yml
cp config/gitlab.yml.example config/gitlab.yml
bundle exec rake db:setup RAILS_ENV=production
bundle exec rake db:seed_fu RAILS_ENV=production
起動
bundle exec rails s -e production
デフォルトのログインIDとパスワードは次の通り。
login………admin@local.host
password……5iveL!fe
Ruby 2.0RCでbundlerがエラー出すときの対処
こちらのブログに書いてくれてました。
http://bmath.org/wordpress/?p=1845
最新版を取得するとき、githubから取ってくることが多いのですが、Rubyの安定版が1.9.3だけど、githubで取得したもののmasterブランチをそのままビルドすると2.0RCがインストールされます。
1.9.3に切り替えればいいだけなんだけど、せっかくなのでそのままにしていたのですが、bundler installを実行したときにエラーが発生しました。
gem install bundler でインストールされるのが 1.2.3 なのですが、Ruby2.0は対応しておらず、1.3に指定しないといけないそうです。これを書いてる時点での最新は1.3.0.pre.7ですが、現在の最新版はgithubで確認できます。
https://github.com/carlhuda/bundler/tree/v1.3.0.pre.7
gem install bundler --version '1.3.0.pre.7'
muninで他のマシンから情報を取得する
今までいくつか試してみたけど、すべて同じマシン(OS)内から取得していました。基本的に監視したいマシンにmunin-nodeを入れればいいだけですが、うまくいかなかった場合のメモ。
環境
- CentOS 6.2
- munin / munin-node 2.0.9 (epelからインストール)
設定内容
- マスター側
/etc/munin/munin.conf に[localhost] の書き方を真似て、対象のノードを指定します。 - ノード側
/etc/munin/munin-node.conf に allow , cidr_allow の設定を真似てマスタを指定します。
確認ポイント
- ログをみる
vi /var/log/munin-node/munin-node.log にエラーが出てないか確認します。
環境によってpostfixやlpstatの設定がないのでエラーが出ています。放置しても動くのですが、不要なら削除します。プラグインの解除は /etc/munin/plugins 以下のシンボリックリンクを削除するだけです。 - 情報が取得できているか確認する
ノードをインストールした環境からtelnetで接続できるか確認します。telnet localhost 4949
接続できたら、LISTでプラグイン一覧を取得して、FETCHで取得したいプラグインを指定します。FECH 情報を取得したいプラグイン名
情報の取得がうまく出来ない場合は、設定ファイルを見直してください。/etc/munin/plugins/プラグイン名 autoconf
- マスタからノードに接続できるか確認する
ファイヤーウォールの設定の問題があるので、ノード側の設定ファイル /etc/sysconfig/iptables に4949ポートのアクセスを許可する設定をいれて、iptablesを再起動してください。-A INPUT -m state --state NEW -m tcp -p tcp --dport 4949 -j ACCEPT
設定後、情報の取得を待つのが面倒なので、マスタが側から手動取得コマンドを実行します。実行ユーザmuninは環境によって置き換えます。sudo -u munin /usr/bin/munin-cron
- それでも動かない場合、取得するためのモジュールがそろっているか確認します。
たとえば、xxx-develがインストールされていないかとか、moduleがインストールされていない(有効になっていない)か、など。
muninでTomcatの情報を取得する
こちらを参考にさせてもらいました。
http://blog.ibsnet.co.jp/2012/02/munin-tomcat7.html
環境
手順
- 必要なパッケージのインストール
yum install perl-XML-Simple
- Tomcatにmuninからのアクセス権限を設定
$TOMCAT_HOME/conf/tomcat-user.conf に次を追記する。
<role rolename="manager-status">
<user username="munin" password="munin" roles="manager-status"/> - Tomcatにアクセスできるか確認する
curl http://munin:munin@127.0.0.1:8080/manager/status?XML=true
- Tomcatへのアクセス設定
/etc/munin/plugin-conf.d/munin-node に次の追記する。
[tomcat*]
env.host 127.0.01
env.port 8080
env.request /manager/status?XML=true
env.user munin
env.password munin
env.timeout 30
env.connector http-bio-8080 - プラグインの追加
ln -s /usr/share/munin/plugins/tomcat_ /etc/munin/plugins/
ln -s /usr/share/munin/plugins/tomcat_jvm /etc/munin/plugins/
ln -s /usr/share/munin/plugins/tomcat_threads /etc/munin/plugins/
ln -s /usr/share/munin/plugins/tomcat_volume /etc/munin/plugins/ - munin-nodeとTomcatを再起動する
muninでMySQLの情報を取得する
次の三つを参考にさせてもらいました。一つ目は基本の手順、二つ目はinnodbとか他の情報を取得できるプラグインの追加手順、三つ目も別のプラグインの追加手順がありました。
http://t.nzk.me/entry/2012/12/16/005311
環境
前提
innodbの情報を取得するので、MySQLは5.5系です。CentOSのベースリポジトリにあるのは5.1系なので、remiから取得します。
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install --enablerepo=remi -y mysql mysql-server mysql-devel
chkconfig mysqld on
service mysqld start
手順
- 必要なパッケージをインストールする
yum install --enablerepo=remi -y mysql-devel
yum install -y --enablerepo=epel perl-IPC-ShareLite perl-Cache-Cache perl-Cache perl-DBD-Mysql - プラグインを追加する
ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/
ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/
ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/
ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_commands
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_bpool
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_io
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_log
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_tnx
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_select_types
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_table_locks
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_connections
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_slow
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_network_traffic
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_qcache
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_qcache_mem - mysqlにmuninからの監視権限を設定する
たとえば次の通り。もしmysql_bytes、mysql_querysだけなら、特定のスキーマに対してselect権限をつけるだけでよい。grant all on *.* to munin@localhost identified by 'munin';
- munin nodeからmysqlに接続する設定をする
/etc/munin/plugin-conf.d/munin-node ファイルに次の記述を追加する。[mysql*]
env.mysqlopts -umunin --password=munin
env.mysqlconnection DBI:mysql:mysql;host=localhost;port=3306
env.mysqluser munin
env.mysqlpassword munin - munin nodeを再起動する
service munin-node restart
MySQLは再起動しなくていいけど、情報取得に少し時間がかかります。
muninでhttpdの情報を取得する
こちらを参考にしました。
環境
手順
- シンボリックリンクでプラグインを追加する
ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/ ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/ ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/
- munin nodeを再起動する
service munin-node restart
- httpdにmod_statusの設定をする
/etc/httpd/conf.d/status.conf を作成して、次の内容を記述する。<IfModule mod_status.c> ExtendedStatus On <Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</IfModule> - httpdの設定の確認をして、再起動する
service httpd graceful
service httpd restart - munin nodeが情報を取得できているか確認する
wget -q -O - http://127.0.0.1/server-status/?auto