Redis,is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
Redis, is a key-value storage system, similar to memcached, it supports more stored value types, including string (string) , List (linked list), set (collection), zset (sorted set-ordered set) and hashs (hash type). These data types all support push/pop, add/remove, intersection, union and difference, and richer operations, and these operations are all atomic. On this basis, redis supports a variety of different ways of sorting. Like memcached, in order to ensure efficiency, data is cached in memory. The difference is that redis periodically writes updated data to disk or writes modification operations to additional record files, and on this basis, it realizes master-slave (master-slave) synchronization.
Redis is a high-performance key-value database. The emergence of redis has largely compensated for the inadequacy of key/value storage such as memcached, and can play a good supplementary role in relational databases in some cases. It provides Python, Ruby, Erlang, and PHP clients, which is very convenient to use.
1、 Redis download
1 ) Download Document
Redis official download Address, download the latest version redis-2.6.14.tar.gz
2 ) Command line download
cd ~/Downloads/tool-server/``wget http://redis.googlecode.com/files/redis-2.6.13.tar.gz ``tar -zxvf redis-2.6.13.tar.gz``cd redis-2.6.13``make ``sudo make install
2、 Default installation
2.1 redis.conf
The default configuration of redis.conf is installed to the directory: /etc/redis/6379.conf
2.2、 redis log
Redis default log path: /var/log/redis_6379.log
Redis default database file path: /var/lib/redis/6379/dump.rdb
2.3、 redis command
The default directory of the redis command: /usr/local/bin/
homer2@ubuntu:/opt/redis-2.6.13$ ls -l /usr/local/bin/
total 8440
2.4 Start redis
sudo redis-server /etc/redis/6379.conf &
3、 Add redis user
**3.1、 Configure the init script: **wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server ``wget https://github.com/ijonas/dotfiles/raw/ master/etc/redis.conf ``sudo mv redis-server /etc/init.d/redis-server ``sudo chmod +x /etc/init.d/redis-server ``sudo mv redis.conf /etc/ redis.conf
3.2、 Initialize user and log path
Before starting Redis for the first time, it is recommended to create a separate user for Redis and create new data and log folders
sudo useradd redis ``sudo mkdir -p /var/lib/redis ``sudo mkdir -p /var/log/redis ``sudo chown redis.redis /var/lib/redis ``sudo chown redis.redis /var/log/redis
Note: redis is a new user, you can also use the current system default user (for example: homer), you need to modify sudo chown homer.redis /var/lib/redis
**3.3、 Set to automatically start when power is turned on, and automatically close when power off **update-rc.d redis-server defaults
**3.4、 Start Redis: **/etc/init.d/redis-server start
6、 Start client client connection
$ redis-cli
redis> set foo bar
OK
redis> get foo
" bar"
7、 Close redis
redis-cli shutdown
Reference recommendation:
Redis Tutorial (official)
Install Redis on Ubuntu and configure it to start on boot
Detailed explanation of Redis installation under Linux (recommended)
Recommended Posts