测试环境
# cat /etc/redhat-release
CentOS release 6.4 (Final)
1.1 必备软件
yum install –y wget unzip gcc gcc-c++
1.2 下载安装
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
unzip master
cd ssdb-master
make
# optional, install ssdb in /usr/local/ssdb
sudo make install
1.3 启动
# start master
./ssdb-server ssdb.conf
# or start as daemon
./ssdb-server -d ssdb.conf
# ssdb command line
./tools/ssdb-cli -p 8888
# stop ssdb-server
kill `cat ./var/ssdb.pid`
1.4 制作启动脚本
copy tools/ssdb.sh /etc/init.d/ssdb
vim /etc/init.d/init.d/ssdb.conf #修改配置文件路径
---------------------------------------------------# ssdb Start ssdb
#
# chkconfig: 2345 08 92
# description: Starts, stops and saves tomcat
#
# config: /usr/local/ssdb/ssdb.conf
#
### BEGIN INIT INFO
# Provides: ssdb
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop ssdb
# Description: Start, stop and save ssdb
### END INIT INFO
configs=/usr/local/ssdb/ssdb.conf---------------------------------------------------
#设置开机自启动
chkconfig --add ssdb
chkconfig ssdb on
1.5 设置环境变量
vim /etc/profile
--------------------------------------------------SSDB_HOME=/usr/local/ssdb
PATH=$SSDB_HOME:$PATH
export SSDB_HOME PATH--------------------------------------------------
source /etc/profile
1.6 SSDB主从复制
主:
# cat /usr/local/ssdb/ssdb.confserver:
ip: 192.168.16.202 #修改
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 #修改从:
# cat /usr/local/ssdb/ssdb.confserver:
ip: 192.168.16.201 #修改
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 #修改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: sync #修改
ip: 192.168.16.202 #修改
port: 8888 #修改主从:
#./ssdb-server -d ssdb.conf
或
# /etc/init.d/ssdb restart
主从:
# /usr/local/ssdb/ssdb-cli -h 192.168.16.201 -p 8888
# /usr/local/ssdb/ssdb-cli -h 192.168.16.202 -p 8888
1.6 修改jar包启动脚本
-Dapplication.ssdb.master.host=192.168.16.202 -Dapplication.ssdb.master.port=8888 -Dapplication.ssdb.slave.host=192.168.16.201 -Dapplication.ssdb.slave.port=8888
参考:
http://ssdb.io/docs/install.html
http://ssdb.io/docs/config.html
https://github.com/ssdb/phpssdbadmin