Difference between revisions of "Machine/Discovery One/Node"

From Sugar Labs
Jump to navigation Jump to search
m
 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
  
 
= Components =
 
= Components =
 
== Install Emacs ==
 
I just like it:)
 
 
apt-get install emacs
 
  
 
== Setup Network ==
 
== Setup Network ==
Line 40: Line 35:
 
  /etc/init.d/networking restart
 
  /etc/init.d/networking restart
  
== Install Database ==
+
== Install php server ==
  
 
===Install needed packages===
 
===Install needed packages===
  apt-get install mysql-client-5.0 mysql-server-5.0
+
  sudo apt-get install gettext
 +
 
 +
===Install required php modules===
 +
sudo pear config-set preferred_state beta
 +
sudo pear install Archive_Zip
 +
 
 +
===Create user to run scripts===
 +
sudo useradd -d /srv/activities activities
 +
 
 +
Make sure that all files in /srv/activities
 +
* has apache(web-data) user
 +
* ''activities'' group
 +
* group write access
 +
* umask is 002
 +
 
 +
===Switch to activities user===
 +
 
 +
sudo -i -u activities
 +
 
 +
===Checkout ASLO sources===
 +
 
 +
git clone git://git.sugarlabs.org/slo-activities/mainline.git ~
 +
git checkout production -b production
 +
 
 +
===Fetch external dependencies===
 +
 
 +
cd ~/site/vendors/
 +
svn co http://svn.mozilla.org/libs/product-details
 +
svn co http://svn.mozilla.org/libs/fizzypop.mozdev fizzypop
 +
svn co http://svn.mozilla.org/libs/phorms
 +
svn co http://svn.mozilla.org/libs/zxtm-api
 +
 
 +
 
 +
===Set up NFS mount points===
 +
Create directories
 +
mkdir -p ~/files
 +
mkdir -p ~/staging
 +
 
 +
