-------------ssdb双主部署---------------------------
环境:
OS: centos7
ip:
192.168.1.134
192.168.1.135
-------------------下面先在192.168.1.134上面安装----------------------------
1.下载安装介质
[root@localhost soft]# wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
2.解压安装
[root@localhost soft]# unzip master.zip
[root@localhost soft]# cd ssdb-master/
[root@localhost ssdb-master]# make
$ # 将安装在 /usr/local/ssdb 目录下 或者指定目录 make install PREFIX=/home/oracle/ssdb/ssdb-master,该目录事先不需要创建
[root@localhost ssdb-master]# make install PREFIX=/home/oracle/ssdb/ssdb-master
3.创建相应目录
数据目录
[root@localhost ssdb-master]# mkdir -p /home/oracle/ssdb/data
日志目录
[root@localhost ssdb-master]# mkdir -p /home/oracle/ssdb/logs
4.修改权限目录
将ssdb目录修改为业务账号的归属,以后会使用业务账号启动
[root@localhost oracle]# cd /home/oracle
[root@localhost oracle]# chown -R oracle:oracle ./ssdb
5.修改配置文件
[oracle@localhost ssdb-master]$ more ssdb.conf
# ssdb-server config
# MUST indent by TAB!
# absolute path, or relative to path of this file, directory must exists
work_dir = /home/oracle/ssdb/data
pidfile = /home/oracle/ssdb/ssdb.pid
server:
ip: 0.0.0.0
port: 6258
# 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: 5
auth: mypasswd
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:port will be used.
id: svc_2
# sync|mirror, default is sync
type: mirror
host: 192.168.1.135
port: 6258
auth: mypasswd
logger:
level: info
output: /home/oracle/ssdb/logs/log.txt
rotate:
size: 1000000000
leveldb:
# in MB
cache_size: 500
# in MB
write_buffer_size: 64
# in MB/s
compaction_speed: 1000
# yes|no
compression: yes
-------------------下面先在192.168.1.135上面安装----------------------------
步骤1至步骤4安装一样,步骤5的配置如下:
[oracle@localhost ssdb-master]$ more ssdb.conf
# ssdb-server config
# MUST indent by TAB!
# absolute path, or relative to path of this file, directory must exists
work_dir = /home/oracle/ssdb/data
pidfile = /home/oracle/ssdb/ssdb.pid
server:
ip: 0.0.0.0
port: 6258
# 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: 5
auth: mypasswd
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:port will be used.
id: svc_2
# sync|mirror, default is sync
type: mirror
host: 192.168.1.134
port: 6258
auth: mypasswd
logger:
level: info
output: /home/oracle/ssdb/logs/log.txt
rotate:
size: 1000000000
leveldb:
# in MB
cache_size: 500
# in MB
write_buffer_size: 64
# in MB/s
compaction_speed: 1000
# yes|no
compression: yes
--------------------启动----------------------------------------------------
1.启动192.168.1.134
[root@localhost oracle]# su - oracle
[oracle@localhost ~]$ cd /home/oracle/ssdb/ssdb-master
[oracle@localhost ~]$./ssdb-server -d /home/oracle/ssdb/ssdb-master/ssdb.conf
2.启动192.168.1.135
[root@localhost oracle]# su - oracle
[oracle@localhost ~]$ cd /home/oracle/ssdb/ssdb-master
[oracle@localhost ~]$./ssdb-server -d /home/oracle/ssdb/ssdb-master/ssdb.conf
-------------------验证-------------------------------------------------------
1.连接到节点1(192.168.1.134)写入测试数据
[oracle@localhost ssdb-master]$ ./ssdb-cli -p 6258
ssdb 127.0.0.1:6258> auth mypasswd
ssdb 127.0.0.1:6258> set name jack
ok
(0.000 sec)
ssdb 127.0.0.1:6258> set age 18
ok
(0.000 sec)
ssdb 127.0.0.1:6258> get age
18
(0.000 sec)
ssdb 127.0.0.1:6258> get name
jack
(0.000 sec)
2.连接到另外一个节点(192.168.1.135)
[oracle@localhost ssdb-master]$ ./ssdb-cli -p 6258
ssdb 127.0.0.1:6258> auth mypasswd
ok
(0.000 sec)
ssdb 127.0.0.1:6258> get age
18
(0.001 sec)
ssdb 127.0.0.1:6258> get name
jack
(0.000 sec)
可以看到另外的节点看到了数据
3.反过来验证,在192.168.135写入数据
set age01 20
set name01 hxl
--------------------停止-----------------------------------------------------
./ssdb-server /home/oracle/ssdb/ssdb-master/ssdb.conf -s stop
----------数据迁移----------------
1.将原库的数据导出
导出整个数据库:
./ssdb-cli -p 6258
ssdb 127.0.0.1:6258> auth mypasswd
export backup0820.ssdb
2.scp到目的机器
然后拷贝到ssdb的目录下
[yeemiao@localhost soft]$ cp backup0820.ssdb /home/yeemiao/ssdb/ssdb-master/
3.导入
在目的机器上进行导入
./ssdb-cli -p 6258
ssdb 127.0.0.1:6258> auth mypasswd
ssdb 127.0.0.1:6258> import backup0820.ssdb
------------------遇到的问题------------------------------------------------
1.需要安装autoconf
[root@localhost ssdb-master]# make
ERROR! autoconf required! install autoconf first
Makefile:4: build_config.mk: No such file or directory
make: *** No rule to make target `build_config.mk'. Stop.
2.配置参数问题
[oracle@localhost ssdb-master]$ ./ssdb-server -d /home/oracle/ssdb/ssdb-master/ssdb.conf
ssdb-server 1.9.7
Copyright (c) 2012-2015 ssdb.io
2019-08-20 08:49:53.301 [ERROR] config.cpp(62): invalid line(23): unexpected whitespace char ' '
error loading conf file: '/home/oracle/ssdb/ssdb-master/ssdb.conf'
原因分析:因为auth敲的是空格,需要修改为tab键
解决办法:改为tab键
3.无法连接对方
2019-08-20 09:05:18.080 [ERROR] slave.cpp(174): [svc_2]failed to connect to master: 192.168.1.135:6528! Connection refused
2019-08-20 09:05:23.084 [INFO ] slave.cpp(171): [svc_2][150] connecting to master at 192.168.1.135:6528...
2019-08-20 09:05:23.084 [ERROR] slave.cpp(174): [svc_2]failed to connect to master: 192.168.1.135:6528! Connection refused
原因是端口写错,修改正确的即可