Top > Installation Guide > CentOS5+Apache+mod_proxy_balancer+Mongrel
Installation Guide (CentOS5+Apache+mod_proxy_balancer+Mongrel)
Version
This document applies to Rubricks-0.6.x
Install CentOS 5.0
IP Address : 192.168.0.10 Gateway : 192.168.0.254 Host Name : rubricks Package Group : Minimal
Disable SELinux
vi /etc/selinux/config ================================================================ (abbr) SELINUX=disabled (abbr) ================================================================
Turn off unused daemons
chkconfig haldaemon off chkconfig ip6tables off chkconfig iptables off chkconfig kudzu off chkconfig mcstrans off chkconfig messagebus off chkconfig netfs off chkconfig restorecond off chkconfig xfs off
RPM Update
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 yum -y update yum -y install crontabs logrotate lsof sudo telnet unzip vixie-cron wget which zip shutdown -r now
Add yum-repository
Caution'''
The RPMs at repos.u-jp.com are not official packages of CentOS.
So it's good for the trial, but we don't recommend to use for release.
vi /etc/yum.repos.d/u-jp.repo ================================================================ [u-jp] name=CentOS-$releasever - u-jp baseurl=http://repos.u-jp.com/$basearch/ enabled=1 gpgcheck=0 ================================================================
Install and Configure MySQL
yum -y install mysql mysql-server perl-DBI perl-DBD-MySQL
vi /etc/my.cnf
================================================================
[mysqld_safe]
pid-file = /var/lib/mysql/mysqld.pid
[mysqld]
user = mysql
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
datadir = /var/lib/mysql/data
default-character-set = utf8
log = /var/log/mysql/mysqld.log
log-bin = /var/log/mysql/update-bin
expire_logs_days = 7
log-slow-queries = /var/log/mysql/slow_query.log
long_query_time = 1
max_allowed_packet = 24M
thread_concurrency = 8
max_connections = 200
thread_cache_size = 200
table_cache = 1024
query_cache_type = 1
query_cache_size = 16M
join_buffer_size = 256K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
sort_buffer_size = 512K
key_buffer = 8M
skip-bdb
bdb_cache_size = 8M
max_heap_table_size = 16M
tmp_table_size = 16M
innodb_data_home_dir = /var/lib/mysql/data
innodb_data_file_path = ibdata1:128M:autoextend
innodb_log_group_home_dir = /var/log/mysql_innodb/
innodb_log_arch_dir = /var/log/mysql_innodb/
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 8M
innodb_log_file_size = 128M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
innodb_file_per_table
[client]
user = root
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set = utf8
[mysql]
user = root
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set = utf8
no-auto-rehash
safe-updates
[mysqladmin]
user = root
socket = /var/lib/mysql/mysql.sock
default-character-set = utf8
[mysqldump]
default-character-set = utf8
max_allowed_packet = 24M
quick
[mysqlhotcopy]
interactive-timeout
================================================================
mkdir /var/log/{mysql,mysql_innodb}
chown mysql.mysql /var/log/{mysql,mysql_innodb}
chmod 700 /var/log/{mysql,mysql_innodb}
mysql_install_db --defaults-file=/etc/my.cnf
chkconfig --level 2345 mysqld on
service mysqld start
mysql
mysql> REVOKE GRANT OPTION on *.* from ''@localhost;
mysql> DROP USER ''@rubricks;
mysql> DROP USER ''@localhost;
mysql> DROP DATABASE test;
mysql> CREATE DATABASE rubricks;
mysql> GRANT ALL ON rubricks.* TO rubricks@localhost;
mysql> EXIT
Install and Configure memcached
yum -y install repcached libevent vi /etc/memcached.conf ================================================================ PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS="" ================================================================ chkconfig --level 2345 memcached on service memcached start
Install and Configure Apache
yum -y install httpd apr apr-util mailcap postgresql-libs
vi /etc/httpd/conf/httpd.conf
================================================================
LoadModule alias_module modules/mod_alias.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
LoadModule expires_module modules/mod_expires.so
LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
ServerRoot /etc/httpd
DocumentRoot /var/www/html
PidFile /var/run/httpd.pid
User apache
Group apache
ServerName 192.168.0.10
Listen 80
Listen 8000
ServerSignature Off
ServerTokens Prod
DirectoryIndex index.html
HostnameLookups Off
TypesConfig /etc/mime.types
DefaultType text/plain
AddDefaultCharset utf-8
<Directory />
Options None
AllowOverride None
Deny from all
</Directory>
Timeout 300
KeepAlive On
MaxKeepAliveRequests 10000
KeepAliveTimeout 10
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 10000
ErrorLog /var/log/httpd/error.log
LogLevel error
LogFormat '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"' combined
CustomLog /var/log/httpd/access.log combined
#===[Setting for Static]=======================================================#
<VirtualHost localhost:8000>
ServerName localhost
DocumentRoot /var/mongrel/rubricks/public
RequestHeader unset If-None-Match
Header unset ETag
Header unset Vary
<Directory /var/mongrel/rubricks/public>
Options None
AllowOverride None
Allow from all
</Directory>
</VirtualHost>
#===[Setting for Deflate]======================================================#
FilterDeclare Compression CONTENT_SET
FilterProvider Compression DEFLATE Content-Type $text/plain
FilterProvider Compression DEFLATE Content-Type $text/css
FilterProvider Compression DEFLATE Content-Type $application/xhtml
FilterProvider Compression DEFLATE Content-Type $application/xml
FilterProvider Compression DEFLATE Content-Type $application/xhtml+xml
FilterProvider Compression DEFLATE Content-Type $application/rss+xml
FilterProvider Compression DEFLATE Content-Type $application/atom+xml
FilterProvider Compression DEFLATE Content-Type $application/x-javascript
FilterProvider Compression DEFLATE Content-Type $image/svg+xml
FilterChain Compression
#===[Setting for Expires]======================================================#
ExpiresActive On
ExpiresByType text/css "access plus 30 days"
ExpiresByType application/x-javascript "access plus 30 days"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
#===[Setting for Rubricks]=====================================================#
<VirtualHost *:80>
ServerName 192.168.0.10
ProxyRequests Off
ProxyTimeout 3
ProxyPreserveHost On
ProxyPass /favicon.ico http://localhost:8000/favicon.ico
ProxyPass /heartbeat.html http://localhost:8000/heartbeat.html
ProxyPass /images/ http://localhost:8000/images/
ProxyPass /javascripts/ http://localhost:8000/javascripts/
ProxyPass /stylesheets/ http://localhost:8000/stylesheets/
ProxyPass / balancer://rubricks/ lbmethod=byrequests timeout=3
ProxyPassReverse / balancer://rubricks/
<Location />
Options None
AllowOverride None
Allow from all
</Location>
<Proxy balancer://rubricks/>
RequestHeader unset If-None-Match
Header unset ETag
Header unset Vary
BalancerMember http://localhost:3000 loadfactor=1 keepalive=on retry=5
BalancerMember http://localhost:3001 loadfactor=1 keepalive=on retry=5
BalancerMember http://localhost:3002 loadfactor=1 keepalive=on retry=5
BalancerMember http://localhost:3003 loadfactor=1 keepalive=on retry=5
BalancerMember http://localhost:3004 loadfactor=1 keepalive=on retry=5
</Proxy>
</VirtualHost>
================================================================
chown -R apache.apache /var/www/html
chmod 700 /var/www/{cgi-bin,error,html,icons}
chkconfig --level 2345 httpd on
service httpd start
Install and Configure Ruby/Mongrel
yum -y install ruby ruby-docs ruby-irb ruby-libs ruby-rdoc ruby-ri yum -y install rubygems rake daemons gem_plugin fastthread cgi_multipart_eof_fix mongrel mongrel_cluster vi /etc/mongrel/mongrel.conf ================================================================ --- address : 0.0.0.0 config_script : cwd : /var/mongrel/rubricks debug : false environment : production group : mongrel log_file : /var/log/mongrel/mongrel.log mime_map : num_procs : pid_file : tmp/pids/mongrel.pid port : 3000 prefix : user : mongrel servers : 5 timeout : 0 ================================================================
Setup Rubricks
wget http://rubyforge.org/frs/download.php/xxxxx/rubricks-0.X.X.tar.gz
tar -zxf rubricks-0.X.X.tar.gz -C /var/mongrel/
chmod 701 /var/mongrel
chown -R mongrel.mongrel /var/mongrel/rubricks
cp /var/mongrel/rubricks/config/sample1_environment.rb /var/mongrel/rubricks/config/environment.rb
cp /var/mongrel/rubricks/config/sample1_database.yml /var/mongrel/rubricks/config/database.yml
cp /var/mongrel/rubricks/config/sample1_memcached.yml /var/mongrel/rubricks/config/memcached.yml
vi /var/mongrel/rubricks/config/environment.rb
================================================================
(省略)
Rails::Initializer.run do |config|
config.frameworks -= [:action_web_service]
config.load_paths += [File.join(RAILS_ROOT, 'tmp', 'components')]
config.log_level = :info
config.log_path = "/var/log/mongrel/#{RAILS_ENV}.log"
config.action_controller.session_store = :mem_cache_store
end
(省略)
ENV['RUBRICKS_SERVER_CONTROL'] = 'true'
================================================================
vi /var/mongrel/rubricks/config/database.yml
================================================================
common: &common
adapter: mysql
host: localhost
socket: /var/lib/mysql/mysql.sock
username: rubricks
password:
encoding: utf8
development:
database: rubricks
<<: *common
test:
database: rubricks
<<: *common
production:
database: rubricks
<<: *common
================================================================
vi /var/mongrel/rubricks/config/memcached.yml
================================================================
session:
expires: '6h'
options:
multithread: false
namespace: 'rubricks'
readonly: false
servers: ['localhost:11211']
================================================================
cd /var/mongrel/rubricks
export RAILS_ENV=production
rake db:migrate
chown -R mongrel.mongrel /var/mongrel/rubricks
chkconfig --level 2345 mongrel_rubricks on
service mongrel_rubricks start
Start Rubricks
Access 'http://192.168.0.10/' on your browser and get the Rubricks top page.
Login as administrator, account name and password is follows.
| account name | 'admin' |
| password | 'pass' |
