One, Redis source installation
As of 2016.8.11,redis, the latest stable version is 3.2.3. This article is based on this version, we will explain the relevant.
Download the Redis source code and do the following:
wget http://download.redis.io/releases/redis-3.2.3.tar.gz
TAR-ZXVF redis-3.2.3.tar.gz
MV redis-3.2.3 Redis
Once the decompression is complete, start the installation now, as follows:
CD Redis
Make && make install
By, we can easily see that Redis is installed into the/usr/local,/usr/local/bin,/usr/local/share,/usr/local/include,/usr/local/lib,/usr/local/ The Share/man directory.
Then switch to the Utils directory and execute the REDIS init script install_server.sh as follows:
CD utils/
./install_server.sh
port:6379
Config File:/etc/redis/6379.conf
Log File:/var/log/redis_6379.log
Data dir:/var/lib/redis/6379
Executable:/usr/local/bin/redis-server
Cli executable:/USR/LOCAL/BIN/REDIS-CLI
copied/tmp/6379.conf =/etc/init.d/redis_6379
Through, we can see Redis initialization after Redis configuration file is/etc/redis/6379.conf, log file is/var/log/redis_6379.log, data file Dump.rdb stored to/var/lib/redis/ 6379 directory, the startup script is/etc/init.d/redis_6379.
Now we are going to use SYSTEMD, so /etc/systems/system
under Create a unit file name for redis_6379.service
.
vi/etc/systemd/system/redis_6379.service
Fill in the following, details can be seen systemd.service.
[Unit]
Description=Redis on port 6379
[Service]
Type=forking
ExecStart=/etc/init.d/redis_6379 start
ExecStop=/etc/init.d/redis_6379 stop
[Install]
WantedBy=multi-user.target
Now to view the Redis version using the Redis-cli–version command, as follows:
Redis-cli–version
Through, we can see that the Redis version is 3.2.3.
Now we can use Redis as soon as we start Redis, and this is the way to install Redis on this source.
Second, yum mode installation
After the source installation of the Redis introduction, we will again through the Yum Way to install Redis, this article is taking centos6.8 as an example. Use the following command:
RPM-UVH http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RPM-UVH http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Yum-y–enablerepo=remi,remi-test Install Redis
Once the Redis installation is complete, let's look at the related files that were created when Redis was installed, as follows:
Rpm-qa |grep Redis
RPM-QL Redis
Through, we can see that the Redis configuration file is/etc/redis.conf, the data file Dump.rdb into the/var/lib/redis/directory, the log file is/var/log/redis/redis.log, the other is the default.
Now to view the Redis version using the Redis-cli–version command, as follows:
Redis-cli–version
With this, we can see that the Yum method is actually the latest version of Redis installed.
Now we can use Redis as soon as we start Redis, and this is where the Yum approach to installing Redis is complete.
Three, Apt-get mode installation
After installing Redis in yum mode, we will now introduce the Apt-get way to install Redis under ubuntu14.04.
Based on the new and old version of the Redis installation, we made a distinction.
3.1 Apt-get
Install the latest version
To introduce the latest version of Redis, first import the Apt-get warehouse verification key, as follows:
Wget-q-O–HTTP://WWW.DOTDEB.ORG/DOTDEB.GPG | sudo apt-key add–
Or
wget HTTP://WWW.DOTDEB.ORG/DOTDEB.GPG
sudo apt-key add dotdeb.gpg
After the verification file has been installed, we will configure the Apt-get warehouse as follows:
Vim/etc/apt/sources.list.d/redis.list
Deb http://packages.dotdeb.org wheezy All
DEB-SRC http://packages.dotdeb.org wheezy All
Note: This Apt-get warehouse, we are using the Debian Apt-get warehouse, because after many tests it was found that only use this apt-get warehouse to install to the latest Redis version.
Once the Apt-get warehouse has been configured, we will now start the installation by executing the following command:
sudo apt-get clean all
sudo apt-get update
sudo apt-get-y install Redis-server
Through, we can clearly see that the version of Redis is 3.2.3, the latest version. Of course, we can also check through the redis-cli–version command. As follows:
Redis-cli–version
With this, we can see that Redis, which is currently installed in this way, is the latest version.
Iv. Configuring Redis
After the Redis installation is complete, we will configure Redis again. In fact, the installation of Redis, my side of the proposal is directly through the source code to install. Since the installation is complete, the Redis configuration file is very full.
With security in mind, we only need to enable the Redis password verification feature requirepass parameters.
The final Redis configuration file is as follows:
Grep-ev ' ^#|^$ '/etc/redis/6379.conf
Bind 127.0.0.1
Protected-mode Yes
Port 6379
Tcp-backlog 511
Timeout 0
Tcp-keepalive 300
Daemonize Yes
Supervised no
Pidfile/var/run/redis_6379.pid
LogLevel Notice
Logfile/var/log/redis_6379.log
Databases 16
Save 900 1
Save 300 10
Save 60 10000
Stop-writes-on-bgsave-error Yes
Rdbcompression Yes
Rdbchecksum Yes
Dbfilename Dump.rdb
dir/var/lib/redis/6379
Slave-serve-stale-data Yes
Slave-read-only Yes
Repl-diskless-sync No
Repl-diskless-sync-delay 5
Repl-disable-tcp-nodelay No
Slave-priority 100
Requirepass Ilanniredis
AppendOnly No
Appendfilename "Appendonly.aof"
Appendfsync everysec
No-appendfsync-on-rewrite No
Auto-aof-rewrite-percentage 100
Auto-aof-rewrite-min-size 64MB
aof-load-truncated Yes
Lua-time-limit 5000
Slowlog-log-slower-than 10000
Slowlog-max-len 128
Latency-monitor-threshold 0
Notify-keyspace-events ""
Hash-max-ziplist-entries 512
Hash-max-ziplist-value 64
List-max-ziplist-size-2
List-compress-depth 0
Set-max-intset-entries 512
Zset-max-ziplist-entries 128
Zset-max-ziplist-value 64
Hll-sparse-max-bytes 3000
activerehashing Yes
Client-output-buffer-limit Normal 0 0 0
Client-output-buffer-limit slave 256MB 64MB 60
Client-output-buffer-limit pubsub 32MB 8MB 60
Hz 10
Aof-rewrite-incremental-fsync Yes
These parameters in the configuration file are described in a later article, which is a brief introduction to the Redis configuration.
v. Start-up and use of Redis
After the Redis configuration file is configured, we'll start Redis and do a simple operation. As follows:
Redis-cli-h 127.0.0.1-p 6379-a Ilanniredis
Keys *
Set Ilanni Testredis
Get Ilanni
Let's talk a little bit about the meaning of the above command:
Redis-cli-h 127.0.0.1-p 6379-a Ilanniredis
This command says to connect a redis server, IP is 127.0.0.1, port is 6379, password is Ilanniredis.
Keys * is to view all the key-value pairs for redis.
Set Ilanni Testredis adds a key value Ilanni, with the content Testredis.
Get Ilanni View Ilanni The contents of this key value.
Transferred from: http://www.cnblogs.com/sandea/p/5782192.html
Install redis3.2.3 installation and configuration on "Linux" CentOS 7