Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Simulate millions of PV architecture

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Case

The design of this case adopts four-tier model, which is mainly divided into front-end reverse proxy layer, web layer, database cache layer and database layer. The front-end reverse agent layer adopts the master-standby mode, the web layer adopts the cluster mode, the database cache layer adopts the master-standby mode, and the database layer adopts the master-slave mode.

The topology diagram is as follows. The solid line is the data flow connection under normal conditions, and the dotted line is the data flow connection under abnormal conditions.

Front-end reverse proxy server configuration installs source rpm-ivh http://nginx.org/packages/centos/7/noarch/RPMS/\nginx-release-centos-7-0.el7.ngx.noarch.rpmyum install keepalived nginx-yvim / etc/keepalived/keepalived.confglobal_defs with nginx rpm package {route_id NGINX_HA # # different ID of master-slave server} vrrp_script nginx {# # setup script script "/ opt/ Shell/nginx.sh "interval 2 # # interval 2 seconds} vrrp_instance VI_1 {state MASTER # # primarily MASTER From BACKUP interface ens33 virtual_router_id 51 priority 100 # # priority The main script is higher than the slave advert_int 1 authentication {auth_type PASS auth_pass 1111} track_script {# # run script nginx} virtual_ipaddress {192.168.x.x # # set up the intranet virtual IP and the extranet virtual IP x.x.x.x}} mkdir / opt/shellvi / opt/shell/nginx.sh # # to create the script, which is designed when keepalived starts Nginx starts at the same time, and #! / bin/bashk= `ps-ef cannot be closed if keepalived,nginx is not closed | grep keepalived | grep-v grep | wc-l`if [$k-gt 0] Then / bin/systemctl start nginx.serviceelse/bin/systemctl stop nginx.servicefichmod + x / opt/shell/nginx.sh # # gives the script permission to run and then configure NGINX's scheduling function vim / etc/nginx/nginx.conf to add upstream tomcat_pool {server 192.168.x.xopt/shell/nginx.sh 8080; server 192.168.x.xopt/shell/nginx.sh 8080 to the http; # # address ip_hash of two tomcat # session stabilization feature. If you don't use this, you need to do session sharing} server {listen 80; server_name 192.168.x.x; # Virtual IP location / {proxy_pass http://tomcat_pool; Proxy_set_header X-Real-IP $remote_addr }} nginx-t-c / etc/nginx/nginx.conf # # Test configuration file syntax systemctl start keepalived.service # # nginx will also be opened for tomcat configuration (two identical) tar xf apache-tomcat-8.5.23.tar.gztar xf jdk-8u144-linux-x64.tar.gzcp-rv jdk1.8.0_144/ / usr/local/javavi / etc/profileexport 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 # # enable the system to recognize java enter java-version to see the version number description completed cp-r apache-tomcat-8.5.23 / usr/local/tomcat8ln-s / usr/local/tomcat8/bin/startup.sh / usr/bin/tomcatup # # start tomcatln-s / usr/local / tomcat8/bin/shutdown.sh / usr/bin/tomcatdown # # disable tomcatnetstat-anpt | grep 8080 requests # see 8080 service enabled successfully access http://192.168.x.x:8080 # # Test whether the default test page displays vi / usr/local/tomcat8/webapps/ROOT/index.jsp # # modify the default web content input scheduling server (virtual IP) address Test the scheduling of the two node servers. Vim / usr/local/tomcat8/conf/server.xml insert # # log debug information debug 0 means less information, docBase specified access directory mysql installation is simulated architecture, this mysql uses mariadb instead of yum install-y mariadb-server mariadbsystemctl start mariadb.servicesystemctl enable mariadb.servicenetstat-anpt | grep 3306mysql_secure_installation # # General Security Settings-Import Database-mysql-u root-p

< xxxx.sql ##导入商城网站数据库mysql -uroot -pshow databases; ##确定导入成功GRANT all ON xxxx.* TO 'root'@'%' IDENTIFIED BY 'abc123'; ##给数据库授权flush privileges; ##刷新数据 ----------------以下在两台tomcat节点做----------------tar xf SLSaleSystem.tar.gz -C/usr/local/tomcat8/webapps/cd /usr/local/tomcat8/webapps/SLSaleSystem/WEB-INF/classesvi jdbc.properties ##修改数据库IP地址是VRRP的虚拟IP,以及授权的用户名root和密码abc123。------------网站测试------http://192.168.x.x:8080/ ##默认的用户名admin 密码:123456http://192.168.x.x ##输入虚拟地址测试登录,并且关闭主再测试登录redis集群yum install redis -yvi /etc/redis.confbind 0.0.0.0 ##修改systemctl start redis.serviceredis-cli -h 192.168.x.x -p 6379 ##测试连接192.168.x.x:6379>

Set name test # # set the name value to test192.168.x.x:6379 > get name # # get the name value on the slave server 266 slaveof 192.168.x.x 6379 # # the IP of the master server is not a virtual IPredis-cli-h 192.168.x.x-p 6379 # # login slave, if you can successfully get the value set on the master Explain that master-slave synchronization succeeded 192.168.x.x:6379 > get name "test"-configure parameters for connecting redis in mall project-vi / usr/local/tomcat8/webapps/SLSaleSystem/WEB-INF/classes/applicationContext-mybatis.xml # # Virtual IP-the following test cache effect-redis-cli-h 192.168.x X-p 6379 # Virtual IP192.168.175.188:6379 > infokeyspace_hits:1 or keyspace_misses:2 # # follow this value Log in to the mall for hits and misses, 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. -configure redis cluster master-slave handover-only operate on master server-- vi / etc/redis-sentinel.confprotected-mode nosentinel monitor mymaster 192.168.x.x 6379 1 # # 1 means 1 slave Note: modify sentinel down-after-milliseconds mymaster 3000 # # failover time unit is millisecond service redis-sentinel start # # start cluster netstat-anpt | grep 26379redis-cli -h 192.168.x.x-p 26379 info Sentinel # # View cluster information mysql master / slave vim / etc/ my.cnf [mysqld] binlog-ignore-db=mysql on master and slave mysql servers Information_schemacharacter_set_server=utf8log_bin=mysql_binserver_id=1 # # the server_id of the master and slave servers is different log_slave_updates=truesync_binlog=1systemctl restart mysqld grants permissions to the slave server mysql-u root-pgrant replication slave on *. * to 'replication'@'192.168.x.%' identified by' 123456' on the master MYSQL Show master status +-+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +- -+ | master-bin.000002 | 335 | +- -mysql-u root-pchange master to master_host='192.168.x.x' on the slave server Master_user='replication',master_password='123456',master_log_file='mysql_bin.000002',master_log_pos=335 Start slave;show slave status\ G; Slave_IO_Running: Yes Slave_SQL_Running: Yes## the presence of these two YES means that MYSQL master-slave replication is complete and all services are installed.

The structure of the case database is a little simpler, and the configuration file is not optimized by default. If the database is under great pressure, optimization can be considered, read-write separation architecture can be used, or multi-master and multi-slave mode can be adopted.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report