redis源码安装(单机版)

下载redis3的稳定版本
● 上传至linux解压

[root@hadoop-01 ~]# tar -zxvf redis-3.2.12.tar.gz -C /usr/local/src/

● 进入源码包编译并安装

[root@hadoop-01 redis-3.2.12]# pwd
/usr/local/src/redis-3.2.12
[root@hadoop-01 redis-3.2.12]# make && make install
如果报错的话,是因为缺少gcc依赖(缺少c的编译器,redis就是c写的)
yum -y install gcc
再重新编译make && make install
还是报错的话,是没有安装jemalloc内存分配器,可以安装jemalloc或直接输入
make MALLOC=libc && make install

成功标志 :

Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/usr/local/src/redis-3.2.12/src'
cd src && make install
make[1]: Entering directory `/usr/local/src/redis-3.2.12/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/src/redis-3.2.12/src'

● 创建目录,并拷贝redis的配置

[root@hadoop-01 ~]# mkdir -p /usr/local/redis
[root@hadoop-01 ~]# cd /usr/local/redis/
[root@hadoop-01 redis]# cp /usr/local/src/redis-3.2.12/redis.conf /usr/local/redis

● 修改redis.conf

#true : redis以后台形式运行 
daemonize yes
#开启aof日志,它会每次写操作都记录一条日志
appendonly yes  
bind 192.168.127.11
# cluster-enabled yes  是否开启集群,默认是不开启

● 启动

#指定配置文件启动
[root@hadoop-01 redis]# redis-server /usr/local/redis/redis.conf

● 使用redis客户端连接

#使用此命令,默认连接的是本地127.0.01,我们改过配置为ip地址,而非本机
[root@hadoop-01 redis]# redis-cli 
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
#指定ip地址连接
[root@hadoop-01 redis]# redis-cli -h 192.168.127.11
192.168.127.11:6379> 

● 设置密码

192.168.127.11:6379> config set requirepass ws
OK
192.168.127.11:6379> exit
[root@hadoop-01 redis]# redis-cli -h 192.168.127.11
192.168.127.11:6379> keys *
(error) NOAUTH Authentication required.
192.168.127.11:6379> auth ws
OK

● 关闭redis

#关闭无密码的redis
[root@hadoop-01 redis]# redis-cli shutdown
#关闭有密码的redis,先用密码登录,在关闭
[root@hadoop-01 redis]# redis-cli -h 192.168.127.11
192.168.127.11:6379> auth ws
OK
192.168.127.11:6379> shutdown
not connected> exit

猜你喜欢

转载自blog.csdn.net/bb23417274/article/details/83050597