mac install redis, build clusters

The following is a practice version 5.0.5

1, download the zip package, download address: https://redis.io/  

2, install redis

(1) extracting ~ / Downloads / redis-5.0.5.tar.gz of ~ / Downloads / redis-5.0.5

(2) After extracting the package moves to the / usr / local: 

sudo mv ~/Downloads/redis-5.0.5 /usr/local/

(3) Installation redis:

cd /usr/local/redis-5.0.5
make install 

(Here the emergence of a small episode, install redis need xcode-select, execute the command terminal xcode-select --install, specific principle is not clear)

At this point redis already started, test: redis-server

3, Configuration

(1) add configuration directory

sudo mkdir /usr/local/redis-5.0.5/bin
sudo mkdir /usr/local/redis-5.0.5/etc
sudo mkdir /usr/local/redis-5.0.5/db

(2) execute the following Copy src directory file to the bin directory: mkreleasehdr.sh, redis-benchmark, redis-check-rdb, redis-cli, redis-server

sudo cp /usr/local/redis-5.0.5/src/mkreleasehdr.sh. 
sudo cp /usr/local/redis-5.0.5/src/redis-benchmark. 
sudo cp /usr/local/redis-5.0.5/src/redis-check-rdb. 
sudo cp /usr/local/redis-5.0.5/src/redis-cli. 
sudo cp /usr/local/redis-5.0.5/src/redis-server

(3) create a configuration file in etc, is enough if a single configuration is as follows (redis.conf):

# Amended as guardian mode 
daemonize yes 
# set the process lock file 
the PidFile /usr/local/redis-5.0.5/redis.pid 
# port 
Port 6379 
# client timeout 
timeout 300 
# log level 
the LogLevel Debug 
# log file location 
logfile / usr /local/redis-5.0.5/log-redis.log 
number # database setup, the default database is 0, may be used SELECT <dbid> specified database command on the connection ID 
databases 16 
## specify how long, there how many times the refresh operation, the data will be synchronized to the data file, a plurality of conditions can be fit 
#save <seconds the> <Changes> 
#Redis default profile provided three conditions: 
Save 900. 1 
Save 300 10 
Save 60 10000 
# specified storage whether data compression to the local database, the default is yes, Redis using LZF compression, if the CPU in order to save time, 
# # can turn off the option, but will cause the database files become huge 
rdbcompression yes 
# specify the local database file name 
dbfilename dump.rdb 
# specify the local database path
/usr/local/redis-5.0.5/db/ dir 
# specify whether logging after every update operation, Redis default asynchronous data is written to disk, if not open, probably 
# will break cause data loss over a period of time when electricity. Because redis itself to synchronize data file is based on the above criteria to save synchronization, so there 
# data will exist only in the memory for some time 
appendOnly NO 
# specified condition update log, there are three possible values: 
#no: representation, etc. operating system to synchronize data cache to disk (fast) 
#always: indicates that the call after each update manually fsync () writes data to disk (slow, safe) 
#everysec: indicate synchronization once per second (a compromise, the default value) 
appendfsync everysec

A clustered environment you need to add multiple configurations (redis-6370.conf, redis-6371.conf, convenience write only two), the path may be allocated according to personal preferences, configure content than the more with a single the following configurations:

# Enable the cluster 
Cluster-Enabled yes 
# node of the corresponding node configuration file 
Cluster-config-File Redis-6370.conf 
# cluster timeout 
cluster-node-timeout 5000

4, start the service

Bin directory to move, performing redis-server [specified profile]

sudo redis-server ../etc/redis-6370.conf
sudo redis-server ../etc/redis-6371.conf

Execute scripts

redis-cli --cluster create 127.0.0.1:6370 127.0.0.1:6371 --cluster-replicas 1

5, node operation

(1) View node: redis-cli -h 127.0.0.1 -c cluster nodes

(2) additional nodes: redis-cli --cluster add-node 127.0.0.1:6372 127.0.0.1:6373

(3) delete a node: redis-cli --cluster del-node 127.0.0.1:6373

 

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/longc-pub/p/11123050.html