Method One: source file installation (recommended installation)
In CentOS and Red Hat systems, warehouse EPEL added first, then update the yum source:
yum install epel-release
yum update
Then install Redis database:
yum -y install redis
After installation you can start the Redis service:
systemctl start redis
View redis server back up and running
systemctl status redis.service
Used herein can also enter Redis redis-cli command line mode.
Further, in order Redis can be remotely connected, you need to modify the configuration file, path /etc/redis.conf
we /etc/redis.conf
The needs of local changes:
First, the comment line:
#bind 127.0.0.1
In addition, it is recommended to set a password Redis, uncomment this line:
#requirepass foobared
foobared i.e. current password, can modify to
requirepass password
Redis then restart the service, use the following command:
systemctl restart redis
redis other commands
Start redis.service systemctl # start redis server systemctl redis.service STOP # Stop redis server systemctl redis.service restart # restart redis server systemctl Status redis.service # get redis servers running state systemctl enable redis.service # boot server redis disable redis.service systemctl # boot disabled redis server
Method II: Installation compressed
First, install
1, in the official website to download tar.gz installation packages, or download via wget
wget http://download.redis.io/releases/redis-4.0.1.tar.gz
2, unzip
takes -zxvf Redis-4.0.1.tar.gz
3. Compile
Compiled by make, make is automatically compiled, the compiler will be described in accordance with the content Makefile.
cd redis-4.0
make
We can see into several new files in the src directory swells.
4, installation
make install
In fact, this is several files added to / usr / local / bin directory down. This directory in the Path following words, you can directly execute these commands.
You can see, these files had been loaded into the bin directory
5, start the server, to see if the installation was successful.
Use redis-server command.
Restart a linux client, redis-cli Open Client
6, shut down the server
Restart a linux client to shut down the server by server-cli shutdown.
Second, the configuration
1, redis server daemon startup settings
After starting the server front redis are started in the foreground, it needs to restart a client to login. This is very inconvenient,
So, we need to set the background to start.
daemonize no
change into:
daemonize yes
Uninstall redis
Uninstall redis service, simply redis under / usr / local / bin / directory can be deleted
rm -rf /usr/local/bin/redis*
You can even extract the package is also deleted
rm -rf /root/redis-stable