一、安装centos系统

此处略去N个字

二、更换centos源

由于默认安装的centos源大陆访问比较慢,所有可以考虑更换一下源

首先备份下原来的源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

然后用vim新建一个文件CentOS-Base.repo

vim /etc/yum.repos.d/CentOS-Base.repo

记得进入vim后先按一下键盘i键,确保进入插入模式,然后再进行下面代码的复制粘贴

此处的代码是清华源,其他源同理,找到对应的,粘贴进去即可

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever – Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever – Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever – Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever – Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

然后刷新缓存更新源

sudo yum makecache

完成。

三、安装gcc

Linux下需要编译源码安装,源码是c,所以需要安装gcc进行编译,默认centos安装的时候如果选了开发相关,应该会自带gcc。

此处安装略过,如有需要再补充

四、安装Redis

下载redis,新版的可以从这里找到http://redis.io/download

此处以6.0.8版本为例

wget下载

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

然后

tar -zxvf redis-6.0.8.tar.gz

解压缩,然后make指令进行编译

 

然后进入到cd /usr/local/redis/bin/ 目录

然后运行redis进行测试

 


cd /usr/local/redis/bin/

./redis-server

 

注意点:

上面的方法可以正常运行server,但是如果用python等,链接redis服务的时候会报下面错误

DENIED Redis is running in protected mode because protected mode is enabled…………

配置文件redis.conf里面修改

tected-mode yes 为tected-mode no

然后启动的时候用下面命令指定你修改的那个配置文件进行启动即可解决。

./redis-server ./xxx/xxx/redis.conf

如果你使用的是虚拟机或其他服务器(不是本地电脑),可能会出现下面报错

!!前提是你要确保填写的服务器地址端口等信息,以及确保redis服务已启用的情况下(因为这种情况和上述情况的报错相同)

redis.exceptions.ConnectionError: Error 10061 connecting to 192.168.73.128:6379. 由于目标计算机积极拒绝,无法连接。

修改redis.conf,将其中的bind 127.0.0.1修改为bind 0.0.0.0,然后再指定配置文件启动即可。

说点什么
请务必填写正确的邮件地址,当有回复时您会收到邮件提醒。
支持Markdown语法
好耶,沙发还空着ヾ(≧▽≦*)o
Loading...