CentOS: Install redis and centosredis in a compressed package
Install the C language environment
Redis isC language development and installationRedis needs to compile the source code downloaded from the official website and compile the dependency.Gcc environment. If noInstall the gcc EnvironmentRun the following command to install gcc:
yum install gcc-c++
Install redis
DownloadDownload the latest apsaradb for redis package to your local device.
wget https://download.redis.io/releases/redis-4.0.8.tar.gz
Decompress the downloaded package
tar zxvf redis-4.0.8.tar.gz
Go to the decompressed folder
cd redis-4.0.8
Execute the compilation command
make
After compilation, start InstallationFor redis, We need to specify an installation directory. My installation directory is:/Usr/soft/redis. You can specify the installation directory as needed.
make PREFIX=/usr/soft/redis install
The installation is complete ,:
Now, go to the installation directory and find that there is only oneBin directory,
Now, go to the decompressed directory of the original compressed package and findRedis. conf file
SetCopy the redis. conf file to the installation directory. The Copy command is as follows:
// Copy the redis. conf file to the/usr/soft/redis directory cp redis. conf/usr/soft/redis
Now go to the installation directory and view the Directory
We can see that there is only oneBin directory, now there is anotherRedis. conf configuration file.
Now we useEnable vimModify redis. confStart redis in the background
daemonize no
Change
daemonize yes
After modification,
UseIn the bin directoryRedis-server File startupRedis, and loadRedis. conf configuration file. The command is as follows:
./bin/redis-server redis.conf
Started successfully,
CheckRedis Port
ps -ef | grep -i redis
We can see thatRedis is up. The port number is6379. The process is24543
Stop redis Service
RunRedis installation directoryIn the bin directoryRedis-cli command, stopRedis Service
./bin/redis-cli shutdown
After stopping, let's checkRedis process information. The command is as follows:
ps -ef | grep -i redis
Effect
We can see that noThe redis-server process provesThe redis service has stopped.
Connect to the redis Database
RunRun the following command to connect to the database through redis-cli:
./bin/redis-cli
Effect:
Here we have successfully connectedRedis database.
After the connection is completed, we need to disconnect the client because there are a limited number of connected clients. The following command is used to disconnect the client:
exit
Effect
Here we have successfully connected the Port Database.