Scalrを使ってみよう [3]
この記事は1年以上前に投稿されました。情報が古い可能性がありますので、ご注意ください。
Scalr 3.5のインストール
Installation を参照し、Scalr 3.5のインストールを行います。
なお、Installationにある通り、プライベートなScalr環境の構築は推奨されていないため、参考程度にとどめてください。
インストール先OSはUbuntu 11.10 server (64bit)とします。OSのインストール手順は省略します。
PHP5のインストール
Ubuntu 11.10 serverのPHP5は5.3.6 なのでそのまま利用可能です。
root@ubuntu:~# aptitude install php5 The following NEW packages will be installed: apache2-mpm-prefork{a} apache2-utils{a} apache2.2-bin{a} apache2.2-common{a} libapache2-mod-php5{a} libapr1{a} libaprutil1{a} libaprutil1-dbd-sqlite3{a} libaprutil1-ldap{a} libcap2{a} php5 php5-cli{a} php5-common{a} ssl-cert{a} 0 packages upgraded, 14 newly installed, 0 to remove and 0 not upgraded. Need to get 9,870 kB of archives. After unpacking 29.8 MB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
MySQLのインストール
MySQLのインストール時に、何度かMySQLのrootのパスワードの設定を求められますが、すべて空欄にしてください。
root@ubuntu:~# aptitude install mysql-server The following NEW packages will be installed: libdbd-mysql-perl{a} libdbi-perl{a} libhtml-template-perl{a} libmysqlclient16{a} libnet-daemon-perl{a} libplrpc-perl{a} mysql-client-5.1{a} mysql-client-core-5.1{a} mysql-common{a} mysql-server mysql-server-5.1{a} mysql-server-core-5.1{a} 0 packages upgraded, 12 newly installed, 0 to remove and 0 not upgraded. Need to get 23.8 MB of archives. After unpacking 61.0 MB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
その他パッケージのインストール
SSLやSNMP、BINDをインストールします。
root@ubuntu:~# aptitude install libssh2-1 libssh2-1-dev openssl snmp snmpd bind9 The following NEW packages will be installed: bind9 bind9utils{a} libperl5.12{a} libsensors4{a} libsnmp-base{a} libsnmp15{a} libssh2-1 libssh2-1-dev snmp snmpd 0 packages upgraded, 10 newly installed, 0 to remove and 0 not upgraded. Need to get 2,568 kB of archives. After unpacking 8,274 kB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
root@ubuntu:~# aptitude install gettext make The following NEW packages will be installed: gettext libcroco3{a} libgomp1{a} libunistring0{a} make 0 packages upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 2,001 kB of archives. After unpacking 6,500 kB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
PHP エクステンションのインストール
必要なエクステンションをインストールします。
なお Sockets, GetText, SimpleXML, mhash, pcntl, posix, dom, SOAP は組み込み済です。
root@ubuntu:~# aptitude install php5-mysql php5-curl php5-mcrypt php5-snmp curl mcrypt The following NEW packages will be installed: curl libcurl3{a} libmcrypt4{a} libmhash2{a} mcrypt php5-curl php5-mcrypt php5-mysql php5-snmp 0 packages upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 764 kB of archives. After unpacking 2,421 kB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
root@ubuntu:~# aptitude install php-pear libssh2-php The following NEW packages will be installed: autoconf{a} automake{a} autotools-dev{a} binutils{a} cpp{a} cpp-4.6{a} gcc{a} gcc-4.6{a} libc-dev-bin{a} libc6-dev{a} libltdl-dev{a} libltdl7{a} libmpc2{a} libmpfr4{a} libquadmath0{a} libssh2-php libssl-dev{a} libssl-doc{a} libtool{a} linux-libc-dev{a} m4{a} manpages-dev{a} php-pear php5-dev{a} shtool{a} zlib1g-dev{a} 0 packages upgraded, 26 newly installed, 0 to remove and 0 not upgraded. Need to get 26.0 MB of archives. After unpacking 82.0 MB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
pecl_httpはパッケージがないので、aptではなくpeclでインストールします。
root@ubuntu:~# aptitude install libcurl4-openssl-dev The following NEW packages will be installed: comerr-dev{a} krb5-multidev{a} libcurl4-openssl-dev libgssrpc4{a} libidn11-dev{a} libkadm5clnt-mit8{a} libkadm5srv-mit8{a} libkdb5-5{a} libkrb5-dev{a} libldap2-dev{a} pkg-config{a} 0 packages upgraded, 11 newly installed, 0 to remove and 0 not upgraded. Need to get 3,065 kB of archives. After unpacking 9,957 kB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
downloading pecl_http-1.7.4.tgz ... Starting to download pecl_http-1.7.4.tgz (174,503 bytes) .....................................done: 174,503 bytes 71 source files, building running: phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 whether to enable cURL HTTP requests; specify libcurl directory [yes] : whether to enable support for gzencoded/deflated message bodies; specify zlib directory [yes] : whether to enable response content type guessing; specify libmagic directory [no] : whether to depend on extensions which have been built shared [yes] : building in /tmp/pear/temp/pear-build-rootJvXqm1/pecl_http-1.7.4 : Installing '/usr/lib/php5/20090626/http.so' install ok: channel://pecl.php.net/pecl_http-1.7.4 configuration option "php_ini" is not set to php.ini location You should add "extension=http.so" to php.ini root@ubuntu:~#
rrdtool-phpもパッケージがないのでソースインストールします。
root@ubuntu:~# aptitude install librrd-dev rrdtool The following NEW packages will be installed: build-essential{a} debhelper{a} defoma{a} dpkg-dev{a} fakeroot{a} fontconfig{a} g++{a} g++-4.6{a} gir1.2-freedesktop{a} gir1.2-pango-1.0{a} html2text{a} intltool-debian{a} libalgorithm-diff-perl{a} libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a} libcairo-gobject2{a} libcairo-script-interpreter2{a} libcairo2-dev{a} libdatrie1{a} libdbi1{a} libdpkg-perl{a} libexpat1-dev{a} libfontconfig1-dev{a} libfontenc1{a} libfreetype6-dev{a} libglib2.0-bin{a} libglib2.0-data{a} libglib2.0-dev{a} libice-dev{a} libice6{a} libmail-sendmail-perl{a} libpango1.0-0{a} libpango1.0-dev{a} libpixman-1-dev{a} libpng12-dev{a} libpthread-stubs0{a} libpthread-stubs0-dev{a} librrd-dev librrd4{a} libsm-dev{a} libsm6{a} libstdc++6-4.6-dev{a} libsys-hostname-long-perl{a} libthai-data{a} libthai0{a} libx11-dev{a} libxau-dev{a} libxcb-render0-dev{a} libxcb-shm0-dev{a} libxcb1-dev{a} libxdmcp-dev{a} libxfont1{a} libxft-dev{a} libxft2{a} libxml2-dev{a} libxrender-dev{a} po-debconf{a} rrdtool ttf-dejavu{a} ttf-dejavu-extra{a} x-ttcidfont-conf{a} x11-common{a} x11proto-core-dev{a} x11proto-input-dev{a} x11proto-kb-dev{a} x11proto-render-dev{a} xfonts-encodings{a} xfonts-utils{a} xorg-sgml-doctools{a} xtrans-dev{a} 0 packages upgraded, 70 newly installed, 0 to remove and 0 not upgraded. Need to get 26.7 MB of archives. After unpacking 96.2 MB will be used. Do you want to continue? [Y/n/?] y : root@ubuntu:~#
root@ubuntu:~# wget http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz : root@ubuntu:~# tar xfz php_rrdtool.tar.gz root@ubuntu:~# mv rrdtool /usr/include/php5/ext/ root@ubuntu:~# cd /usr/include/php5/ext/rrdtool/ root@ubuntu:/usr/include/php5/ext/rrdtool# phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 root@ubuntu:/usr/include/php5/ext/rrdtool# ./configure --with-php-config=/usr/bin/php-config --with-rrdtool=/usr : root@ubuntu:/usr/include/php5/ext/rrdtool# make : root@ubuntu:/usr/include/php5/ext/rrdtool# make install Installing shared extensions: /usr/lib/php5/20090626/ root@ubuntu:/usr/include/php5/ext/rrdtool#
PHP設定ファイルにソースインストールしたエクステンションを追加します。
root@ubuntu:~# cp -a /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.orig root@ubuntu:~# cat >> /etc/php5/apache2/php.ini extension=http.so extension=rrdtool.so root@ubuntu:~# diff -u /etc/php5/apache2/php.ini.orig /etc/php5/apache2/php.ini --- /etc/php5/apache2/php.ini.orig 2012-06-14 03:18:05.000000000 +0900 +++ /etc/php5/apache2/php.ini 2012-07-10 16:07:00.446446719 +0900 @@ -1850,3 +1850,5 @@ ; Local Variables: ; tab-width: 4 ; End: +extension=http.so +extension=rrdtool.so root@ubuntu:~#
root@ubuntu:~# cp -a /etc/php5/cli/php.ini /etc/php5/cli/php.ini.orig root@ubuntu:~# cat >> /etc/php5/cli/php.ini extension=http.so extension=rrdtool.so root@ubuntu:~# diff -u /etc/php5/cli/php.ini.orig /etc/php5/cli/php.ini --- /etc/php5/cli/php.ini.orig 2012-06-14 03:18:05.000000000 +0900 +++ /etc/php5/cli/php.ini 2012-07-10 16:11:14.422427015 +0900 @@ -1850,3 +1850,5 @@ ; Local Variables: ; tab-width: 4 ; End: +extension=http.so +extension=rrdtool.so root@ubuntu:~#
mod_rewriteを有効にします。
root@ubuntu:~# a2enmod rewrite Enabling module rewrite. To activate the new configuration, you need to run: service apache2 restart root@ubuntu:~#
AllowOverrideをAllにします。
root@ubuntu:~# cp -a /etc/apache2/sites-available/default /etc/apache2/sites-available/default.orig root@ubuntu:~# vi /etc/apache2/sites-available/default root@ubuntu:~# diff -u /etc/apache2/sites-available/default.orig /etc/apache2/sites-available/default --- /etc/apache2/sites-available/default.orig 2012-02-15 01:35:18.000000000 +0900 +++ /etc/apache2/sites-available/default 2012-07-10 16:13:00.966444907 +0900 @@ -8,7 +8,7 @@ </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews - AllowOverride None + AllowOverride All Order allow,deny allow from all </Directory> root@ubuntu:~#
apacheを再起動します。
root@ubuntu:~# /etc/init.d/apache2 restart * Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ...done. root@ubuntu:~#
Scalr 3.5のインストール
アーカイブを展開して /var に設置します。
root@ubuntu:~# tar xfz scalr-3.5.r7704.tar.gz root@ubuntu:~# mv scalr-3.5.r7704 /var/scalr root@ubuntu:~# cd /var root@ubuntu:/var# chown -R root.root scalr root@ubuntu:/var# mv www www_old root@ubuntu:/var# ln -s /var/scalr/app/www root@ubuntu:/var# chmod -R a+rX www root@ubuntu:/var#
所有者、パーミッションの変更を行います。
root@ubuntu:~# chown -R www-data.www-data /var/scalr/app/cache root@ubuntu:~# chown -R www-data.www-data /var/scalr/app/cron/cron.pid root@ubuntu:~#
root@ubuntu:~# chmod -R 700 /var/scalr/app/cache root@ubuntu:~# chmod -R 700 /var/scalr/app/cron/cron.pid root@ubuntu:~#
root@ubuntu:~# chmod 777 /var/scalr/app/etc/.passwd root@ubuntu:~#
root@ubuntu:~# chown -R www-data.www-data /var/scalr/app/www root@ubuntu:~# chmod -R a+rX /var/scalr/app/www root@ubuntu:~#
MySQL 設定
Scalr 用のデータベースを作成し、初期データを取り込みます。
ただし、scalr-3.5.r7704.tar.gz に含まれているSQLファイルには間違いがあるため、取り込み前に修正を行います。
root@ubuntu:~# cd /var/scalr/ root@ubuntu:/var/scalr# wget https://github.com/Scalr/scalr/commit/357d0361df4e415fe40e86cc7a5ac1fa16b1b841.diff : root@ubuntu:/var/scalr# patch -p1 < 357d0361df4e415fe40e86cc7a5ac1fa16b1b841.diff patching file sql/scalr.sql root@ubuntu:/var/scalr#
root@ubuntu:/var/scalr# echo 'CREATE DATABASE scalr;' | mysql -u root root@ubuntu:/var/scalr# mysql -u root -D scalr < ./sql/scalr.sql root@ubuntu:/var/scalr#
なお、間違ったSQLファイルを取り込むと以下のエラーになります。
root@ubuntu:/var/scalr# mysql -u root -D scalr < ./sql/scalr.sql ERROR 1054 (42S22) at line 2222: Unknown column 'architecture' in 'field list' root@ubuntu:/var/scalr#
scalrユーザの権限とパスワードの設定を行います。
root@ubuntu:~# mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 41 Server version: 5.1.63-0ubuntu0.11.10.1 (Ubuntu) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> grant all privileges on scalr.* to 'scalr'@'%' identified by 'scalr'; Query OK, 0 rows affected (0.00 sec) mysql> use mysql; update user set password=password('scalrpwd') where user='scalr'; 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 Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye root@ubuntu:~#
今設定したscalrユーザとパスワードで設定ファイルを作成します。
root@ubuntu:~# cp -a /var/scalr/app/etc/config.ini-sample /var/scalr/app/etc/config.ini root@ubuntu:~# vi /var/scalr/app/etc/config.ini root@ubuntu:~# diff -u /var/scalr/app/etc/config.ini-sample /var/scalr/app/etc/config.ini --- /var/scalr/app/etc/config.ini-sample 2012-06-08 05:39:41.000000000 +0900 +++ /var/scalr/app/etc/config.ini 2012-07-10 17:01:18.750446168 +0900 @@ -3,4 +3,4 @@ host = "localhost" name = "scalr" user = "scalr" -pass = "" \ ファイル末尾に改行がありません +pass = "scalrpwd" root@ubuntu:~#
cron設定
rootのcrontabに設定します。
root@ubuntu:~# crontab -e root@ubuntu:~# grep -v ^# /var/spool/cron/crontabs/root */2 * * * * /usr/bin/php -q /var/scalr/app/cron-ng/cron.php --Poller * * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --Scheduler2 */10 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --MySQLMaintenance * * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --DNSManagerPoll 17 5 * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --RotateLogs */2 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --EBSManager */20 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --RolesQueue */5 * * * * /usr/bin/php -q /var/scalr/app/cron-ng/cron.php --DbMsrMaintenance */2 * * * * /usr/bin/php -q /var/scalr/app/cron-ng/cron.php --Scaling */5 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --DBQueueEvent */2 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --SzrMessaging */4 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --RDSMaintenance */2 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --BundleTasksManager * * * * * /usr/bin/php -q /var/scalr/app/cron-ng/cron.php --ScalarizrMessaging * * * * * /usr/bin/php -q /var/scalr/app/cron-ng/cron.php --MessagingQueue */2 * * * * /usr/bin/php -q /var/scalr/app/cron-ng/cron.php --DeployManager */2 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --UsageStatsPoller * * * * * /usr/bin/php -q /var/scalr/app/cron-ng/cron.php --SNMPStatsPoller root@ubuntu:~#
bind 設定
root@ubuntu:~# mkdir /etc/bind/client_zones root@ubuntu:~# touch /etc/bind/client_zones/zones.include root@ubuntu:~# chmod -R 777 /etc/bind/client_zones root@ubuntu:~# echo '#xxxx' > /etc/bind/client_zones/zones.include root@ubuntu:~# cp -a /etc/bind/named.conf /etc/bind/named.conf.orig root@ubuntu:~# vi /etc/bind/named.conf root@ubuntu:~# diff -u /etc/bind/named.conf.orig /etc/bind/named.conf --- /etc/bind/named.conf.orig 2012-06-06 00:51:00.000000000 +0900 +++ /etc/bind/named.conf 2012-07-10 17:20:02.986447194 +0900 @@ -9,3 +9,4 @@ include "/etc/bind/named.conf.options"; include "/etc/bind/named.conf.local"; include "/etc/bind/named.conf.default-zones"; +include "/etc/bind/client_zones/zones.include"; root@ubuntu:~#
root@ubuntu:~# /etc/init.d/bind9 restart * Stopping domain name service... bind9 ...done. * Starting domain name service... bind9 ...done. root@ubuntu:~#
動作確認
インストールが正常に完了していれば、http://localhost/ にアクセスすると、Scalrログイン画面が表示されます。ID:admin PW:adminでログインできるはずです。