First, the environment: Nginx+jre+tomcat+redis+mysql
Nginx 192.168.1.200 web+ Load Balancing
Tomcat ( A ) 192.168.1.210 Web Application
Tomcat ( B ) 192.168.1.211 Web Application
Mysql ( Master ) 192.168.1.230 master-slave replication, database
Mysql ( Slava ) 192.168.1.231 master-slave replication, database
Test Domain name ABC . com
Second, the deployment of ideas
domain name directly resolves to nginx server ( 192.168.1.200 nginx server load Balancer to tomcat ( a "Server ( 192.168.1.210 tomcat ( b "Server ( 192.168.1.211
Three, Nginx : Installation and Configuration
Yum-yinstall gcc gcc-c++ autoconf automake
Yum-yinstall zlib zlib-devel OpenSSL openssl-devel pcre-devel
Groupadd-r Nginx;useradd-r-G nginx
./configure--prefix=/usr/local/nginx--sbin-path=/usr/sbin/nginx--conf-path=/etc/nginx/nginx.conf
Make && make install
Search the web for an nginx startup script, Vim/etc/rc.d/init.d/nginx, paste it in
Add Execute permissions chmod +x/etc/rc.d/init.d/nginx
modifying Startup Items Chkconfig--add nginx
Add boot auto-start chkconfig nginx on
Starting service Nginx Start
Edit Nginx configuration file/etc/nginx/nginx.conf
upstream abc.com { server 192.168.1.210:8080; server 192.168.1.211:8080; } location / { proxy_pass http://mycluster ; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP$remote_addr; proxy_set_ headerx-forwarded-for $PRoxy_add_x_forwarded_for; }
# Note, if the implementation session is maintained can use Nginx ip_hash module, add Ip_hash in upstream can be
Iv. JDK and Tomcat installation
Tar XF Apache-tomcat-7.0.57.tar.gz–c/usr/local/tomcat
Tar XF jdk-7u80-ea-bin-b03-linux-i586-19_nov_2014.tar.gz–c/usr/local/jdk1.7.0_80
Vim/etc/profile Java_home=/usr/local/jdk1.6.0_12 path= $JAVA _home/bin: $PATH class_path= $JAVA _home/lib: $JAVA _home/ Jre/lib Export Java_home PATH class_path
. /etc/profile
cp/usr/local/tomcatbin/startup.sh/etc/rc.d/init.d/tomcat.sh
Chkconfig--add Tomcat
Chkconfig Tomcat on
Service Tomcat Start
V. MySQL Master and slave replication
MySQL Install online search, or my other articles have written;
MySQL master-slave replication principle: The primary server records the binary log, from the server in command mode and row mode for execution and replication, so the master and slave server to open the binary log.
1. Configure the primary server
VIM/ETC/MY.CNF [mysqld] log-bin=/var/log/mysql/mysql-bin.log # Log path server-id=230 # Service ID, I understand is used for multi-service differentiation, network only One
Restart mysqld after configuration, log on to master server MySQL to authorize from server user
Mysql> GRANT REPLICATION SLAVE on * * to ' myuser ' @ ' 192.168.1.231 ' identified by ' mypass ';
2. Configure the slave server
VIM/ETC/MY.CNF [mysqld] Log-bin=/var/log/mysql/mysql-bin.log server-id=231
Restart mysqld after configuration is complete, log on from the server to start slave
Mysql>start slave;
Master-slave configuration is completed, this time can be modified by modifying the main server table, library information to test,
You can also compare the show Master Status\g, and show slave status\g information
This is the offline test environment installation, if the line configuration also requires lock table, data file copy and other operations.
This article is from the "Drops of love and tears to throw red beans" blog, please be sure to keep this source http://beijgh.blog.51cto.com/8272564/1590783
Nginx+tomcat+mysql Architecture Building