Redis study notes (2) redis installation

introduction

Redis is developed in C language. To install redis, you need to compile the source code downloaded from the official website first, and the compilation depends on the gcc environment.

Install GCC compilation environment

Start installing the gcc environment and
enter the command:

yum install gcc-c++

If an error occurs, the following is reported:

[root@localhost xueshanfeitian]# yum install gcc-c++
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

Need to pay attention to re-establish the yum command environment
1. First modify the fastestmirror.conf, the modification command is:

vi /etc/yum/pluginconf.d/fastestmirror.conf
#修改
enable=0

Or directly enter in the command

sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf
  1. Move the previous repo to the backup first
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

Replace server url

curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo

Perform yum update

yum clean all
yum makecache

After the yum environment is updated, you can install the gcc environment

Uninstall gcc

When you need to uninstall gcc, you need to note that gcc depends on other packages. If you want to uninstall gcc, you need to uninstall other dependent environments.
View the gcc installation package

rpm -q gcc

Uninstall the gcc installation package

gcc -e gcc-4.4.7-23.el6.x86_64

Uninstallation failed

[root@localhost xueshanfeitian]# rpm -e gcc-4.4.7-23.el6.x86_64
error: Failed dependencies:
	gcc = 4.4.7-23.el6 is needed by (installed) gcc-c++-4.4.7-23.el6.x86_64

View gcc detailed information,
Insert picture description here
first uninstall dependent packages

rpm -e gcc-c++-4.4.7-23.el6.x86_64

Uninstall the gcc installation package again

gcc -e gcc-4.4.7-23.el6.x86_64

Check gcc again, uninstall successfully
Insert picture description here

Install redis in linux

Through two methods of local installation and online installation, online installation can directly enter the command to download:

wget http://download.redis.io/releases/redis-6.0.9.tar.gz

When installing offline, download the offline installation package and upload it to the server.

rz  

Unzip redis

tar -zxvf redis-6.0.9.tar.gz -C ./redis/

Compile the redis source code and enter the redis directory and execute make directly (very different from nginx)

make

There is a problem with the matching of the gcc version of the Linux installation and the redis version in
Xiaoyuan . It is necessary to install a lower version of redis. Xiaoyuan installed and replaced the redis version.

redis-5.0.10.tar.gz

The gcc version is:

gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 

Install after make

make PREFIX=/usr/local/redis/redis-5.0.10 install

Insert picture description here
Successful installation.
Or you can directly enter the command

make && make -PREFIX = /usr/local/redis/redis-5.0.10/  install

This execution directly puts the generated executable file in the src directory, and the first installation method is recommended.
Copy reidis to the bin directory:

After the installation is complete, start redis.

./redis-server ./redis.conf

You can see the redis startup interface

cp redis.conf ./bin

How to exit redis? At this point you can press ctrl+ckey to achieve out redis.

Guess you like

Origin blog.csdn.net/xueshanfeitian/article/details/111310592