In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Case summary: it is implemented in four-tier mode, which is mainly divided into front-end reverse proxy layer, Web layer, database cache layer and database layer. Front-end reverse proxy layer adopts master-standby mode, Web layer adopts cluster mode, database cache layer adopts master-slave mode, and database layer adopts master-slave mode. In order to get closer to the production environment, two physical machines are used to deploy the environment. The front-end reverse proxy layer, database cache layer and database layer are deployed on the physical machine, and only the Web layer is deployed in the KVM virtual machine. At the same time, each layer has a highly available architecture to ensure the stability of the business. Million pv network architecture:
Ps: the implementation is the normal data flow, and the dotted line is the data flow in the abnormal case.
Case environment: hostname IP address system use master192.168.217.128CentOS 7.3reverse proxy machine, redis master cache, MySQL master database backup192.168.217.129CentOS 7.3reverse proxy machine, redis slave cache, mysql slave database tomcat-node 1192.168.217.130CentOS 7.3webtomcat-node 2192.168.217.131CentOS 7.3web deployment master: build Nginx reverse proxy: 1. Installation source: rpm-ivh http://nginx.org/packages/centos/7/noarch/RPMS/\nginx-release-centos-7-0.el7.ngx.noarch.rpm # installs the source master and slave with the nginx rpm package. Configure Nginx reverse proxy: yum install-y nginxvi / etc/nginx/nginx.conf # add http {upstream tomcat_pool {server 192.168.217.130 nginxvi 8080; # real node web server 192.168.217.131 nginxvi 8080; ip_hash to http # session firmness, otherwise you cannot log in to} server {listen 80; server_name 192.168.175.188; # virtual IP location / {proxy_pass http://tomcat_pool; via vip address Proxy_set_header X-Real-IP $remote_addr;}} include / etc/nginx/mime.types; .nginx-t-c / etc/nginx/nginx.conf / / Test configuration file syntax build keepalived: 1. Configure keepalived: yum install-y keepalivedvim / etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_defs {route_id NGINX_HA} vrrp_script nginx {# add script path script "/ opt/shell/nginx.sh" interval 2 # every two seconds} vrrp_instance VI_1 {state MASTER # active server interface ens33 # network card virtual_router_id 51 priority 100 # priority advert_int 1 authentication {auth_type PASS auth_pass 1111} track_script {# call script nginx} virtual_ipaddress {192.168.217.188 # Virtual IP} 2. Write a Nginx script: mkdir / opt/shellvim / opt _ gt _ nginx.shache _ gt _ bind _ Bash = `ps-ef | grep keepalived | grep-v grep | wc-l`if [$k-gt 0] Then / bin/systemctl start nginx.serviceelse/bin/systemctl stop nginx.servicefi# means that enabling keepalived will automatically enable Nginxchmod + x / opt/shell/nginx.shsystemctl start keepalived.service # enable service configuration backup: slightly different from master configuration except keepalived Other same: vim / etc/keepalived/keepalived.conf .vrrp _ instance VI_1 {state BACKUP # modify backup mode interface ens33 virtual_router_id 51 priority 90 # confirm master / slave .systemctl start keepalived.service # start service test: when keepalived service is on, turn off nginx for testing, and find that nginx automatically enables and closes master keepalived every 2 seconds Test the master-slave drift address switch and use ip addr to view the VIP binding location and deploy the web service: 1. Install java environment: tar xf jdk-8u144-linux-x64.tar.gz-C / optcp-rv / opt/jdk1.8.0_144/ / usr/local/java # Mobile rename vim / etc/profile # add java environment 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/libsource / etc/ Profile # refresh environment java-version # proves that the java environment installed successfully java version "1.8.0 # 144" 2. Install tomcat: tar xf apache-tomcat-8.5.23.tar.gz-C / optcp-r / opt/apache-tomcat-8.5.23 / usr/local/tomcat8 # Mobile rename ln-s / usr/local/tomcat8/bin/startup.sh / usr/bin/tomcatup # enable tomcatln-s / usr/local/tomcat8/bin/shutdown.sh / usr/bin/tomcatdown # turn off tomcattomcatup # enable netstat-anpt | grep 8080 # check whether the service is enabled. Test: http://192.168.217.130:8080/ # Test whether the default test page is displayed properly http://192.168.217.131:8080/ access http://192.168.217.188 # modify web different home pages Test whether keepalived and reverse proxy are successful vim / usr/local/tomcat8/webapps/ROOT/index.jsp # homepage deployment of master and backup databases: yum install-y mariadb-server mariadbsystemctl start mariadb.service systemctl enable mariadb.servicenetstat-anpt | grep 3306mysql_secure_installation # General security settings, testing can be omitted. Mysql-uroot-p
< slsaledb-2014-4-10.sql #导入SL商城数据mysql -uroot -pshow databases; #查看有没有 slsaledb 数据库GRANT all ON slsaledb.* TO 'root'@'%' IDENTIFIED BY 'abc123'; #授权flush privileges; # 刷新部署 web 服务器 :1.添加cd /usr/local/tomcat8/conf/vim server.xml #跳到148行尾,在Host name下新增 #日志调试信息debug为0表示信息越少,docBase指定访问目录# SLSaleSystem 为webapps目录下的源码包tar xf SLSaleSystem.tar.gz -C /usr/local/tomcat8/webapps/ #解压商城的源码包cd /usr/local/tomcat8/webapps/SLSaleSystem/WEB-INF/classes #移动到 webapps下vim jdbc.properties #修改数据库IP地址是VRRP的虚拟IP,以及授权的用户名root和密码abc123。2.网站测试,进入SL商城 :http://192.168.217.130:8080/ #默认的用户名admin 密码:123456http://192.168.217.131:8080/http://192.168.217.188 #输入虚拟地址测试登录,并且关闭主再测试登录Deploy master: 1. In redis cache host configuration: yum install-y epel-release # install redis source yum install redis- y # install redis cache service vim / etc/redis.conf # modify configuration file bind 0.0.0.0systemctl start redis.service # enable service netstat-anpt | grep 6379redis-cli-h 192.168.217.128-p 6379 # Local test connection 192.168.217.128yum install redis- 6379 > set name test # create The name value is test192.168.217.128:6379 > get name # View name value 2. Configure redis cache slave configuration: yum install-y epel-release # install Epel source yum install redis- y # install redis cache service vim / etc/redis.conf # modify configuration file bind 0.0.0.0slaveof 192.168.217.128 6379 # the IP of the master server is not a virtual IP line 266 systemctl start redis.service # enable service redis-cli-h 192.168.217.129-p 6379 / log in to get the value Success indicates that master-slave synchronization succeeded 192.168.217.129 get name 6379 > vim # if you can see it, synchronization successfully deployed web: configure parameters for connecting redis in the mall project: vim / usr/local/tomcat8/webapps/SLSaleSystem/WEB-INF/classes/applicationContext-mybatis.xml 47 line # modify virtual IP 48 deployment master: 1. Test the cache effect: redis-cli-h 192.168.217.188-p 6379192.168.175.188keyspace_hits 6379 > infokeyspace_hits:1 or keyspace_misses:0 # follow this value, number of hits and misses # log in to the mall, then repeatedly click on the operation page that requires the database to participate, and then come back to check the change of keyspace_hits or keyspace_misses: value using info. two。 Configure redis cluster master-slave switchover (only operated on the master server): redis-cli-h 192.168.217.128 info Replication / / obtain the role of the current server vim / etc/redis-sentinel.conf17 protected-mode no # enable 68 sentinel monitor mymaster 192.168.175.128 6379 1 # 1 means 1 slave attention: modify 98 sentinel down-after-milliseconds mymaster 3000 # failover time unit is millisecond systemctl restart redis- Sentinel.service / / start cluster netstat-anpt | grep 26379redis-cli-h 192.168.217.128-p 26379 info Sentinel / / View cluster information 3. Verify the master-slave switch: systemctl stop redis.service # closes the master cache service redis-cli-h 192.168.175.128-p 26379 info Sentinel # and finds that the master becomes 129. check out 4. Verify data synchronization: redis-cli-h 192.168.217.129-p 6379 # enter the slave cache server 192.168.217.129 test2 6379 > set name2 test2 # create OK192.168.217.129:6379 > get name2 "test2" systemctl start redis # start the main cache service redis-cli-h 192.168.217.128-p 6379 # enter the master cache server 192.168.217.1286379 > get name2 # View "test2" mysql master and slave for deploying master and backup: 1. Edit the configuration file: vim / etc/my.cnf # [mysqld] add binlog-ignore-db=mysql,information_schemacharacter_set_server=utf8log_bin=mysql_binserver_id=1 # Master / slave id different log_slave_updates=truesync_binlog=1vim / etc/my.cnf # mysql slave server # add server_id=2 systemctl restart mariadb.service # restart database 2 under [mysqld]. View authorization in master: mysql-u root-pshow master status; # record log file name and offset location value grant replication slave on *. * to 'rep'@'192.168.175.%' identified by' 123456 license; # license flush privileges; # refresh 3. In backup authorization: mysql-u root-pchange master to master_host='192.168.217.128',master_user='rep',master_password='123456',master_log_file='mysql_bin.000001',master_log_pos=245;start slave; # open show slave status; # View Slave_IO_Running: Yes # successful Slave_SQL_Running: Yes4. Test:
Create the database in the master database and view it from the database.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.