Ubuntu server 10.04, resin 3.1.10, nginx-0.7.65 Server Load balancer website
Software and Hardware architecture
Internet-> fire wall-> F5 Load balancer-> router-> Web servers (Ubuntu + nginx + resins)-> dB servers (Aix + Oracle)-> storage
1. Install Ubuntu
Install it in vitrual box 3.2.4 and the network may be disconnected during installation, which is faster
Select bridged adapter for the Network
The local address is 192.168.3.31.
Ubuntu server address: 3.222
Gateways 3.1
DNS 8.8.8.8
Use putty as a terminal to connect
2. Modify the unbuntu server Nic
Sudo VI/etc/Network/interfaces
# This file describes the network interfaces available on your system
# And how to activate them. For more information, see interfaces (5 ).
# The loopback network interface
Auto Lo
Iface lo Inet loopback
# The primary network interface
Auto eth0
Iface eth0 Inet static
Address 192.168.3.222 # Ubuntu IP Address
Netmask 255.255.255.0 # Subnet Mask
# Network 192.168.3.0 # No need to configure
# Broadcast 192.168.3.255 # configuration not required
Gateway 192.168.3.1 # Gateway
# DNS-* options are implemented by the resolvconf package, if installed
DNS-nameservers 8.8.8.8 # DNS, separated by Spaces
Sudo/etc/init. d/networking restart # Start the nic and the eni will be disconnected.
Sudo/etc/init. d/networking force-Reload # force loading. This is better, and the terminal will not be disconnected.
3. Install JDK
Preparations
Sudo VI/etc/APT/sources. List
Add Source
Deb http://archive.canonical.com/lucid partner
Sudo apt-Get update must be executed.
APT: advanced packaging tools
Other apt-Get usage
Apt-cache search package
Apt-Cache show package obtains package information, such as description, size, and version.
Sudo apt-Get install package installation package
Sudo apt-Get install package--reinstall re-installation package
Sudo apt-get-F install force installation? # "-F = -- fix-missing" should be fixed and installed...
Sudo apt-Get remove package Delete package
Sudo apt-Get remove package--Purge delete a package, including deleting a configuration file.
Sudo apt-Get Update update source
Sudo apt-Get upgrade updates installed packages
Sudo apt-Get dist-upgrade System
Sudo apt-Get dselect-upgrade using dselect
Apt-Cache depends package for dependency usage
Apt-Cache rdepends package understand a specific dependency? # Check which packages the package depends on...
Sudo apt-Get build-dep package installation-related compilation environment
Apt-Get source package download the source code of the package
Sudo apt-Get Clean & sudo apt-Get autoclean clear the archives of downloaded files & only clear useless packages
Sudo apt-Get check whether any corrupted dependency exists
Sudo apt-Get install sun-java6-jdk # download, install
Java-version # Check whether the installation is successful
Sudo VI/etc/profile # configure java_home method 1
Add at last
# Jdk1.6 env
Java_home =/usr/Java/jdk1.6.0 _ 20
Path = $ java_home/bin: $ path
Classpath =.: $ java_home/lib/TD. jar: $ java_home/lib/tools. Jar
Export java_home
Export path
Export classpath
Sudo VI/etc/environment # configure java_home method 2 (recommended)
# Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/Games"
# Jdk1.6 env
Java_home =/usr/lib/JVM/Java-6-sun
Path = $ java_home/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games
Classpath =.: $ java_home/lib/TD. jar: $ java_home/lib/tools. Jar
Press Ctrl + D on the putty interface to exit and then enter
Echo $ java_home
4. Install nginx
Sudo apt-Get install nginx # download and install
Sudo/etc/init. d/nginx reload | START | stop
Sudo VI/etc/nginx/sites-available/Default
# You may add here your
# Server {
#...
#}
# Statements for each of your virtual hosts
Upstream resin {
# Server 192.168.1.103: 8080 Weight = 2;
Server 192.168.3.222: 8080 Weight = 2;
Server 192.168.3.222: 8081 Weight = 2;
Server 192.168.3.31: 8080 Weight = 3;
Server 192.168.3.31: 8081 Weight = 3;
}
Server {
Listen 80 default;
SERVER_NAME localhost, 192.168.3.222;
Access_log/var/log/nginx/localhost. Access. log;
Location /{
Proxy_redirect off;
Proxy_set_header host $ host;
Proxy_pass http: // resin;
Proxy_set_header X-real-IP $ remote_addr;
Proxy_set_header X-forwarded-for $ proxy_add_x_forwarded_for;
Proxy_redirect false;
}
}
Sudo/etc/init. d/nginx reload
Access http: // 192.168.3.222
5. install Resin
Download resin 3.1.10 free
Http://www.caucho.com/download/
Download and upload to/home/root
Sudo tar-zxvf resin-pro-3.1.10.tar.gz # unzip
Sudo MV Resin-Pro-3.1.10/usr/local/resin # copy to resin
Sudo chmod-r 777/usr/local/resin # Modify permissions
CD/usr/local/resin/config
Sudo CP resin. conf resin-8080.conf
Sudo CP resin. conf resin-8081.conf
Modify the port in the resin-8081.conf to 8081, and Add 1 to other ports in turn
Modify the web-app node in the two files
<Web-app id = "/" Root-directory = "webapps/root/8080"/>
<Web-app id = "/" Root-directory = "webapps/root/8081"/>
Put the test file in two folders
CD/usr/local/resin/bin
Sudo CP httpd. Sh httpd-8080.sh
Sudo CP httpd. Sh httpd-8081.sh
Modify the last row from
Exec $ java_exe-jar $ {resin_home}/lib/resin. Jar $ *
Change
Exec $ java_exe-jar $ {resin_home}/lib/resin. jar-conf $ {resin_home}/CONF/resin-8080.conf $ *
Exec $ java_exe-jar $ {resin_home}/lib/resin. jar-conf $ {resin_home}/CONF/resin-8081.conf $ *
Add the-conf Parameter
Sudo./httpd-8080.sh start
Sudo./httpd-8081.sh start
Running successful
Install resin as a service
Sudo VI/usr/local/resin/contrib/init. Resin. In
Java_home and resin_home are modified
Java_home = "/usr/lib/JVM/Java-6-Sun"
Resin_home = "/usr/local/resin"
Copy to two files
Sudo CP/usr/local/resin/contrib/init. Resin. in/etc/init. d/resin8080
Sudo CP/usr/local/resin/contrib/init. Resin. in/etc/init. d/resin8081
Modify the two files separately.
Sudo VI/etc/init. d/resin8080
Sudo VI/etc/init. d/resin8081
Modify target:
Conf = "-conf $ resin_home/CONF/resin-8080.conf" # This line is added, different files conf is not the same
ARGs = "-resin-home $ resin_home $ server $ conf" # add $ conf to the end of this line.
Sudo update-rc.d/etc/init. d/resin-8080 defaults 99;
Sudo service Resin-8080 start;
Sudo reboot
Access http: // 192.168.3.222 again