定制网站大概多少钱百度搜索广告价格
1.Redis集群说明
1.1 分片/哨兵有哪些缺点
1.分片缺点: 分片的主要功能是实现内存的扩容的,但是没有高可用的效果的
2.哨兵缺点: 数据没有扩容,哨兵本身没有高可用机制
需求:既可以实现内存数据的扩容,同时实现高可用机制(不用第三方)
1.2 redis集群搭建
1.2.1 Redis集群搭建问题说明
1.首先关闭所有的Redis服务器
2.检查配置文件编辑是否正确
3.删除多余的配置文件
4.重启redis服务器
5.搭建redis集群
redis-cli --cluster create --cluster-replicas 1 192.168.126.129:7000 192.168.126.129:7001 192.168.126.129:7002 192.168.126.129:7003 192.168.126.129:7004 192.168.126.129:7005
1.3集群入门案例
@Testpublic void testCluster(){Set<HostAndPort> sets = new HashSet<>();sets.add(new HostAndPort("192.168.126.129", 7000));sets.add(new HostAndPort("192.168.126.129", 7001));sets.add(new HostAndPort("192.168.126.129", 7002));sets.add(new HostAndPort("192.168.126.129", 7003));sets.add(new HostAndPort("192.168.126.129", 7004));sets.add(new HostAndPort("192.168.126.129", 7005));JedisCluster jedisCluster = new JedisCluster(sets);jedisCluster.set("jedis", "集群赋值");System.out.println(jedisCluster.get("jedis"));}
1.4 面试题
1.resid集群一共可以储存16384个KEY?不对的
答:16284知识槽位的数量 只负责规划这个数据归谁管理的问题,至于数据如何储存,是由redis内存决定的
hash(key1)=3000,
hash(key2)=3000,
2.Redis集群中最多可以有多少台主机?16384台主机
3.Redis中如果遇到多线程操作,是否有线程安全性问题?没有
因为:redis如何实现内存数据的优化?
LRU/LFU/随机算法/TTL
1.5 SpringBoot整合Redis集群
1.5.1编辑properties文件
说明:将redis集群的节点写入pro配置文件中
# 配置单台redis服务器
#redis.host=192.168.126.129
#redis.port=6379##配置redis分片
#redis.nodes=192.168.126.129:6379,192.168.126.129:6380,192.168.126.129:6381# redis集群配置
redis.nodes=192.168.126.129:7000,192.168.126.129:7001,192.168.126.129:7002,192.168.126.129:7003,192.168.126.129:7004,192.168.126.129:7005
1.5.2 编辑配置类
package com.jt.config;import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import redis.clients.jedis.*;import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;@Configuration //标识我是配置类
@PropertySource("classpath:/properties/redis.properties")
public class RedisConfig {//实现redis集群操作@Value("${redis.nodes}")private String nodes; //node,node,node@Beanpublic JedisCluster jedisCluster(){Set<HostAndPort> nodeSet = new HashSet<>();String[] nodeArray = nodes.split(",");for (String node : nodeArray){ //host:portString host = node.split(":")[0];int port = Integer.parseInt(node.split(":")[1]);nodeSet.add(new HostAndPort(host,port));}return new JedisCluster(nodeSet);}/*@Beanpublic ShardedJedis shardedJedis(){List<JedisShardInfo> shards = new ArrayList<>();String[] nodeArray = nodes.split(",");for (String node : nodeArray){ //node=ip:portString host = node.split(":")[0];int port = Integer.parseInt(node.split(":")[1]);//准备分片节点信息JedisShardInfo info = new JedisShardInfo(host, port);shards.add(info);}return new ShardedJedis(shards);}*//* @Value("${redis.host}")private String host;@Value("${redis.port}")private Integer port;@Beanpublic Jedis jedis(){return new Jedis(host, port);}*/
}
1.5.3 编辑AOP配置
在AOP中注入Redis缓存对象
2.京淘前台项目搭建
2.1京淘架构设计
2.2 JT-WEB项目创建
2.2.1 创建JT-WEB服务器
2.2.2 添加继承/依赖/插件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><!--项目坐标--><modelVersion>4.0.0</modelVersion><artifactId>jt-web</artifactId><!--打war包--><packaging>war</packaging><!--父级工程--><parent><artifactId>jt2007</artifactId><groupId>com.jt</groupId><version>1.0-SNAPSHOT</version></parent><!--添加依赖项--><dependencies><dependency><groupId>com.jt</groupId><artifactId>jt-common</artifactId><version>1.0-SNAPSHOT</version></dependency></dependencies><!--4.添加maven插件--><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
</project>
2.2.3 导入静态资源文件
说明:将课前资料中的文件src目录导入到jt-web中
2.2.4 关于主启动类说明
说明:jt-web服务器启动时会加载数据源的自动化配置,但是web服务器没有配置数据源,所以报错.
启动类上添加数据源启动.
2.2.5 配置工作目录
2.3 域名反向代理
需求: 要求用户通过http://www.jt.com 访问localhost:8092服务器.
2.3.1 修改hosts文件
2.3.2 修改Nginx配置文件
#配置前台服务器server {listen 80;server_name www.jt.com;location / {proxy_pass http://localhost:8092;}}
修改之后,重启nginx服务器
2.3.3 页面效果展现
2.4 谷歌浏览器禁用HTTPS
键入地址:
chrome://net-internals/#hsts:
修改完成之后,先清空缓存之后重启浏览器
2.5 开启后缀类型匹配
说明: 由于京东商城的商品展现时通过
url:https://item.jd.com/10021377498920.html,京东的访问是根据.html进行拦截,之后通过restFul结构动态获取商品的ID号,之后查询数据库进行的回显.所以需要对后缀进行拦截.有了如下的配置.
@Configuration
public class MvcConfigurer implements WebMvcConfigurer{//开启匹配后缀型配置@Overridepublic void configurePathMatch(PathMatchConfigurer configurer) {configurer.setUseSuffixPatternMatch(true);}
}
URL地址小结:
- http://www.jt.com/index 该请求会被Controller进行拦截.
- http://www.jt.com/index.html 该请求默认条件下表示获取静态资源文件.不会被拦截.
一般条件下:Controller只拦截前缀类型的请求. 如果需要拦截后缀类型的请求需要单独配置.
3 登录注册页面跳转
3.1 实现通用页面跳转
url1: http://www.jt.com/user/login.html 跳转页面 login.jsp
url2: http://www.jt.com/user/register.html 跳转页面 register.jsp
需求: 能否利用一个Controller方法.实现通用页面的跳转?
package com.jt.controller;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;@Controller
@RequestMapping("/user")
public class UserController {/*** 实现用户登录/注册页面的跳转* url1: http://www.jt.com/user/register.html* url2: http://www.jt.com/user/login.html*/@RequestMapping("/{moduleName}")public String module(@PathVariable String moduleName){return moduleName;}}
3.2 伪静态
伪静态是相对真实静态来讲的,通常我们为了增强搜索引擎的友好性,都将文章内容生成静态页面,但是有的朋友为了实时的显示一些信息。或者还想运用动态脚本解决一些问题。不能用静态的方式来展示网站内容。但是这就损失了对搜索引擎的友好性。怎么样在两者之间找个中间方法呢,这就产生了伪静态技术。伪静态技术是指展示出来的是以html一类的静态页面形式,但其实是用ASP一类的动态脚本来处理的。
总结: 以.html结尾的一种动态页面的形式…