redis搭建
1.下载软件包
[root@db01 ~]# rz redis-3.2.12.tar.gz
或者
[root@db01 ~]# wget http://download.redis.io/releases/redis-3.2.12.tar.gz
2.安装依赖
[root@db01 ~]# yum install -y gcc gcc-c++
3.解压移动
[root@db01 ~]# tar xf redis-3.2.12.tar.gz
[root@db01 ~]# mv redis-3.2.12 /usr/local/
[root@db01 ~]# ln -s /usr/local/redis-3.2.12 /usr/local/redis
4.安装
[root@db01 ~]# cd /usr/local/redis
[root@db01 redis]# make
5.启动redis
[root@db01 redis]# ./src/redis-server &
[root@db01 redis]# netstat -lntp
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 11759/./src/redis-s
6.连接redis
#配置环境变量
[root@db01 redis]# vim /etc/profile.d/redis.sh
export PATH=/usr/local/redis/src:$PATH
#连接
[root@db01 redis]# redis-cli
127.0.0.1:6379>
7.关闭redis
[root@db01 redis]# redis-cli shutdown
11759:M 03 Aug 10:20:20.535 # User requested shutdown...
11759:M 03 Aug 10:20:20.535 * Saving the final RDB snapshot before exiting.
11759:M 03 Aug 10:20:20.546 * DB saved on disk
11759:M 03 Aug 10:20:20.546 # Redis is now ready to exit, bye bye...
[1]+ Done ./src/redis-server
[root@db01 redis]# redis-cli
127.0.0.1:6379> shutdown
11851:M 03 Aug 10:20:59.580 # User requested shutdown...
11851:M 03 Aug 10:20:59.580 * Saving the final RDB snapshot before exiting.
11851:M 03 Aug 10:20:59.584 * DB saved on disk
11851:M 03 Aug 10:20:59.584 # Redis is now ready to exit, bye bye...
not connected> quit
[1]+ Done ./src/redis-server
8.redis配置文件
1.配置
#默认的配置文件
[root@db01 redis]# pwd
/usr/local/redis
[root@db01 redis]# ll
-rw-rw-r-- 1 root root 46695 Jun 13 2018 redis.conf
#创建reids配置文件目录
[root@db01 redis]# mkdir /service/redis/6379 -p
#编写配置文件
[root@db01 redis]# vim /service/redis/6379/redis.conf
bind 172.16.1.51 127.0.0.1 #监听地址
port 6379 #端口
daemonize no #后台启动
pidfile /service/redis/6379/redis_6379.pid #指定pid文件
loglevel notice #指定日志级别
logfile /service/redis/6379/redis_6379.log #指定日志文件
2.指定配置文件启动
[root@db01 redis]# redis-server /service/redis/6379/redis.conf