

|
Valid XHTML v1.0
Author Profile
Top Authors
Log In to set widget preferences
| Author | # |
|---|---|
|
185 |
|
148 |
Anonymous User
|
49 |
|
28 |
Kimberly Hieber
|
27 |
|
23 |
Note: some conversations may be proxied or secured, thereby causing # differences
Subscribe
Partners
Recent
Tags
Log In to set widget preferences
Recent
Log In to set widget preferences
Most Active
Log In to set widget preferences
Popular
Log In to set widget preferences
|
|
Setting up and Configuring a Platform Server
by Akif on 2008-09-25 09:41 PM read 284 times |
Get the source code from:
ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz
Unzip using:
tar -zxvpf ruby-1.8.6.tar.gz
Read the README for instructions on compiling. These should be:
./configure
make
make install
Download rubygems:
wget http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz
tar --zxvpf rubygems-1.3.0.tgz
cd rubygems-1.3.0
Try:
ruby setup.rb
If you get a zlib error message then try the following:
yum install zlib zlib-devel
cd /usr/local/src/ruby-1.8.6/ext/zlib/
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
make
make install
cd /usr/local/src/rubygems-1.3.0/
Try again:
ruby setup.rb
If this doesn't work then try the following:
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
Install rails
gem install rails --include-dependencies
gem install mongrel
gem install mongrel_cluster
Install C++ compiler
yum install gcc-c++
Install htmldoc
wget http://ftp.easysw.com/pub/htmldoc/snapshots/htmldoc-1.9.x-r1571.tar.gz
tar -zxvpf htmldoc-1.9.x-r1571.tar.gz
cd htmldoc-1.9.x-r1571
./configure
make
make install
This may give an error mentioning that flex is required. If so download and install flex as follows:
wget http://prdownloads.sourceforge.net/flex/flex-2.5.35.tar.gz
tar zxvf flex-2.5.35.tar.gz
cd flex-2.5.35.tar.gz
./configure
make
make check
make install
Install byacc (Pre-requisite for monit)
yum install byacc
Install monit (This requires flex and yacc, as listed above, to be installed):
wget http://tildeslash.com/monit/dist/monit-4.10.1.tar.gz
tar zxvf monit-4.10.1.tar.gz
cd monit-4.10.1.tar.gz
./configure --without-ssl
make
make install
Copy the /usr/local/etc/monitrc file from 1.bsgplatform.com (72.249.21.180) to the server being setup
Modify monitrc accordingly.
Edit the /etc/inittab file and add the following statement
mo:2345:respawn:/usr/local/bin/monit -Ic /usr/local/etc/monitrc
Use telinit q to start up monit initially.
Use ps afx to check that monit is running with the -Ic parameters.
start monit:
/usr/local/bin/monit
stop monit:
/usr/local/bin/monit quit
Check the results in monit.log
Install memcached (Requires libevent so first install that)
wget http://www.monkey.org/~provos/libevent-1.4.8-stable.tar.gz
tar -xvf libevent-1.4.8-stable.tar.gz
cd libevent-1.4.8-stable
./configure
make
make install
make verify
Now install memcahced:
wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar -xvf memcached-1.2.6.tar.gz
cd memcached-1.2.6
./configure
make
make install
ln -s /usr/local/lib/libevent-1.4.so.2 /lib/libevent-1.4.so.2
Run memcached:
memcached -d -u root -m 512 127.0.0.1 -p 11211
Check that memcached is running:
ps -ef | grep memcached
This should list the memcached process with the parameters listed above. You can also test it by keying in:
telnet localhost 11211
If it connects then memcached is running properly. Enter "quit" to exit out of the telnet session.
Kill memcached process:
killall memcached
Install mysql gem:
yum install-mysql-devel
gem install mysql --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql
Install openssl
cd /usr/local/src
wget http://www.openssl.org/source/openssl-0.9.8i.tar.gz
tar xvf openssl-0.9.8i.tar.gz
cd openssl-0.9.8i
./configure
make
make install
This will install openssl but ruby then needs to be configured as follows:
cd /usr/local/scr/ruby-1.8.6/ext/openssl
ruby extconf.rb
cd ../..
make
make install
Install hpricot gem
gem install hpricot
Install
Install rfacebook gem
gem install rfacebook
Install ezcrypto
gem install ezcrypto
Setup MySQL to allow remote connections to the database as follows.
On the MySQL Server:
Edit the /etc/my.cnf file to set the mysqld section as follows.
[mysqld]
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/lib/mysql/mysql.sock
port=3306
basedir=/usr
datadir=/var/lib/mysql
bind-address=72.249.74.249
Where the bind-address is the ip address of this MySQL server machine.
/etc/init.d/mysqld restart
Then go to mysql:
mysql -u root -p <password>
use mysql
Run the following commands specifying the remote ip address and each database that it needs to access.
update db set Host='<remote host ip address>' where Db='<db_name>';
update user set Host='<remote host ip address>' where user='root';
flush privileges
If port 3306 is not open you will need to open it up using iptables using:
iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
You can now test the remote connection using telnet and mysql as follows.
mysql -u root -h <mysql server ip address> -p
telnet <mysql server ip address> 3306
Add the following line to /usr/local/bin/mongrel_rails
ENV['PATH'] = "#{ENV['PATH']}:/usr/local/bin";
You may need to insert the following row for each mysql database that needs to be accessed (This example uses the service_user_test database):
insert into db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv, Create_view_priv,
Show_view_priv, Create_routine_priv, Alter_routine_priv, Execute_priv) values ('72.249.21.162', 'service_user_test', 'root', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y')
Also ensure that in the mysql database the user table has entries for localhost and the remote host and all the privieleges are set to yes. The following statements can be used for this.
update user set Select_priv = 'Y, Insert_priv = 'Y', Update_priv = 'Y', Delete_priv = 'Y', Create_priv = 'Y', Drop_priv = 'Y', Reload_priv = 'Y', Shutdown_priv = 'Y', Process_priv = 'Y', File_priv = 'Y', Grant_priv = 'Y', References_priv = 'Y', Index_priv = 'Y', Alter_priv = 'Y', Show_db_priv = 'Y', Super_priv = 'Y', Create_tmp_table_priv = 'Y', Lock_tables_priv = 'Y', Execute_priv = 'Y', Repl_slave_priv = 'Y', Repl_client_priv = 'Y', Create_view_priv = 'Y', Show_view_priv = 'Y', Create_routine_priv = 'Y', Alter_routine_priv = 'Y', Create_user_priv = 'Y' where host = 'localhost';
update user set Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'Y', Delete_priv = 'Y', Create_priv = 'Y', Drop_priv = 'Y', Reload_priv = 'Y', Shutdown_priv = 'Y', Process_priv = 'Y', File_priv = 'Y', Grant_priv = 'Y', References_priv = 'Y', Index_priv = 'Y', Alter_priv = 'Y', Show_db_priv = 'Y', Super_priv = 'Y', Create_tmp_table_priv = 'Y', Lock_tables_priv = 'Y', Execute_priv = 'Y', Repl_slave_priv = 'Y', Repl_client_priv = 'Y', Create_view_priv = 'Y', Show_view_priv = 'Y', Create_routine_priv = 'Y', Alter_routine_priv = 'Y', Create_user_priv = 'Y' where host = '72.249.74.249'
During the remote MySQL setup the following error may be encountered when connecting to mysql from the command prompt with mysql -uroot -p
Access denied for user 'root'@localhost
This can be remedied by resetting the password in the user table. This is detailed at http://anojrs.blogspot.com/2007/11/access-denied-for-user-rootlocalhost.htm
mysqld --skip-grant-tablesmysql -u root mysqlUPDATE user SET Password=PASSWORD('my_password') where USER='root';FLUSH PRIVILEGES;/etc/init.d/mysql restart
This should reset the password.
Setting up MySQL Master/Slave Replication
This section provides details on setting up master/slave replication for MySQL. The example here uses the following servers which are the standard test database servers for platform services.
Master (2.bsgplatform.com) ip address: 72.249.74.249
Slave (3.bsgplatform.com) ip address: 72.249.21.162
The service_user_test database will be replicated.
First take a backup of the master database using:
mysqldump -uroot -p --opt --single_transaction --database service_user_test > service_user_test_2008_10_08.sql
Create a new MySQL user called "replicator" and allow the slave to connect to it by running the following on the master.
grant replication slave on *.* to 'replicator'@'72.249.21.162' identified by 'slave';
On the Master machine edit the /etc/my.cnf file so that the mysqld section is set as follows. The last four lines (from log-bin) have been added for replication. The rest of the lines should be there already.
[mysqld]
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/lib/mysql/mysql.sock
port=3306
basedir=/usr
datadir=/var/lib/mysql
bind-address=72.249.74.249
log-bin=mysql-bin
server-id=2
innodb_flush_log_at_trx_commit=1
sync_binlog=1
Now restart MySQL
/etc/init.d/mysqld restart
If mysql fails to restart then get the mysql process ids and kill them. This can be done as follows.
ps -ef | grep mysql
There should be two processes running mysqld_safe and mysqld. Kill them both using
kill -9 <pid>
On the Slave machine edit the /etc/my.cnf file and add the following line to the mysqld section.
server-id=3
Now take a backup of the Master databases that need to be replicated. This is done be stopping execution of statements on the master and recording the position of the log that the slave will use to perform replication.
flush tables with read lock;
show master status;
Record the "File" and "Position" values displayed by the command listed above. Keep this shell running so statements are blocked and open up a new sql window to perform a backup as follows.
mysqldump -uroot -p --databases service_content_test service_org_test service_provision_test service_pubsub_test service_user_test --lock-all-tables > master_2008_10_09.sql
On the slave run teh following statement. this will create the master.info file which is used by MySQL to configre the slave options (Note that if options are set and changed in my.cnf these changes will not be used, instead use the change master command below)
CHANGE MASTER TO
MASTER_HOST='72.249.74.249',
MASTER_USER='replicator',
MASTER_PASSWORD='slave',
MASTER_LOG_FILE='mysql-bin.000005',
MASTER_LOG_POS=3323789;
Now on the slave start mysql with the --skip-slave-start option
/etc/init.d/mysqld start --skip-slave-start
Copy the backup file from the master to the slave
scp root@72.249.74.249:/var/www/apps/database_backups/master_2008_10_09.sql master_2008_10_09.sql
Load the backup file into the slave
mysql -v -uroot -p < master_2008_10_09.sql
Now start the slave by keying at the sql prompt:
start slave
Check the status of the slave by:
show slave status
The Slave_IO_Running and SLAVE_SQL_Running should both have values of "Yes"
Check the /var/log/mysqld.log for any errors. There may be errors due to databases that are in the master but not required to be replicated in the slave. To ensure that only the required databases are replicated and the slave keeps running add the following entries in the master and slave my.cnf files for databases that need to be replicated.
Master my.cnf
binlog-do-db=service_content_test
binlog-do-db=service_org_test
binlog-do-db=service_provision_test
binlog-do-db=service_provision_test
binlog-do-db=service_user_test
Slave my.cnf
replicate-do-db=service_content_test
replicate-do-db=service_org_test
replicate-do-db=service_provision_test
replicate-do-db=service_pubsub_test
replicate-do-db=service_user_test
Now restart mysqld on both the master and the slave
/etc/init.d/mysqld restart
Now check the status again on the slave.
show slave status
Also ensure that the master database server (72.249.74.249) has the correct version of rails installed. This is currently rails 2.1.1
gem install rails
The Pubsub Service needs the libxml-ruby gem version 0.5.4. Perform teh following steps to install it.
yum install libxml2
yum install libxml2-devel
gem install libxml-ruby -v=0.5.4
The User service needs the uuidtools gem. Install it using:
gem install uuidtools -v=1.0.2
Setup SSL and virtual hosts files accordingly. Details are available at:
http://www.akadia.com/services/ssh_test_certificate.html
No current tags
1 Reply
|
Log In to Reply |
39 Versions |
Log In to Copy |
Tell a Friend
|
Trackback URL: http://www.kalivo.com/trackback/1722-setting-up-and-configuring-a-platform-server
|
|
re: Setting up and Configuring a Platform Server
by Steve Elmore on 2008-10-14 04:05 PM read 19 times |
Well if it is this easy I would have done it myself!
Log In to Reply | Log In to Copy | Tell a Friend |
Trackback URL: http://www.kalivo.com/trackback/1775-re-setting-up-and-configuring-a-platform-server
