Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set –有序集合)和hash(哈希类型)。文件简要介绍redis在CentOS 7下安装并配置自启动。
一、安装环境及版本
# more /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
# /u01/app/redis/src/redis-server -v
Redis server v=4.0.9 sha=00000000:0
二、安装redis
检查当前系统是否存在自带的redis,如存在则卸载
本文将redis安装到 /u01/app/redis目录
# rpm -qa |grep redis
redis-3.2.10-2.el7.x86_64
# rpm -e --nodeps redis-3.2.10-2.el7.x86_64
下载安装文件,解压并make
# cd /u01/soft
# wget http://download.redis.io/releases/redis-4.0.9.tar.gz
# tar xzf redis-4.0.9.tar.gz
# mv redis-4.0.9 /u01/app/redis
# cd /u01/app/redis
# make
三、配置自启动
# vim /u01/app/redis/redis.conf
daemonize yes
# vim /etc/systemd/system/redisd.service
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/var/run/redis_6379.pid
ExecStart=/u01/app/redis/src/redis-server /u01/app/redis/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start redisd
# systemctl enable redisd
四、验证redis
# netstat -nltp|grep redis
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 6240/redis-server 1
# ln -sv /u01/app/redis/src/redis-cli /usr/bin/redis
‘/usr/bin/redis’ -> ‘/u01/app/redis/src/redis-cli’
# redis
127.0.0.1:6379> set name leshami
OK
127.0.0.1:6379> get name
"leshami"
原文链接:https://www.f2er.com/centos/374169.html