Redis安装

Redis安装

官网地址:

https://redis.io

安装:

1、安装文件下载

wget http://download.redis.io/releases/redis-3.2.8.tar.gz

2、解压下载文件

tar zxvf redis-3.2.8.tar.gz

3、进入源码目录

cd redis-3.2.8/

4、编译源码

make MALLOC=libc

  • 如果安装提示报错,提示gcc-c++未安装,请先安装gcc

5、安装Redis

make install

6、配置Redis能随系统启动

./utils/install_server.sh

显示结果

Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] 
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] 
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] 
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...

Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

安装成功!!!

启动配置

1、在/usr/local/下创建需要的目录

cd /usr/local
mkdir redis #创建目录

2、在redis目录,新建bin和conf目录

mkdir bin
mkdir conf

3、把前面编译后的redis的可执行文件(在redis-3.2.8/src/下),复制到/usr/local/redis/bin里面去

cp redis* /usr/local/redis/bin/

4、redis提供给我们了一个默认的配置文件redis.conf ,把它复制到/usr/local/redis/conf目录下,并改名为6379.conf

cp redis.conf /usr/local/redis/conf/6379.conf

5、修改配置文件

vi 6379.conf

修改如下几个配置:

daemonize no
修改为:
daemonize yes (后台程序方式运行)
pidfile /var/run/redis_6379.pid
修改为:
pidfile /usr/local/redis/redis_6379.pid
(把pidfile生成到有权限的目录下)

6、启动

/usr/local/redis/bin/redis-server /usr/local/redis/conf/6379.conf

7、客户端连接测试

redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> set name test
OK
127.0.0.1:6379> get name
“test”
127.0.0.1:6379>

8、Redis关闭

redis-cli shutdown
ps -ef|gerp redis
bash: gerp: command not found…
Similar command is: ‘grep’

启动成功 !!!

远程登陆

1、绑定注销

# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1

2、保护模式关闭

protected-mode no

3、设置访问密码

equirepass 100527

4、远程访问

c:\Program Files\Redis>redis-cli -h 192.168.137.128 -p 6379 -a 100527
192.168.137.128:6379> get name
“\”aaa\””
192.168.137.128:6379>

远程访问成功!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值