赞
踩
首先到Redis官网下载 redis下载链接 找到下图所示位置:选择相对应的版本的redis进行下载,本文以mac开发环境进行演示:
下载完成后使用scp命令拷贝安装包到Linux系统下:scp /Users/codegeekgao/Desktop/gxp/redis-3.2.11.tar.gz donniegao@10.211.55.9:/soft/packages
由于Redis的安装需要依赖C++,请确保安装的系统有C++的环境。若没有使用yum install gcc-c++
进行安装C++
tar -zxvf redis-3.0.0.tar.gz
cd /usr/local/redis-3.0.0
make PREFIX=/usr/local/redis install
redis.conf
是redis的配置文件,redis.conf在redis源码目录。拷贝配置文件到安装目录下进入源码目录,里面有一份配置文件 redis.conf,然后将其拷贝到安装路径下,并创建日志目录和数据目录。cp /usr/local/redis/redis.conf /usr/local/redis/conf
cd /usr/local/redis
mkdir conf
mkdir log
mkdir redisData
vim redis.conf
dir /usr/local/service/redis/redisData
logfile /usr/local/service/redis/log/redis.log
配置redis可以远程连接
bind 127.0.0.1
注释掉,见下图:protected-mode no
JedisDataException: 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.
出现这个问题可以选择上面的关闭保护模式,也可以配置redis登陆的密码
将redis.conf
中配置项注释的#requirepass
打开并设置以下连接的密码比如:requirepass myRedis
以上配置好以后,初始化配置基本完成了,下面就是启动redis了。
./bin/redis-server ./redis.conf
/usr/local/redis/bin/redis-cli -a myRedis
[Unit]
Description=redis
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.targe
保存后,启动和开启服务
systemctl daemon-reload
重新加载systemctl
systemctl enable redis.service
设置开机启动
systemctl start redis.service
启动redis服务
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。