ssdb install

Pre-installed software

 

   yum -y install gcc automake autoconf libtool make

   yum -y install gcc gcc-c++ glibc

   yum -y install libmcrypt-devel mhash-devel libxslt-devel 

 

Download package  

wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
unzip master
cd ssdb-master  make
# will be installed in /usr/local/ssdb directory or specified directory make install PREFIX =/home/servers/ssdb
$ sudo make install

# Specify the installation directory

make install PREFIX=/software/ssdb

 

# Start the main library, you can also customize the configuration file, start multiple instances
$ ./ssdb-server ssdb.conf

 

 

# start, stop, restart
# $ ./ssdb-ins.sh start/stop/restart ssdb.conf

# Start as a background process
$ ./ssdb-server -d ssdb.conf

# Start the ssdb command line, under the installation package path, 8889 is the port of the main library
$ /export/servers/ssdb-master/tools/ssdb-cli -p 8889
# Connect the command line of the remote SSDB service
# $ /export/servers /ssdb-master/tools/ssdb-cli -h 192.168.1.1 -p 8889

# To stop ssdb-server, you need to manually stop the SSDB service by default
. $ kill `cat ./var/ssdb.pid`
# Or find the pid of the current SSDB process first, and then kill it
# $ ps -ef|grep 'ssdb'
# $ kill -9 6912

 

 

 

 

Master-master, master-slave configuration:

The service port configuration of the current instance
server:
 #ip: 127.0.0.1
 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


The master and slave
 take the master library ip: 192.168.1.1 as an example to introduce
#server 1 (master) 
replication:
 slaveof:


#server 2(从)
replication:
 slaveof:
  id: svc_1
  # sync|mirror, default is sync
  type: sync
  ip: 192.168.1.1
  port: 8888


Master-master (dual master)
 The following takes the master library ip: 192.168.1.1/192.168.1.2 as an example to introduce
#server 1
replication:
 slaveof:
  id: svc_2
  # sync|mirror, default is sync
  type: mirror
  ip: 192.168.1.1
  port : 8889


#server 2
replication:
 slaveof:
  id: svc_1
  # sync|mirror, default is sync
  type: mirror
  ip: 192.168.1.2
  port: 8888

 

 

 

Notice:

1. If there is a system failure such as downtime, power failure, kernel panic, etc., you need to manually delete the PID file of SSDB. If you put tools/ssdb.sh in /etc/init.d/, the PID will be automatically deleted after restarting;
2. Default configuration The log files are separated by volume, and you need to write your own crontab for log compression and regular cleaning;
3. The configured IP is preferably 0.0.0.0, which can be accessed externally. If it is 127.0.0.1, it can only be accessed locally.

Using the SSDB command line client (ssdb-cli)

The command line client of SSDB, ssdb-cli, can be used for daily management, including viewing the running status (info) of SSDB, and can also do some operations that the API does not have, such as clearing the entire database.

1. Run the line ssdb-cli
# connect to 127.0.0.1:8888,
$ /usr/local/ssdb/ssdb-cli -h 127.0.0.1 -p 8888


You can enter the letter h and press Enter to view help information.

2. Perform row KV operation
ssdb 127.0.0.1:8888>get key
ssdb 127.0.0.1:8888>set key 1
ssdb 127.0.0.1:8888>del key


3、进行行 hashmap 操作
ssdb 127.0.0.1:8888> hsize h
ssdb 127.0.0.1:8888> hset h k1 vb
ssdb 127.0.0.1:8888> hset h k2 va
ssdb 127.0.0.1:8888> hset h k3 vc
ssdb 127.0.0.1:8888> hscan h "" "" 10
ssdb 127.0.0.1:8888> hclear h


4、进行行 zset 操作
ssdb 127.0.0.1:8888> zsize z
ssdb 127.0.0.1:8888> zset z k1 2
ssdb 127.0.0.1:8888> zset z k2 0
ssdb 127.0.0.1:8888> zset z k3 1
ssdb 127.0.0.1:8888> zscan z "" "" "" 10
ssdb 127.0.0.1:8888> zclear z

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326176454&siteId=291194637