redis安装..采坑

服务器 软件版本 服务器地址 项目位置
CentOS7 3.2.6 X /usr/local/program/redis
配置位置 数据位置 端口 账号/密码
/usr/local/program/redis/redis.conf /data/redis 27017 只有一个验证:root

##下载

[root@localhost program]# yum install wget
####到下面的一步输入 y 回车
Is this ok [y/d/N]: y
[root@localhost program]# wget http://download.redis.io/releases/redis-3.2.6.tar.gz

##解压改名

[root@localhost program]# tar zxf redis-3.2.6.tar.gz
[root@localhost program]# mv redis-3.2.6 redis

##安装需要的编译软件

[root@localhost program]# sudo yum -y install gcc gcc-c++ libstdc++-devel
[root@localhost program]# yum install tcl
	Is this ok [y/d/N]: y #回车

##安装redis

[root@localhost program]# make && make install
[root@localhost program]# mv ../bin/ ./redis
## 因为默认是安装在/usr/local/bin的,所以直接考到项目下
bind 0.0.0.0
daemonize yes
pidfile /data/redis/redis_6379.pid
port 6379
[root@localhost redis]# mkdir /data/redis

##启动并且查看成功了吗

[root@localhost redis]# cd bin/
[root@localhost bin]# ./redis-server /usr/local/program/redis/redis.conf
[root@localhost bin]# ps -ef|grep redis
root      11771      1  0 01:38 ?        00:00:00 ./redis-server 0.0.0.0:6379
root      11775   8109  0 01:38 pts/0    00:00:00 grep --color=auto redis
## 安装成功

关闭

[root@localhost bin]# ./redis-cli shutdown

设置密码登录

[root@localhost bin]# cd ../
[root@localhost redis]# vim redis.conf
	requirepass root
[root@localhost redis]# ./bin/redis-cli shutdown
[root@localhost redis]# /usr/local/program/redis/bin/redis-server /usr/local/program/redis/redis.conf

##测试

[root@localhost redis]# ./bin/redis-cli -h 192.168.120.61 -p 6379  ##命令方式链接服务
192.168.120.61:6379> keys *
(error) NOAUTH Authentication required.
192.168.120.61:6379> auth root  ## 验证命令
OK
192.168.120.61:6379> keys *

添加开机自启

[root@localhost ~]# chmod +x /etc/rc.d/rc.local
[root@localhost ~]# vi /etc/rc.d/rc.local

你可能感兴趣的:(redis安装..采坑)