Add the following lines to the end of `/etc/fstab'
 +
 
 +
sunjammer.sugarlabs.org:/srv/nfs/activities/files /srv/activities/files nfs rsize=8192,wsize=8192,timeo=14,intr
 +
sunjammer.sugarlabs.org:/srv/nfs/activities/staging /srv/activities/staging nfs rsize=8192,wsize=8192,timeo=14,intr
 +
 
 +
===First-time ASLO setup===
  
===Log Rotate===
+
Using ''~/aslo/config.php'' as template, setup ASLO settings in file ''~/site/app/config/config.php''. Template file was configured for ''dev'' environment, switch it to production by  setting ''SITE_STATE'' variable to ''production''.
/etc/logrotate.d/mysql-server
+
 
 +
Setup other env defines in file ''~/site/app/config/config-local.php''
 +
define('DEBUG', 0);
 +
define('DEV', false);
 +
define('QUERY_CACHE', true);
 +
 
 +
Create directories
 +
mkdir -p ~/site/app/tmp/cache/persistent
 +
mkdir -p ~/site/app/tmp/cache/models
 +
mkdir -p ~/site/app/tmp/cache/views
 +
mkdir -p ~/files/temp
 +
mkdir -p ~/files/extracted
 +
mkdir -p ~/data
 +
 
 +
Minify css/js stuff
 +
~/aslo/minify.py
 +
 
 +
Merge ASLO gettext strings
 +
~/aslo/po-compile.sh
 +
 
 +
===Crontab for activities user===
 +
 
 +
@hourly $HOME/aslo/cron/hourly
 +
# do not use @daily to make sure that we start job after aslo-proxy
 +
01 08 * * * $HOME/aslo/cron/daily
 +
 
 +
===Create vhost===
 +
vim /etc/apache2/sites-available/activities.sl.org
 
<pre>
 
<pre>
# - I put everything in one block and added sharedscripts, so that mysql gets 
+
<VirtualHost *:80 *:443>
#  flush-logs'd only once.  
+
        ServerName activities.sugarlabs.org
#   Else the binary logs would automatically increase by n times every day.  
+
        ServerAlias activities2.sugarlabs.org # for test/install
# - The error log is obsolete, messages go to syslog now.
+
        ServerAdmin webmaster@sugarlabs.org
/var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log {
+
 
        daily
+
        DocumentRoot /srv/activities/site/app/webroot
        rotate 7
+
 
        missingok
+
        LogFormat "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{HTTP_COOKIE}i\"" addons
        create 640 mysql adm
+
        CustomLog /srv/activities/data/access addons
        compress
+
        CustomLog /var/log/apache2/all-access.log vhost_combined
        sharedscripts
+
         #CustomLog /var/log/apache2/performance.log performance
         postrotate
+
</VirtualHost>
                test -x /usr/bin/mysqladmin || exit 0
 
 
                # If this fails, check debian.conf! 
 
                MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
 
                if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then
 
                  # Really no mysqld or rather a missing debian-sys-maint user?
 
                  # If this occurs and is not a error please report a bug.
 
                  if ps cax | grep -q mysqld; then
 
                    exit 1
 
                  fi 
 
                else
 
                  $MYADMIN flush-logs
 
                fi
 
        endscript
 
}
 
 
</pre>
 
</pre>
 
==== Turn off database by default ====
 
 
sudo update-rc.d -f mysql remove
 

Latest revision as of 12:24, 1 March 2010

ASLO Node

While discussing activities.sugarlabs.org maintainability with Dogi this afternoon, he suggested that instead of thinking about web, proxy, and database nodes we create a standard ALSO node which we can adopt and tune via configs.

Components

Setup Network

Set the IP address for the each nic

/etc/networks/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 10.0.0.101
        netmask 255.255.255.0
        network 10.0.0.0
        broadcast 10.0.0.255
        gateway 10.0.0.1

#auto eth1
iface eth1 inet static
        address 10.0.0.201
        netmask 255.255.255.0
        network 10.0.0.0
        broadcast 10.0.0.255
        gateway 10.0.0.1

restart the network

/etc/init.d/networking restart

Install php server

Install needed packages

sudo apt-get install gettext

Install required php modules

sudo pear config-set preferred_state beta 
sudo pear install Archive_Zip

Create user to run scripts

sudo useradd -d /srv/activities activities

Make sure that all files in /srv/activities

  • has apache(web-data) user
  • activities group
  • group write access
  • umask is 002

Switch to activities user

sudo -i -u activities

Checkout ASLO sources

git clone git://git.sugarlabs.org/slo-activities/mainline.git ~
git checkout production -b production

Fetch external dependencies

cd ~/site/vendors/
svn co http://svn.mozilla.org/libs/product-details
svn co http://svn.mozilla.org/libs/fizzypop.mozdev fizzypop
svn co http://svn.mozilla.org/libs/phorms
svn co http://svn.mozilla.org/libs/zxtm-api


Set up NFS mount points

Create directories

mkdir -p ~/files
mkdir -p ~/staging

Add the following lines to the end of `/etc/fstab'

sunjammer.sugarlabs.org:/srv/nfs/activities/files /srv/activities/files nfs rsize=8192,wsize=8192,timeo=14,intr
sunjammer.sugarlabs.org:/srv/nfs/activities/staging /srv/activities/staging nfs rsize=8192,wsize=8192,timeo=14,intr

First-time ASLO setup

Using ~/aslo/config.php as template, setup ASLO settings in file ~/site/app/config/config.php. Template file was configured for dev environment, switch it to production by setting SITE_STATE variable to production.

Setup other env defines in file ~/site/app/config/config-local.php

define('DEBUG', 0);
define('DEV', false);
define('QUERY_CACHE', true);

Create directories

mkdir -p ~/site/app/tmp/cache/persistent
mkdir -p ~/site/app/tmp/cache/models
mkdir -p ~/site/app/tmp/cache/views
mkdir -p ~/files/temp
mkdir -p ~/files/extracted
mkdir -p ~/data

Minify css/js stuff

~/aslo/minify.py

Merge ASLO gettext strings

~/aslo/po-compile.sh

Crontab for activities user

@hourly $HOME/aslo/cron/hourly
# do not use @daily to make sure that we start job after aslo-proxy
01 08 * * * $HOME/aslo/cron/daily

Create vhost

vim /etc/apache2/sites-available/activities.sl.org

<VirtualHost *:80 *:443>
        ServerName activities.sugarlabs.org
        ServerAlias activities2.sugarlabs.org # for test/install
        ServerAdmin webmaster@sugarlabs.org

        DocumentRoot /srv/activities/site/app/webroot

        LogFormat "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{HTTP_COOKIE}i\"" addons
        CustomLog /srv/activities/data/access addons
        CustomLog /var/log/apache2/all-access.log vhost_combined
        #CustomLog /var/log/apache2/performance.log performance
</VirtualHost>