mkdir /config
ssdb.conf
传入虚拟机的config
目录内1.注意不要给ssdb设置密码,太长(32个字符)。
2.work_dir
是工作目录,可以随意改
3.ip
表示允许什么样的ip
来访问ssdb
4.0.0.0.0
代表允许所有用户访问
# ssdb-server config
# MUST indent by TAB!
# absolute path, or relative to path of this file, directory must exists
work_dir = /ssdb/var
pidfile = /run/ssdb.pid
server:
ip: 0.0.0.0
port: 8888
# bind to public ip
#ip: 0.0.0.0
# format: allow|deny: all|ip_prefix
# multiple allows or denys is supported
#deny: all
#allow: 127.0.0.1
#allow: 192.168
# auth password must be at least 32 characters
#auth: very-strong-password
#readonly: yes
# in ms, to log slowlog with WARN level
#slowlog_timeout:
replication:
binlog: yes
# Limit sync speed to *MB/s, -1: no limit
sync_speed: -1
slaveof:
# to identify a master even if it moved(ip, port changed)
# if set to empty or not defined, ip: 0.0.0.0
#id: svc_2
# sync|mirror, default is sync
#type: sync
#host: localhost
#port: 8889
logger:
level: info
output: stdout
rotate:
size: 1000000000
leveldb:
# in MB
cache_size: 500
# in MB
write_buffer_size: 128
# in MB/s
compaction_speed: 1000
# yes|no
compression: yes
1.-v /ssdb/var:ssdb/var
表示把虚拟机中的工作目录挂载到docker容器中的ssdb/var
目录下,虚拟机中没有的话会创建一个。
2.-v /config/ssdb.conf:/ssdb/ssdb.conf
表示把配置文件从虚拟机啊中挂载到容器中的工作目录下
3.如果直接把配置文件托进虚拟机中,配置文件有可能会变成文件夹,导致ssdb启动失败。
docker run -d --name su-ssdb -p 8888:8888 -v /ssdb/var:/ssdb/var -v /config/ssdb.conf:/ssdb/ssdb.conf leobuskin/ssdb-docker
1.java操作ssdb
和操作redis
一回事。
2.尽量不要向ssdb
中存放list
类型的数据
1.此处导入了nacons注册中心和配置中心
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
1.ssdb可以使用redis的配置文件属性。
3.最后的就是ssdb配置文件
server:
port: 8085
spring:
application:
name: catch
profiles:
active: regist
cloud:
nacos:
config:
server-addr: 192.168.19.132:8848
file-extension: yml
prefix: su
redis:
host: 192.168.19.132
port: 8888
@RunWith(SpringRunner.class)
@SpringBootTest(classes = CatchApp.class)
public class Test {
@Resource
RedisTemplate redisTemplate;
@org.junit.Test
public void handler(){
redisTemplate.opsForValue().set("abc","111111");
String abc = (String)redisTemplate.opsForValue().get("abc");
System.out.println(abc);
}
}