从零开始搭建系统1.5——Redis安装及配置
1.在/usr/目录下创建redis目录
[root@localhost usr]# mkdir redis
2.下载安装包
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
3.安装gcc,由于编译需要gcc如果没有安装的话需要安装
yum install gcc
查看gcc版本,会看到详细的版本信息,安装GCC就完成了
4.解压安装包并安装
tar -zxvf redis-4.0.8.tar.gz
cd redis-4.0.8
make MALLOC=libc
5.启动redis
先切换到redis src目录下
直接启动redis
./redis-server

如上图:redis启动成功,但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。
按 ctrl + c可以关闭窗口。
6.将/usr/local/redis-4.0.6/src目录下的文件加到/usr/local/bin目录
cd src && make install

7.设置redis开机自启动
在/etc目录下新建redis目录
将/usr/redis/redis-4.0.8/redis.conf 文件复制一份到/etc/redis目录下,并命名为6379.conf
cp /usr/redis/redis-4.0.8/redis.conf /etc/redis/6379.conf
设置为后台方式运行,修改6379.conf文件
将
daemonize no
修改为
daemonize yes
将redis的启动脚本复制一份放到/etc/init.d目录下
cp /usr/redis/redis-4.0.8/utils/redis_init_script /etc/init.d/redis
先切换到/etc/init.d目录下
然后执行自启命令
[root@iZwz991stxdwj560bfmadtZ init.d]# chkconfig redis on
看结果是redis不支持chkconfig
解决方法:
使用vim编辑redis文件,在第一行加入如下两行注释,保存退出
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database


再次执行开机自启命令,成功
[root@iZwz991stxdwj560bfmadtZ init.d]# chkconfig redis on

现在可以直接已服务的形式启动和关闭redis了
启动:
service redis start

service redis stop
ps:如果redis设置了密码的话直接stop的话会出现以下情况,关闭不掉

解决方法:
1.修改redis服务脚本,加入如下所示的信息即可:
vi /etc/init.d/redis
$CLIEXEC -a "password" -p $REDISPORT shutdown

2.也可以通过redis-cli登录,然后shutdown关闭
8.开启远程访问
修改6379.conf
注释掉bind 127.0.0.1可以使所有的ip访问redis
若是想指定多个ip访问,但并不是全部的ip访问,可以bind
注意
下面还有个说明
在redis3.2之后,redis增加了protected-mode,在这个模式下,即使注释掉了bind 127.0.0.1,再访问redisd时候还是报错,如下
(error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
修改办法:protected-mode no
重新启动服务
service redis stop
service redis start
9.设置访问密码
修改6379.conf
打开配置文件找到,大概在500行,可以在命令行模式下进行搜索

[plain] view plain copy
#requirepass foobared
去掉行前的注释,并修改密码为所需的密码,保存文件
[plain] view plain copy
requirepass myRedis
重新启动服务
service redis stop
service redis start
10.开启6379端口
rm -rf redis

从零开始搭建系统1.5——Redis安装及配置的更多相关文章
- 从零开始搭建系统2.8——HDFS安装及配置
从零开始搭建系统2.8——HDFS安装及配置
- 从零开始搭建系统2.4——Jenkins安装及配置
1.安装wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.reporpm --impo ...
- 从零开始搭建系统1.7——FTP安装及配置
1.安装vsftp软件包 [root@localhost usr]# yum install -y vsftpd 2.先备份vsftpd的默认配置文件 [root@localhost usr]# cd ...
- 从零开始搭建系统1.3——Tomcat安装及配置
首先安装jdk,手动解压JDK的压缩包,然后设置环境变量 1.卸载自带openjdk 查询OpenJDK rpm -qa|grep java 批量卸载所有名字包含jdk的已安装程序.命令行: rpm ...
- 从零开始搭建系统1.2——Nginx安装及配置
一.安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++.gcc.openssl-devel.pcre-devel和zlib ...
- 从零开始搭建系统2.5——Apollo安装及配置
参见https://github.com/ctripcorp/apollo/wiki/Quick-Start安装即可
- 从零开始搭建系统2.2——ELK安装及配置
ELK 最新版本对JDK的最低要求是1.8,安装java_1.8版本 一.Elasticsearch 1.创建目录 2.下载安装包 wget https://artifacts.elastic.co/ ...
- 从零开始搭建系统2.1——Nexus安装及配置
在安装配置Nexus时,请先确定您已经配置好jdk 1.创建目录 2.下载安装包 [root@localhost usr]# cd nexus 下载地址:https://www.sonatype.co ...
- 从零开始搭建系统1.4——MySql安装及配置
安装环境:CentOS7 64位 ,安装MySQL5.7 1.创建mysql目录 2.在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo ...
随机推荐
- Javascript高级程序设计--读书笔记之理解原型对象
先上一段代码和关系图 function Person(){} Person.prototype.name = "Nic" Person.prototype.age = 22 Per ...
- 关于导出Excel出现异常的解决办法。:System.UnauthorizedAccessException: 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败
异常信息为:System.UnauthorizedAccessException: 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} ...
- ASE code search -- 第二次结对编程作业
baseline 复现 baseline模型 我们再这次实验中选择了deep code search方法作为了解并复现.下面介绍一下这两种方法 deep code search 模型的结构在论文中已经 ...
- Mybatis-概况
是什么 官网定义 http://www.mybatis.org/mybatis-3/ 百科定义(维基百科) https://en.wikipedia.org/wiki/MyBatis Github: ...
- CSV模块的使用
1.csv简介 CSV (Comma Separated Values),即逗号分隔值(也称字符分隔值,因为分隔符可以不是逗号),是一种常用的文本 格式,用以存储表格数据,包括数字或者字符.很多程序在 ...
- 【Luogu】【关卡2-4】排序Ex(2017年10月)
任务说明:这里的排序就更上一层了.不仅融合了别的算法与技巧,排序本身也有各种花招.
- C++中创建对象的时候加括号和不加括号的区别(转)
c++创建对象的语法有----- 1 在栈上创建 MyClass a; 2 在堆上创建加括号 MyClass *a= new MyClass(); 3 不加括号 MyClass *a = new My ...
- js 实现弹出层效果
代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <tit ...
- 64. 输出字节流(FileOutputStream)
IO分类: 按照数据流向分类: 输入流 输出流 按照处理的单位划分: 字节流:字节流读取的都是文件中的二进制数据,读取到的 ...
- python 爬取拉勾网
import requestsimport randomimport timeimport osimport csvimport pandas as pdreq_url = 'https://www. ...