陈皈莫守 發表於 2020-6-10 15:58:00

centos安装redis(rpm)

<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">
第一、redis安装错误提示
</span><span style="color: rgba(255, 0, 255, 1)"> yum -</span><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(255, 0, 255, 1)">y install redis</span>

Loaded plugins: fastestmirror
Loading mirror speeds </span><span style="color: rgba(0, 0, 255, 1)">from</span> cached hostfile
* <br><span style="color: rgba(0, 0, 255, 1)">base</span>: centos.sonn.com
* extras: mirror.supremebytes.com
* <br>updates: mirrors.cat.pdx.edu
Setting up Install Process<br><strong><span style="color: rgba(255, 0, 0, 1)">
No package redis available.</span></strong><br>
Error: Nothing to <span style="color: rgba(0, 0, 255, 1)">do</span><span style="color: rgba(0, 0, 0, 1)">
在安装redis的时候有出现</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">No package redis available</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">错误提示,这个提示应该是当前的系统中没有redis应用安装源,我们需要从第三方下载到当前目录下然后进行安装后才可以执行。

第二、下载EPEL对应的版本和安装
版本寻找地址:http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">fedoraproject.org/wiki/EPEL</span>
<span style="color: rgba(0, 0, 0, 1)">我需要的是centos64位,我直接找到源后wget下载到当前目录:
<span style="color: rgba(255, 0, 255, 1)">wget http:</span></span><span style="color: rgba(255, 0, 255, 1)">//dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
</span><span style="color: rgba(0, 0, 0, 1)">然后进行安装:
<span style="color: rgba(255, 0, 255, 1)">rpm </span></span><span style="color: rgba(255, 0, 255, 1)">-ivh epel-release-6-8</span><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(255, 0, 255, 1)">.noarch.rpm
</span>
第三、安装redis
<span style="color: rgba(255, 0, 255, 1)">yum install redis
</span>然后我们再执行安装命令就可以正常的安装,期间会提到需要输入y回车我们就根据提示输入回车直到安装完毕。
PS:同样的,如果我们在安装nginx的时候出现</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">No package nginx available</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">提示也是通过这个方法解决,安装EPEL库就可以解决。


redis服务常用命令
</span><span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">,启动redis
service redis start

</span><span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">,停止redis
service redis stop

</span><span style="color: rgba(128, 0, 128, 1)">3</span><span style="color: rgba(0, 0, 0, 1)">,查看redis运行状态
service redis status

</span><span style="color: rgba(128, 0, 128, 1)">4</span><span style="color: rgba(0, 0, 0, 1)">,查看redis进程
ps </span>-ef |<span style="color: rgba(0, 0, 0, 1)"> grep redis

</span><span style="color: rgba(128, 0, 128, 1)">5</span><span style="color: rgba(0, 0, 0, 1)">,设置redis为开机自动启动
chkconfig redis on

</span><span style="color: rgba(0, 128, 0, 1)"><strong>6</strong></span><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 128, 0, 1)"><strong>,</strong></span>编辑redis配置文件
vim </span>/etc/<span style="color: rgba(0, 0, 0, 1)">redis.conf
在文件中找到绑定到本机文本注释掉
# 找到 bind </span><span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span><span style="color: rgba(0, 0, 0, 1)"> 将其注释取消绑定本地地址
# 找到 </span><span style="color: rgba(0, 0, 255, 1)">protected</span>-mode yes 将其改为 <span style="color: rgba(0, 0, 255, 1)">protected</span>-<span style="color: rgba(0, 0, 0, 1)">mode no.在没有密码的情况下,关闭保护模式
#把daemonize no改为daemonize&nbsp;yes&nbsp; &nbsp;(是否为进程守护,关闭ssh窗口后即是否在后台继续运行)<br><br><br>ps:有时候服务器中redis启动了,但是客户端连接不上,这个需要把<strong><span style="color: rgba(0, 128, 0, 1)">步骤6</span></strong></span><span style="color: rgba(0, 0, 0, 1)">中的配置完成,主要是bind和protected-mode 然后就可以了,如果还不可以<br>,那么,可能启动的时候使用的默认配置文件不是你修改的这个,需要指定配置文件启动<br>   ./redis-server /xx/redis.config</span></pre>
</div>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/renjianjun/p/13085805.html
頁: [1]
查看完整版本: centos安装redis(rpm)