从零开始搭建系统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 ...
随机推荐
- docker--build base image
通过dockerfile build一个base image,在上面运行一个c程序 首先 1.创建一个目录. 2.然后创建一个c写的小程序,并且gcc编译好. 3.创建一个Dockerfile FRO ...
- js函数方法
/** * call()和apply * 这两个方法都是函数对象的方法,需要通过函数对象来调用 * 当对函数调用call()和apply()都会调用函数执行 * 在调用call()和apply()可以 ...
- LeetCode Array Easy 189. Rotate Array
---恢复内容开始--- Description Given an array, rotate the array to the right by k steps, where k is non-ne ...
- LeetCode Array Easy 118. Pascal's Triangle
Description Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. I ...
- 深入理解java虚拟机JVM(下)
深入理解java虚拟机JVM(下) 链接:https://pan.baidu.com/s/1c6pZjLeMQqc9t-OXvUM66w 提取码:uwak 复制这段内容后打开百度网盘手机App,操作更 ...
- MySQL数据库企业级应用实践(多实例源码编译)
MySQL数据库企业级应用实践(多实例源码编译) 链接:https://pan.baidu.com/s/1ANGg3Kd_28BzQrA5ya17fQ 提取码:ekpy 复制这段内容后打开百度网盘手机 ...
- 一句话的Android增量更新框架(增量更新)
转自:http://www.jianshu.com/p/a9ec8fa780e2 Android应用更新要使用完整的新版本Apk安装,增量更新则是提供一个新旧版本偏差数据的patch包供应用下载,然后 ...
- Hibernate与Mybatis的简单区别
数据库连接创建.释放频繁造成系统的资源浪费从而影响系统性能,可以使用数据库连接池解决此问题,之前的java应用程序sql语句也是写在java代码中造成系统可维护性差,实际应用的sql变化较大,sql变 ...
- java随笔记录
JAVA的变量类型 类变量:独立于方法之外的变量,用 static 修饰. 实例变量:独立于方法之外的变量,不过没有 static 修饰. 局部变量:类的方法中的变量. public class Va ...
- 谈谈你对本次2018级ACM新手赛的体会
第一次参加这类比赛,挺有趣的,在现场磨了四个小时也没有全写出来,收获还是挺大的,至少意识到自己是能做到这些的(笑 今后也会多多努力