Redis搭建

一. 环境

  • centos7.4

二. YUM搭建Redis

1 yum -y install  epel-release
2 yum -y install redis
3 systemctl enable redis.service
4 systemctl start redis.service
5 systemctl status redis.service
6 netstat -lnutp | grep 6379

三.  编译安装Redis

3.1.1编译安装

 1 wget http://download.redis.io/releases/redis-4.0.0.tar.gz
 2 mkdir /usr/local/redis/
 3 mkdir /data/redis/ -p
 4 tar xf redis-4.0.0.tar.gz 
 5 mv redis-4.0.0/* /usr/local/redis/
 6 cd /usr/local/redis/
 7 make
 8 echo $?
 9 cp redis.conf /data/redis/
10 cp src/redis-server /data/redis/
11 cd /data/redis/
12 ln -s /usr/local/redis/src/redis-cli /usr/bin/redis-cli
13 ./redis-server ./redis.conf 
14 netstat -lnutp | grep 6379

3.1.2配置启动脚本

 1 [Unit]
 2 #描述信息
 3 Description=Redis Server 3.0.4
 4 #启动时机,开机启动最好在网络服务启动后即启动
 5 After=network.target
 6 [Service]
 7 #此处为命令行启动redis的命令及参数,可参考官方文档
 8 ExecStart=/data/redis/redis-server /data/redis/redis.conf --daemonize no  
 9 #停止redis服务器命令
10 ExecStop=/usr/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown 
11 User=redis #运行reddis用户
12 Group=redis #所属组
13 [Install]
14 WantedBy=multi-user.target #字符界面下启动

 

3.1.3 测试systemctl管理启动

1 systemctl enable redis.service
2 systemctl stop redis.service
3 systemctl start redis.service
4 systemctl status redis.service
5 netstat -lnutp | grep 6379

 

posted @ 2018-07-25 21:47  闫世成  阅读(119)  评论(0编辑  收藏  举报