Created
May 9, 2011 21:34
-
-
Save tobsn/963466 to your computer and use it in GitHub Desktop.
setting up a db template on rackspace cloud debian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. system upgrade (lenny to squeeze) | |
================ | |
apt-get update | |
apt-get upgrade | |
// keep old configs - hit [enter] | |
nano /etc/apt/source.list | |
// replace lenny with squeeze | |
apt-get update | |
apt-get upgrade | |
// keep old - keep hitting [enter] | |
apt-get dist-upgrade | |
// keep old - keep hitting [enter] | |
shutdown -r now | |
// making sure everything works | |
// box should come back within 30 sec | |
unset HISTFILE | |
rm .bash_history | |
echo "unset HISTFILE" >> .profile | |
// this turns off the bash history | |
echo "vm.swappiness=0" >> /etc/sysctl.conf | |
// turn off swappiness | |
nano /etc/rsyslog.conf | |
// comment out all rules like: | |
#auth,authpriv.* -/var/log/auth.log | |
#*.*;auth,authpriv.none -/var/log/syslog | |
#cron.* -/var/log/cron.log | |
#daemon.* -/var/log/daemon.log | |
#kern.* -/var/log/kern.log | |
#lpr.* -/var/log/lpr.log | |
#mail.* -/var/log/mail.log | |
#user.* -/var/log/user.log | |
// all the way down to the end of the file | |
// but leave the very last block "daemon.*;mail.*; and following lines untouched | |
// also the a bit further up from the last line *.emerge * | |
mv /etc/cron.daily/logrotate /etc/cron.hourly/ | |
// move the daily logrotate to hourly | |
nano /etc/logrotate.conf | |
// change "weekly" to "daily" | |
// change "rotate 4" to "rotate 0" | |
// add the line "shred" and another line "size 0k" after "#compress" | |
// in the "wtmp" and "btmp" config block comment out "monthly" and "rotate 1" | |
// now open all log rotate configs within /etc/logrotate.d/ and comment out | |
// every line that says daily, monthly, yearly, compress, rotate or size | |
/etc/init.d/cron restart | |
nano /etc/default/rsyslog | |
// change "-c4" to "-m 0" | |
nano /etc/ssh/sshd_config | |
// change default listen Port from 22 to something else for example 222 | |
2. installing mongodb | |
===================== | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 | |
nano /etc/apt/source.list | |
// add following line to the bottom | |
// deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen | |
// use "ubuntu-upstart" for ubuntu | |
apt-get update | |
apt-get install mongodb-10gen | |
ps aux | grep mongodb | |
// should show a running mongodb process | |
/etc/init.d/mongodb stop | |
// turn off mongodb for reconfigure | |
nano /etc/mongodb.conf | |
// change the following: | |
logpath = /dev/null | |
logappend = false | |
// comment out following if in use: | |
#port | |
#bind_ip | |
nano /etc/init.d/mongodb | |
// open the init script and add the following after ENABLE_MONGODB=yes | |
IP=`ifconfig | grep 'inet addr:10' | cut -d: -f2 | cut -d ' ' -f1` | |
// change LOGPATH into /dev/null | |
// and change the following line: | |
DAEMON_OPTS=${DAEMON_OPTS:-"--dbpath $DATA --logpath $LOGFILE run"} | |
// into this: | |
DAEMON_OPTS=${DAEMON_OPTS:-"--bind_ip $IP --shardsvr --replSet shard1 --dbpath $DATA --logpath $LOGFILE run"} | |
// remember that the replSet name is the only hardcoded variable that | |
// has to be the same within all replica set mongodb instances within a shard! | |
// you need to set this variable by hand - there is literally no way to feed it | |
// into the config without adding meta data on startup or server managing scripts | |
// IMPORTANT: this single variable has to be manually set for reach replica set! | |
/etc/init.d/mongodb start | |
ps aux | grep mongodb | |
// should look like this: | |
// /usr/bin/mongod --bind_ip 10.177.167.55 --shardsvr --replSet shard1 --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongodb.log run --config /etc/mongodb.conf | |
3. installing redis | |
=================== | |
nano /etc/apt/source.list | |
// add following lines | |
deb http://packages.dotdeb.org stable all | |
deb-src http://packages.dotdeb.org stable all | |
// and save | |
wget -q -O - http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add - | |
// add dotdeb gpg key | |
apt-get update | |
apt-get install redis-server | |
nano /etc/logrotate.d/redis-server | |
// comment out every line that says daily, monthly, yearly, compress, rotate or size | |
// looks like this: | |
/var/log/redis/*.log { | |
# weekly | |
missingok | |
copytruncate | |
# rotate 12 | |
# compress | |
notifempty | |
} | |
// and save | |
nano /etc/init.d/redis-config | |
// add following lines after PIDFILE variable | |
IP=`ifconfig | grep 'inet addr:10' | cut -d: -f2 | cut -d ' ' -f1` | |
sed -i "s/127.0.0.1/$IP/g" /etc/redis/redis.conf | |
// and add the following line inside the start block after the "fi" and before ";;" | |
sed -i "s/$IP/127.0.0.1/g" /etc/redis/redis.conf | |
// this will change the local 127.0.0.1 bind ip to the local ip inside the redis.config file | |
// and after starting it change it back so the script works for the next restart (even after cloning the image) | |
/etc/init.d/redis-server restart | |
4. install memcached | |
==================== | |
apt-get install memcached | |
nano /etc/memcached.conf | |
// comment out -l 127.0.0.1 to: | |
#-l 127.0.0.1 | |
nano /usr/share/memcached/scripts/start-memcached | |
// add the following line after "my $params;…" line | |
my $ip = `ifconfig | grep 'inet addr:10' | cut -d: -f2 | cut -d ' ' -f1`; | |
// also add the following line after "push @$params, …" and before "$params = join "", @$params;" | |
push @$params, "-l ", $ip; | |
/etc/init.d/memcached restart | |
5. final | |
======== | |
shutdown -r now | |
// make sure (ps aux or ps -HAf) when server comes back mongodb and memcached are running on the internal ip | |
// (-l for memcache and bind_ip for mongodb) | |
// if memcached is not showing the line restart memcached and shutdown -r now again | |
// it should now definitely show the -l param in the process |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment