一、下载源码包
必备条件:最小化centos 安装基础命令
yum install vim iotop bc gcc gcc-c++ glibc glibc-devel pcre \
pcre-devel openssl openssl-devel zip unzip zlib-devel net-tools \
lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel \
bc systemd-devel bash-completion traceroute -y
[root@node1 src]# wget http://download.redis.io/releases/redis-4.0.14.tar.gz
#解压
[root@node1 src]#tar xvf redis-4.0.14.tar.gz
#编译安装
[root@node1 redis-4.0.14]#make PREFIX=/apps/redis install
..........
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
#创建目录
[root@node1 src]#mkdir -pv /apps/redis/{etc,log}
#拷贝配置文件
[root@node1 redis-4.0.14]#cp redis.conf /apps/redis/etc/
二、准备启动文件
[root@node1 redis-4.0.14]#vi /usr/lib/systemd/system/redis.service
1 [Unit]
2 Description=Redis persistent key-value database
3 After=network.target
4 After=network-online.target
5 Wants=network-online.target
6 [Service]
7 ExecStart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised sy stemd
8 ExecReload=/bin/kill -s HUP $MAINPID
9 ExecStop=/bin/kill -s QUIT $MAINPID
10 Type=notify
11 User=redis
12 Group=redis
13 RuntimeDirectory=redis
14 RuntimeDirectoryMode=0755
15 [Install]
16 WantedBy=multi-user.target
#配置文件生效
[root@node1 redis-4.0.14]#systemctl daemon-reload
#创建redis用户
[root@node1 redis-4.0.14]#useradd -r redis -s /sbin/nologin
#修改目录权限
[root@node1 redis-4.0.14]# chown -R redis.redis /apps/redis
#启动service
[root@node1 redis-4.0.14]#systemctl start redis
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:33657 *:*
LISTEN 0 128 127.0.0.1:6010 *:*
LISTEN 0 128 127.0.0.1:6379 *:*