ubuntu 安装
sudo apt-get install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get -y install redis
源码编译安装 Redis
创建 redis 用户
useradd -r -s /sbin/nologin redis
下载 Redis
wget https://download.redis.io/redis-stable.tar.gz
编译 Redis
tar -xzvf redis-stable.tar.gz
cd redis-stable
make BUILD_TLS=yes
make install
redis-server.service
cat > /lib/systemd/system/redis-server.service <<EOF
[unit]
Description=Redis persistent key-vaue database
After=network.target
[service]
Execstart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervisedsystemd
Execstop=/bin/ki11 -S QUIT $MAINPID
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryode=0755
LimitNOFILE=1000000
[Install]
WantedBy=multi-user.target
EOF
Redis 配置
bind 0.0.0.0
requirepass 123456
解决警告信息
查看服务日志
2580:C 12 Dec 2024 08:53:46.461 # 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, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
解决办法
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf && sysctl -p
systemctl restart redis-server
参考文档
https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/
标签:sudo,install,部署,gpg,redis,https,memory From: https://www.cnblogs.com/wangguishe/p/18602991