Docker搭建Minio

命令

1
docker run -p 9000:9000 -p 9090:9090 --name minio -e "MINIO_ACCESS_KEY=minio" -e "MINIO_SECRET_KEY=password" -e "TZ=Asia/Shanghai" -v E:/Docker/minio-RELEASE.2023-06-02T23-17-26Z/data/:/data/ -v E:/Docker/minio-RELEASE.2023-06-02T23-17-26Z/config/:/root/.minio -d --restart=always minio/minio:RELEASE.2023-06-02T23-17-26Z server /data --console-address ":9090" -address ":9000"

访问http://127.0.0.1:9000

RedisTemplate操作Redis

大环境

pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.10</version>
<relativePath/>
</parent>
<dependencys>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencys>
redis配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class RedisConfiguration {

/**
* @Description redis模板配置
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(stringRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
template.setHashValueSerializer(stringRedisSerializer);
template.setDefaultSerializer(stringRedisSerializer);
template.afterPropertiesSet();
return template;
}
}

批量模糊删除

1
2
Set<String> keys = redisTemplate.keys("MENU:*");
redisTemplate.delete(keys);

MySQL-8.0.24主从环境搭建

docker搭建创建MySQL容器

master主库
1
docker run -d -p 3316:3306 -e MYSQL_ROOT_PASSWORD=password -e TZ=Asia/Shanghai --name mysql-8.0.24-master mysql:8.0.24 --lower-case-table-names=1 --default-authentication-plugin=mysql_native_password
阅读更多