Experimental environment
Virtual Machine Three
TOMCAT1 192.168.103.192 Tomcat+mysql
TOMCAT2 192.168.103.195 Tomcat
Apache2 192.168.103.217 apache2
The Tomcat directory is placed in the/data/software
First, install MySQL and Redis, Tomcat on the TOMCAT1
installation of MySQL
1. Install MySQL dependent packages
Apt-get-y install gcc libncurses5-dev zlib1g-dev Libssl-dev Bison build-essential
2.mysql5.5 gave up./configure precompiled method, instead of cmake, so we have to install CMake first.
wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
TAR-ZVXF cmake-2.8.7.tar.gz
CD cmake-2.8.7
./configure
Make && make install
3. Download MySQL source package, add compression after compiling and install MySQL.
Mkdir/var/lib/mysql/var/log/mysql creating a MySQL Directory
wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.30.tar.gz
TAR-ZVXF mysql-5.5.30.tar.gz
CD mysql-5.5.30
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/var/lib/mysql-ddefault_charset=utf8-ddefault_collation =utf8_general_ci-dwith_innobase_storage_engine=1-dextra_charsets=all-dwith_ssl=system-dwith_debug=0
Make && make install
Note: For csv,myisam,myisammrg,heap in CMake, it is not necessary to explicitly specify the name of the storage engine because they are mandatory to install.
4. Create user groups and users, create related directories and empower them.
#创建mysql组和mysql用户
Groupadd MySQL;
Useradd-r-g MySQL MySQL or useradd-s/sbin/nologin MySQL
chmod +w/usr/local/mysql
Chown-r Mysql:mysql/usr/local/mysql/var/lib/mysql/var/log/mysql
5. Initialize the database and assign the database the right
/usr/local/mysql/scripts/mysql_install_db--user=mysql--pid-file=/var/lib/mysql/mysql.pid--datadir=/var/lib/ mysql/--basedir=/usr/local/mysql
Empowerment:
Chown-r Mysql:mysql/var/lib/mysql
6. Modify the configuration file.
Copy/etc The support-files/my-medium.cnf under the extracted tar package and replace it with the/my.cnf. (Copy the configuration as required)
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
Under #在 [client], modify the socket value to/var/lib/mysql/mysql.sock,
Modify the socket value under Mysqld to/var/lib/mysql/mysql.sock, and specify the MySQL directory, MySQL data directory, mysql error log directory, configured as follows, and set the database encoding to UTF-8 modified save exit
[Client]
Socket =/var/lib/mysql/mysql.sock
# The MySQL server
[Mysqld]
Port = 3306
Socket =/var/lib/mysql/mysql.sock
Basedir =/usr/local/mysql
DataDir =/var/lib/mysql/
Log-error =/var/log/mysql/mysql-error.log
Pid-file =/var/lib/mysql/mysql.pid
Character-set-server = UTF8
7. Set up MySQL boot.
Start MySQL
/usr/local/mysql/bin/mysqld_safe &
Ps-a|grep MySQL
Set up MySQL boot.
CP Support-files/mysql.server/etc/init.d/mysql
chmod +x/etc/init.d/mysql
Chkconfig--add MySQL
Chkconfig MySQL on
Test if MySQL can start, pause, restart
Service MySQL restart (start|stop|restart)
or/etc/init.d/mysql restart (start|stop|restart)
Add part of the MySQL command to/usr/bin:
ln/usr/local/mysql/bin/mysql/usr/bin/
ln/usr/local/mysql/bin/mysqladmin/usr/bin/
ln/usr/local/mysql/bin/mysqldump/usr/bin/
After the installation is successful, set the MySQL root password
Mysql>set password =password (' 123456 ');
Mysql>Grant all privileges on * * to ' myuser ' @ '% ' identified by ' MyPassword ' with GRANT OPTION; can be connected from any host to mysql
Mysql>flush privileges;
Ii. installation of Tomcat
First configure the Java environment
#vi ~/.BASHRC Add a parameter at the end
Export java_home=/data/software/jdk1.7.0_79
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
#java-version
Java Version "1.7.0_79"
Java (TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot (TM) 64-bit Server VM (build 24.79-b02, Mixed mode)
2. Unzip the configuration Tomcat
#tar ZXVF apache-tomcat-7.0.62.tar.gz
#cd apache-tomcat-7.0.62/webapps/
Then upload the login system login, and then specify the database to the local database address (here according to your needs)
Go to the Bin directory of Tomcat to start the service
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/6d/92/wkiom1vmihcsn6yoaauft5bpfkg757.jpg "title=" 1.jpg "alt=" Wkiom1vmihcsn6yoaauft5bpfkg757.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/8E/wKioL1Vmiv3hsP8mAAC5viD1Yks685.jpg "title=" 2.jpg " alt= "Wkiol1vmiv3hsp8maac5vid1yks685.jpg"/>
Tomcat2 only on Tomcat and the above steps, login configuration to point to 192.168.103.192 this database
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/8E/wKioL1Vmi4qj4elUAADZ4tEIoIc555.jpg "title=" 3.jpg " alt= "Wkiol1vmi4qj4eluaadz4teioic555.jpg"/> Three, installation Apache2
1 Installing Apache2
Apt-get Install Apache2
Service Apache2 Stop
2 Loading the agent module
A2enmod proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http lbmethod_byrequests
3 Modifying configuration sudo vi/etc/apache2/mods-enabled/proxy.conf
Proxyrequests OFF
<proxy *>
Order Deny,allow
Deny from all
#Allow from. your_domain.com
</Proxy>
4 Modifying Configuration vim/etc/apache2/sites-available/000-default.conf
Load Balancing Configuration
Proxyrequests OFF
proxypass/balancer://proxy/
<proxy balancer://proxy>
Order Deny,allow
Allow from all
Balancermember http://192.168.103.192:8080
Balancermember http://192.168.103.195:8080
</Proxy>
</VirtualHost>
Service Apache2 Restart
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/8E/wKioL1VmjH2RpJHWAANrpyhxkiU158.jpg "title=" 4.jpg " alt= "Wkiol1vmjh2rpjhwaanrpyhxkiu158.jpg"/>
Then access address 192.168.103.217/login first visit will jump to 192.168.103.192 the second time will go to 192.168.103.195, the experiment is complete.
This article is from the "Fighting" blog, make sure to keep this source http://690156297.blog.51cto.com/10074910/1655893
Apache2 on Ubuntu for load Balancing