Building the million PV site architecture

Source: Internet
Author: User
Tags install redis

Mega PV Site Architecture 1, experimental overview
    • The experimental design is implemented in four layer mode, which is mainly front-end reverse proxy layer, Web layer, database cache layer and database layer. The front-end reverse proxy uses the main standby mode, the Web layer adopts the cluster mode, the database cache layer adopts the main standby mode, and the database layer adopts the master-slave mode.
2, Million PV website construction experiment Extension map

3. Experimental environment
Host name IP Address system Use
Master 192.168.190.130 CentOS 7 Front-end Reverse proxy host, Redis cache host, MySQL database
Backup 192.168.190.128 CentOS 7 Front-end Reverse proxy host, Redis cache host, MySQL database
Tomcat-node1 192.168.190.131 CentOS 7 Web Services
Tomcat-node2 192.168.190.129 CentOS 7 Web Services
4, the Experiment Step 1), installs the Nginx, keepalived, and configures the Keepalived dual machine hot standby, the Nginx front-end dispatch function
    • Master, Backup host configuration is basically the same, the difference between the logo;

RPM-IVH http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm #安装带有nginx Source of RPM Packages

Yum Install keepalived nginx-y

Vi/etc/keepalived/keepalived.conf #配置keepalived双机热备配置文件

! Configuration File for keepalivedglobal_defs {    route_id test01                 #backup为test02 }vrrp_script nginx {                 #引用脚本    script "/opt/shell/nginx.sh"    #脚本位置    interval 2                      #检测脚本时间间隔}vrrp_instance VI_1 {    state MASTER                    #另一台为backup    interface ens33    virtual_router_id 51                priority 100                    #另一台优先级为99    advert_int 1    authentication {        auth_type PASS        auth_pass 1111}track_script {                      #调用脚本    nginx}virtual_ipaddress {                 #虚拟IP    192.168.27.180    }}

Mkdir/opt/shell

Vi/opt/shell/nginx.sh #配置脚本

#!/bin/bashk=`ps -ef | grep keepalived | grep -v grep | wc -l`if [ $k -gt 0 ];then    /bin/systemctl start nginx.serviceelse/bin/systemctl stop nginx.servicefi#脚本的含义是如果keepalived已启动,那么每两秒检查启动一次nginx服务

chmod +x/opt/shell/nginx.sh #赋予执行权限

Vi/etc/nginx/nginx.conf #编辑nginx配置文件;

 upstream tomcat_pool {                server 192.168.190.131:8080;                server 192.168.190.129:8080;                ip_hash;           #会话稳固功能,否则无法通过vip地址登陆        }        server {                listen 80;                server_name 192.168.190.180; #虚拟出的IP                  location / {                        proxy_pass http://tomcat_pool;                        proxy_set_header X-Real-IP $remote_addr;                }    }

Nginx-t-c/etc/nginx/nginx.conf #测试配置文件语法

Systemctl Start Keepalived.service #nginx启动会等待一会

2), install Tomcat on both Web servers

Tar XF apache-tomcat-8.5.23.tar.gz-c/opt

Tar XF jdk-8u144-linux-x64.tar.gz-c/opt #将挂载的压缩包解压

CP-RV jdk1.8.0_144//usr/local/java

Vim/etc/profile #环境变量

export JAVA_HOME=/usr/local/javaexport JRE_HOME=/usr/local/java/jreexport PATH=$PATH:/usr/local/java/binexport CLASSPATH=./:/usr/local/java/lib:/usr/local/java/jre/lib

Source/etc/profile #刷新环境变量

Java-version #查看java版本

java version "1.8.0_144

Cp-r Apache-tomcat-8.5.23/usr/local/tomcat8

Ln-s/usr/local/tomcat8/bin/startup.sh/usr/bin/tomcatup #建立软连接

Ln-s/usr/local/tomcat8/bin/shutdown.sh/usr/bin/tomcatdown

Tomcatup #启动Tomcat

vim/usr/local/tomcat8/webapps/root/index.jsp #更改默认测试首先内容

3), install the MySQL database on the master, Backup server and import the data, configure the Web server and test
    • Master, backup server settings;

Yum install-y mariadb-server mariadb

Systemctl Start Mariadb.service

Systemctl Enable Mariadb.service

Mysql_secure_installation #常规安全设置

Mysql-u Root-p < Slsaledb-2014-4-10.sql #将挂载的数据库导入

Mysql-uroot-p #进入数据库

show databases; #查看

GRANT all on slsaledb.* to ' root ' @ '% ' identified by ' abc123 '; #授权

Flush privileges; #刷新权限

    • Configure two Web servers and test

Tar zxvf slsalesystem.tar.gz-c/usr/local/tomcat8/webapps/

Cd/usr/local/tomcat8/webapps/slsalesystem/web-inf/classes

Vim Jdbc.properties #修改数据库IP地址是VRRP的虚拟IP, and the username root and password abc123 are authorized.

cd/usr/local/tomcat8/conf/

VI server.xml #在Host name (148 lines) New

<Context path="" docBase="SLSaleSystem" reloadable="true" debug="0"></Context>#日志调试信息debug为0表示信息越少,docBase指定访问目录
    • Website Test, default username admin password: 123456

4), install the Redis master-slave cache on master and backup

Yum Install epel-release-y #安装epel源

Yum Install redis-y #安装redis

Vim/etc/redis.conf

bind 0.0.0.0#从缓存服务器上在266行添加 slaveof 192.168.190.130  6379(主服务器的IP不是虚拟IP)

Systemctl Start Redis.service #开启服务

    • Test master-Slave cache;

    • Primary server:
    • From the server:

    • Test the cache effect, refresh the SL membership store, and view cache hit and Miss hits;

    • Before refresh:
    • After refresh:

5), configure MySQL master/slave
    • MySQL Master server configuration

VIM/ETC/MY.CNF #[mysqld] Under

binlog-ignore-db=mysql,information_schemacharacter_set_server=utf8log_bin=mysql_binserver_id=1         #两台ID不同log_slave_updates=truesync_binlog=1

Systemctl Restart MARIADB

Mysql-u Root

Show master status; Record log file name and location values

Grant replication Slave on . to ' rep ' @ ' 192.168.190.% ' identified by ' 123456 '; # #允许192.168.190.0 network segment from the server using the account password login

Flush privileges;

    • MySQL from server configuration

VIM/ETC/MY.CNF #[mysqld] Under

server_id=2

Systemctl Restart MARIADB

Mysql-u Root

Change Master to master_host= ' 192.168.190.130 ', master_user= ' rep ', master_password= ' 123456 ', master_log_file= ' Mysql_ Bin.000002 ', master_log_pos=483; # #配置同步

Start slave;

show slave status; # #查看slave状态

Building the million PV site architecture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.