从零开始搭建系统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 ...
随机推荐
- python基础之数据类型初始
变量 贴标签 变量名规则:只能是字母下划线和数字组成,不能以数字开头,不能和关键字同名,不能使用拼音和中文,具有可描述性,区别大小写,变量名推荐写法:驼峰提,下划线(官方推荐) 变量赋值 常量 特性: ...
- python面试题之下面这些是什么意思:@classmethod, @staticmethod, @property?
回答背景知识 这些都是装饰器(decorator).装饰器是一种特殊的函数,要么接受函数作为输入参数,并返回一个函数,要么接受一个类作为输入参数,并返回一个类. @标记是语法糖(syntactic s ...
- android5.1 修改音量键绑定多媒体声音
修改此文件frameworks/base/media/java/android/media/AudioService.java中函数 private int getActiveStreamType(i ...
- 第五章 配置私有仓库Harbor
一.Harbor 安装(尚硅谷资料) 安装:Harbor 官方地址:官方地址:https://github.com/vmware/harbor/releases 1.解压软件包 tar xvf har ...
- 解决虚拟机克隆的linux系统ip无法正常使用问题
当我们克隆centos虚拟机无法正常获取IP地址,重启网卡也提示Bringing up interface eth0: Device eth0 does not seem to be present ...
- Comet OJ - contest #3 C DP
题意:给你一个长度为n序列,和一个数m,问这个序列有多少个子序列,满足这个子序列的所有子序列的和是m的倍数?答案对1e9 + 7取模,n, m范围到5e3; 思路:容易发现,如果一个子序列的长度是n, ...
- 通过lua进行nginx的权限控制
nginx_lua的安装 nginx使用luajit进行编译安装 使用openresty进行yum安装 openresty中将lua和nginx进行封装,详情可查看openresty官网 openre ...
- Nginx---配置详解(转发)
转载于 http://baijiahao.baidu.com/s?id=1604485941272024493&wfr=spider&for=pc 1.概述 Nginx配置文件的整体 ...
- Vue学习笔记【20】——Vue中的动画(使用动画钩子函数)
定义及使用钩子函数 定义 transition 组件以及三个钩子函数: <div id="app"> <input type="button&q ...
- posix_rpi_common.cmake学习
# This file is shared between posix_rpi_native.cmake 这个文件在posix_rpi_native.cmake和posix_rpi_cross.cma ...