是否安装gcc,没有安装的话安装
gcc -v
yum install gcc gcc-c++ kernel-devel
下载包
wget https://download.redis.io/releases/redis-6.2.6.tar.gz
解压
tar -zxvf redis-6.2.6.tar.gz
移走
mv redis-6.2.6 /usr/local/
切换目录
cd /usr/local/redis-6.2.6/
安装
make
运行redis:
src/redis-server
以后台进程方式启动redis
第一步:修改/usr/local/redis-6.2.6/redis.conf文件
将
daemonize no
appendonly no
修改为
daemonize yes 后台启动
appendonly yes 数据存储到磁盘
第二步:指定redis.conf文件启动
src/redis-server /usr/local/redis-6.2.6/redis.conf
交互:
src/redis-cli
set foo bar
get foo
第三步:关闭redis进程
首先使用ps -aux | grep redis查看redis进程
使用kill命令杀死进程
[root@iZwz991stxdwj560bfmadtZ src]# kill 1046
设置redis开机自启动
放到/etc/systemd/system:redis.6379.service
[Unit]
Description=Redis.6379
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis-6.2.6/src/redis-server /usr/local/redis-6.2.6/redis.conf
SyslogIdentifier=Redis.6379
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl enable redis.6379.service
systemctl start redis.6379.service
systemctl status redis.6379.service
参考:
https://redis.io/download
https://www.cnblogs.com/zuidongfeng/p/8032505.html