Redis
请使用 Redis
本项目使用版本
解压目录
- 解压:
tar -zxvf redis-7.0.8.tar.gz
- /software/redis-7.0.8
- 解压:
CentOS 安装
shell# -bash: make: command not found yum -y install make # /bin/sh: cc: command not found yum -y install gcc # #include <jemalloc/jemalloc.h> # https://github.com/redis/redis#allocator # https://gitcode.net/mirrors/redis/redis#allocator make MALLOC=libc # You need tcl 8.5 or newer in order to run the Redis test yum -y install tcl # 测试 make test # 安装 make install
Ubuntu 安装
shell# Command 'make' not found, but can be installed with: sudo apt-get install -y make # /bin/sh: 1: cc: not found sudo apt-get install -y gcc # #include <jemalloc/jemalloc.h> # https://github.com/redis/redis#allocator # https://gitcode.net/mirrors/redis/redis#allocator make MALLOC=libc # 测试 make test # 安装 make install
安装位置
shell/usr/local/bin/redis-server /usr/local/bin/redis-benchmark /usr/local/bin/redis-cli
编写服务脚本
复制
/software/redis-7.0.8/redis.conf
到/etc/redis/redis_server_6379.conf
:shellmkdir -p /etc/redis cp /software/redis-7.0.8/redis.conf /etc/redis/redis_server_6379.conf
新建文件
/usr/lib/systemd/system/redis_6379.service
:shellvim /usr/lib/systemd/system/redis_6379.service
shell[Unit] Description=nacos After=syslog.target [Service] Type=oneshot ExecStart=/usr/local/bin/redis-server /etc/redis/redis_server_6379.conf ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
开放远程连接与后台运行:
shellvim /etc/redis/redis_server_6379.conf
shell# 不限制客户端IP # bind 127.0.0.1 -::1 # 关闭保护模式 protected-mode no # 允许后台运行 daemonize yes # 设置密码 requirepass xuxiaowei.com.cn
开放端口
CentOS
shellfirewall-cmd --zone=public --add-port=6379/tcp --permanent firewall-cmd --reload firewall-cmd --list-all
Ubuntu
shellsudo ufw allow 6379
服务命令
查看状态
shellsystemctl status redis_6379.service
启动
shellsystemctl start redis_6379.service
停止
shellsystemctl stop redis_6379.service
重启
shellsystemctl restart redis_6379.service
设置开机自启
shellsystemctl enable redis_6379.service
查看开机自启
shellsystemctl list-unit-files | grep redis_6379.service
shellsystemctl is-enabled redis_6379.service
关闭开机自启
shellsystemctl disable redis_6379.service