从零开始搭建系统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 ...
随机推荐
- C++之循环体内变量
今天做PAT题目时候看人家解答: #include <cstdio> #include <set> using namespace std; int main() { int ...
- Raspberry Pi 开机启动QT程序
https://blog.csdn.net/coekjin/article/details/52498212 https://blog.csdn.net/dubuzherui/article/deta ...
- ionic3 图片(轮播)预览 ionic-gallary-modal组件使用方法
一.效果展示 使用方法: 1.npm安装ionic-gallary-modal扩展模块 npm install ionic-gallery-modal --save 2.在app.module.ts根 ...
- Centos安装mysql5.6.33
下载安装包 百度网盘地址: 链接:https://pan.baidu.com/s/15xaHIqvjggS_rFP_jL-BVA 提取码:mh48 上传到服务器 mkdir mysql #在/us ...
- 解决ubuntu终端路劲显示过长问题
1 找到配置文件先进行备份: cp ~/.bashrc ~/.bashrc-bak 2 找到配置文件修改: vi ~/.bashrc 备份是为了防止配置修改出错,可以还原 3 在以下的红色位置 ...
- vue 非父子组件之间的传值(Bus/总线/发布订阅模式/观察者模式)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- J2EE学习篇之--Struts2技术详解
前面说到了Struts1的相关知识,下面来说一下Struts2的相关知识,我们知道现在Struts2使用的比Struts1多,Struts2已经替代Struts1成为主流的框架了... 摘要 Stru ...
- DLL中使用字符串时的注意事项。
library dll1; uses SysUtils, Classes; {$R *.res} function TESTDLL:string;stdcall; begin Result:='tes ...
- LInux文件基础知识和文件目录操作(系统调用函数方式)
1.进程是处于活动状态的程序,某个用户通过操作系统运行程序所产生的进程代表着该用户的行为.如果用户不具备访问某个目录和文件的权限,那么该用户的进程也不能访问. 2.Linux系统中文件安全机制是通过给 ...
- vs2012+wdk8.0 搭建wdf驱动开发环境
开发环境搭建: 系统:win7 x64 工具:vs2012 + WDK8.0 插件:wdfcoinstaller.msi (1)先安装vs2012,再安装wdk8.0,这样在打开vs2012时可以创建 ...