Scaling down from MS to open source
We just moved a service that was running on the Microsoft stack (Windows Server 2008, .NET, MSSql Server, IIS) to an open source stack (Ubuntu Server, php, Codeigniter framework, apache2, postgres).
We now run the service on a cloud server with dual cpu and 256MB ram (Yes, that's megabytes).
The old server ran on dual core with 2GB of ram.
A four letter word can ruin your day
halt + Amazon EC2 + Instance Store = A bad day
I did a stupid thing while on vacation. Decided to clone an EC2 server and executed halt from commandline without checking to see if the server was using Instance Store. Whoops, Amazon showed the server as terminating...terminated... ahhhhh.
After having to rebuild the server while on vacation, I have learned a valuable lesson.
sendmail[2525]: My unqualified host name (servername) unknown
If you see these messages in your syslog, your sendmail is not configured correctly with the domain name. If you are sending from a fully qualified domain, add it to the local-host-names file. In Ubuntu, it would be /etc/mail/local-host-names. Make sure it reads something like this.
localhost
[domain.com]
[server name]
Now in the /etc/hosts, make sure it reads the following.
127.0.0.1 [domain.com] [server name] localhost
...
Then
sudo /etc/init.d/sendmail restart
and the error should not continue filling the syslog.
Fail2ban does not start after reboot
This problem was identified with the following configuration:
Ubuntu 8.04
fail2ban
Problem: After fail2ban install, everything works fine, but after reboot fail2ban does not start. Manual /etc/init.d/fail2ban restart fails also.
Cause: Fail2ban looks for fail2ban.sock in
/var/run/fail2ban/
During reboot, that directory is removed. Fail2ban assumes it is there and fails on restart.
Solution: Make sure the directory exists during start of fail2ban. Edit the init.d for fail2ban to fix this.
sudo vi /etc/init.d/fail2ban
Find the do_start option.
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_status && return 1
if [ -e "$SOCKFILE" ]; then
log_failure_msg "Socket file $SOCKFILE is present"
[ "$1" = "force-start" ] \
&& log_success_msg "Starting anyway as requested" \
|| return 2
DAEMON_ARGS="$DAEMON_ARGS -x"
fi
start-stop-daemon --start --quiet --chuid root --exec $DAEMON -- \
$DAEMON_ARGS start > /dev/null\
|| return 2
return 0
}
Add the following after the if statement.
# Assure that /var/run/fail2ban exists
[ -d /var/run/fail2ban ] || mkdir -p /var/run/fail2ban
Finally, it should look like this
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_status && return 1
if [ -e "$SOCKFILE" ]; then
log_failure_msg "Socket file $SOCKFILE is present"
[ "$1" = "force-start" ] \
&& log_success_msg "Starting anyway as requested" \
|| return 2
DAEMON_ARGS="$DAEMON_ARGS -x"
fi
# Assure that /var/run/fail2ban exists
[ -d /var/run/fail2ban ] || mkdir -p /var/run/fail2ban
start-stop-daemon --start --quiet --chuid root --exec $DAEMON -- \
$DAEMON_ARGS start > /dev/null\
|| return 2
return 0
}
Now restart and it should work.
sudo /etc/init.d/fail2ban restart
Just for kicks, see how /var/run has the newly created fail2ban directory.
sudo ls /var/run
VMware Server must be reconfigured when there is a kernel upgrade
If the linux kernel is upgraded, vmware will not load http://localhost:8222. It requires a reconfigure when this happens. Do the following.
sudo /usr/bin/vmware-config.pl
Forget your mysql root password?
This following line saved my butt when something happened and my root password was no longer working.
sudo dpkg-reconfigure mysql-server-5.0
It will allow you to reset your root password without messing with the data or any other configuration in my.cnf.
Ubuntu apache2 virtualhost setup problems
If you are getting error messages when starting apache2 like
"Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName"
or
"[warn] _default_ VirtualHost overlap on port 80, the first has precedence"
you need to make sure a couple of lines are in your /etc/apache2/httpd.conf file.
ServerName localhost
VMware bridged network Ubuntu and Windows
Setting up a Windows guest to serve to the LAN that the host Ubuntu is on is simple but a few gotchas to look out for.
My Setup:
1. Host VM Ubuntu withd 2 NICs
2. Guest VM XP Pro serving http through IIS
3. Lan with DHCP exist at Host VM level
4. Host VM uses eth0
5. VMware Server
Getting it to work:
- For the Network Adapter config for the guest VM select the Bridged Network created during install of VMware server (eth1 in my case since eth0 is assigned to host VM)
- On host VM Ubuntu, goto System>Preferences>Network Connections
- Edit eth1
- Uncheck Available to all users
- Goto IPv4 Settings tab
- Change method to Link-Local Only
- Apply and close
- Refresh NICs
- Make sure ifconfig does not show an IP address from the subnet of your LAN on eth1
- Since guest VM XP is to serve http, it should have a static IP
- Goto guest VM
- Set TCP/IP for the Local Area Connection to a static IP within the subnet of the LAN
- Run ipconfig /refresh in command line
- Make sure ipconfig shows the correct IP info just set
- Make sure it can connect to internet
- Make sure Windows Firewall is not blocking http or port 80 (obvious step but it threw me for a loop for a little while)
- Now just check from host VM to see if a test webpage shows up
Ubuntu 9.04 Vmware Arrow Keys Problem
I finally found how to get all those keys working on my newly installed Ubuntu 9.04 with my XP VM. The issue is that all the arrow keys and delete key don't work. There are others too but not listed. So a bit of googling, I found that you have to map the keys in a vmware config file to solve the problem. So this is what needs to be done.
1. Edit /usr/lib/vmware/config
2. Add the following to the end.
xkeymap.keycode.108 = 0x138 # Alt_R
xkeymap.keycode.106 = 0x135 # KP_Divide
xkeymap.keycode.104 = 0x11c # KP_Enter
xkeymap.keycode.111 = 0x148 # Up
xkeymap.keycode.116 = 0x150 # Down
xkeymap.keycode.113 = 0x14b # Left
xkeymap.keycode.114 = 0x14d # Right
xkeymap.keycode.105 = 0x11d # Control_R
xkeymap.keycode.118 = 0x152 # Insert
xkeymap.keycode.119 = 0x153 # Delete
xkeymap.keycode.110 = 0x147 # Home
xkeymap.keycode.115 = 0x14f # End
xkeymap.keycode.112 = 0x149 # Prior
xkeymap.keycode.117 = 0x151 # Next
xkeymap.keycode.78 = 0x46 # Scroll_Lock
xkeymap.keycode.127 = 0x100 # Pause
xkeymap.keycode.133 = 0x15b # Meta_L
xkeymap.keycode.134 = 0x15c # Meta_R
xkeymap.keycode.135 = 0x15d # Menu
3. Save it
4. Restart vmware
Thank goodness. What a pain this was to use with a whole bunch of keys not working.
GRUB Error 21 Dual Boot Raid
I was installing Ubuntu to dual boot onto a newly added drive on my workstation that already has Windows XP. After the installation, GRUB gives me error 21. I looked through all the forums and help and tried everything from reinstalling GRUB to modifying menu.lst. Nothing worked. Then I figured out what the problem was. My system before adding the new drive had three drives; one with XP OS and two in a Raid 1 array for data. The issue was the Raid 1 array. With the new drive I added for Ubuntu, the computer had four drives. During installation, Ubuntu saw four drives and when installing GRUB, it pointed Ubuntu to boot on hd3,0. However, when GRUB tried to load, the BIOS was showing only three drives and hd3 was non-existent resulting in error 21.
Then I decided to move my SATA cables around so the location of the Ubuntu install does not change no matter if we saw the Raid 1 as one drive or two. So I kept XP on hd0, moved Ubuntu to hd1, and then having the Raid 1 drives to follow with hd2 and hd3. At this point, I reinstalled GRUB and tried to boot up again with the Raid 1 configured in the BIOS. Now I get GRUB error 17! What the heck is that? I found that if I got rid of Raid on the BIOS, error 17 goes away and GRUB comes up without a problem.
I got tired of trying to debug this and decided to just go all Ubuntu and just VM XP for the few things I still need to do on Windows.