-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathredis.html
84 lines (82 loc) · 3.34 KB
/
redis.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv=pragma content=no-cache>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico">
<link rel="bookmark" href="favicon.ico">
<title>Redis安装配置笔记</title>
</head>
<body>
<div class="container">
<p><a href="index.html">返回首页</a></p>
<h2 align=center>Redis安装配置笔记</h2>
<h3>一、Linux下安装说明</h3>
<p><b>1、包管理器安装:</b></p>
<pre>
yum/apt install redis
systemctl start redis
systemctl enable redis
</pre>
<p><b>2、编译安装:</b></p>
<pre>
wget http://download.redis.io/releases/redis-7.4.2.tar.gz
tar xvf redis-7.4.2.tar.gz
cd redis-7.4.2
make
make PREFIX=/usr/local/redis install
cp redis.conf /usr/local/redis/
useradd -U -r -M -s /bin/false redis
cat > /lib/systemd/system/redis.service << "EOF"
[Unit]
Description=Redis persistent key-value database
After=network.target
[Service]
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf --daemonize no
ExecStop=/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown
User=redis
Group=redis
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
ln -sf /usr/local/redis/bin/* /usr/local/bin/
#linux中以unix socket运行redis,提升连接速度
sed -i "s/# unixsocket \/run\/redis.sock/unixsocket \/tmp\/redis.sock/g" /usr/local/redis/redis.conf
sed -i "s/# unixsocketperm 700/unixsocketperm 666/g" /usr/local/redis/redis.conf
#Failed opening the RDB file dump.rdb问题
mkdir /usr/local/redis/db
chown redis:redis /usr/local/redis/db -R
sed -i "s/dir .\//dir \/usr\/local\/redis\/db\//g" /usr/local/redis/redis.conf
#日志文件
mkdir /usr/local/redis/log
sed -i "s/logfile \"\"/logfile \"\/usr\/local\/redis\/log\/redis.log\"/g" /usr/local/redis/redis.conf
touch /usr/local/redis/log/redis.log
chown redis:redis /usr/local/redis/log/redis.log
#The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.问题
echo 511 > /proc/sys/net/core/somaxconn
echo "echo 511 > /proc/sys/net/core/somaxconn" >> /etc/rc.local
#MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk问题
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl -p
echo 1 > /proc/sys/vm/overcommit_memory
# WARNING you have Transparent Huge Pages (THP) support enabled in your kernel.问题
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local
#注意:使用systemd的发行版,/etc/rc.local或软链接到的/etc/rc.d/rc.local无执行权限,需要处理一下
chmod +x /etc/rc.local
systemctl start redis
systemctl enable redis
#设置密码(如:redis123)
sed -i "s/# requirepass foobared/requirepass redis123/g" /usr/local/redis/redis.conf
</pre>
<h3>二、Windows下安装说明</h3>
<p><b>1、下载地址:</b><a href="https://github.com/zkteco-home/redis-windows" target="_blank">https://github.com/zkteco-home/redis-windows</a></p>
<p>最新版本为:redis-7.4.2</p>
<p><b>2、解压,命令行进入当前目录,运行“redis-server.exe redis.conf”</b></p>
<p><a href="index.html">返回首页</a></p>
<p align="center">© 2016-2025 清风的个人笔记</p>
</div>
</body>
</html>