下载源码
reids
解压编译
# 解压
tar -zxvf redis-5.0.14.tar.gz
cd redis-5.0.14/
make PREFIX=/opt/redis install
#
requirepass root
# 开启远程访问
bind 0.0.0.0
protected-mode no
# 修改日志打印路径,修改redis.conf
daemonize yes
logfile /var/log/redis.log
# 运行
./redis-server redis.conf
redis 国产数据库编译问题
Redis - 适配全国产操作系统的那些坑
编译aarch 架构问题:
因操作系统PAGE SIZE差异,导致的启动报错 [jemalloc] unsupported system page size
# 查看操作系统
cat /proc/version
....ubuntu...
....desktop....
getconf PAGESIZE
原因:
arm64下,centos的pagesize是64k,Ubuntu的是4k,64k下编译的镜像可以在64k以及一下的环境下运行,如果在4k环境下编译的不能在大于4k的环境下运行,是jemalloc造成的问题
spring boot redis jar包
redis 工具项目
maven 打包
<!-- redis 缓存操作 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<project>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- pool 对象池 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<resource>META-INF/spring.handlers</>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<resource>META-INF/spring.schemas</>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
resource下新建META-INF
新建spring.factories,内容如下,package.Classname
org.springframework.boot.autoconfigure.EnableAutoConfigration=\
bean1,\
bean2
spring boot 项目引入redis.jar
# 启动类中去除
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@SpringBootApplication(exclude = [ DataSourceAutoConfiguration.class,RedisRepositoriesAutoConfigration.class])
# redis使用,@Autowired 自动注入
redisTemplateUtil.restore("version0","1.1")
redis cli
./redis-cli -h 127.0.0.1 -p 6379 -a 1234
select 1
get key
./redis-cli -h 127.0.0.1 -p 6379
auth 1234
©
著作权归作者所有,转载或内容合作请联系作者
喜欢的朋友记得点赞、收藏、关注哦!!!