redis7.2.5安装

redis7.2.5安装

#1、安装编译环境等
dnf install -y gcc vim wget
#2、下载并建立目录
mkdir software
wget https://download.redis.io/releases/redis-7.2.5.tar.gz
tar -zxvf redis-7.2.5.tar.gz
#3、安装

cd redis-7.2.5.tar.gz
make
make install

4、编译后默认安装目录是/usr/local/bin

#5、修改配置文件redis.conf
vim /software/redis-7.2.5/redis.conf

1 默认daemonize no 改为 daemonize yes 表示开启后台启动
2 默认protected-mode yes 改为 protected-mode no 需要别人来连接redis服务器的话需要改成no
3 默认bind 127.0.0.1 改为 直接注释掉(默认bind 127.0.0.1只能本机访问)或改成本机IP地址,否则影响远程IP连接 bind 192.168.0.115 -::1
4 默认# requirepass foobared 修改redis密码 去#改foobared改为你自己设置的密码
5 默认port 6379 改为你想用的端口号,如6679
6 pidfile /var/run/redis_6379.pid,如果使用默认端口则保持默认值即可。
7 logfile /usr/local/redis/redis_log.log 设置redis日志,记得自己创建目录让redis保存日志,可不设置logfile。

#6、修改系统参数
vim /etc/sysctl.conf
加入
vm.overcommit_memory = 1
/sbin/sysctl -p
#以上代码可以解决WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition

#7、运行
./redis-server /software/redis-7.2.5/redis.conf

#8、设置开机自启
vim /etc/systemd/system/redis.service
#以下内容复制到redis.service里
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /software/redis-7.2.5/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target
#以上内容复制到redis.service里
#重新加载
systemctl daemon-reload
#重启服务
systemctl restart redis
#开机自启
systemctl enable redis

posted @ 2024-07-09 14:28  昵称昵称昵称  阅读(9)  评论(0编辑  收藏  举报