安装配置Redis手册

安装配置Redis手册

1. yum安装运维维护版本 redis-4.0.12

yum install redis

2. 修改配置增加 Authentication Password

# 生成随机密钥
pwgen -s 16 -1
 
 
# vim /usr/local/redis6379/redis.conf
# debug verbose notice warning
loglevel notice
requirepass p5F6AsKTVZvpuH6p
 
# master slave
masterauth KXFwiqY1MYpLvyqv
slaveof 10.16.19.188 6379
 
# 快捷操作
echo "requirepass p5F6AsKTVZvpuH6p" >> /usr/local/redis6379/redis.conf

3.重启Redis

systemctl restart redis6379

4.发现的问题

一是:Redis未设置密码,并且允许通过网络开放访问;
二是:如果增加密码配置,无法通过上面的命令重启

# 停止是使用调用的命令 redis-cli shutdown,修改/usr/local/redis6379/redis.server解决[XXX]
 
 
echo "Stopping ..."
$CLIEXEC -p $REDISPORT -a p5F6AsKTVZvpuH6p shutdown

5.打开文件数限制

mkdir /etc/systemd/system/redis6379.service.d/
vim /etc/systemd/system/redis6379.service.d/limit.conf 添加如下内容
 
 
# If you need to change max open file limit
# for example, when you change maxclient in configuration
# you can change the LimitNOFILE value below
# see "man systemd.exec" for information
 
[Service]
LimitNOFILE=65536

6. Disable Transparent Huge Pages (THP)

# Create a new profile.
mkdir /etc/tuned/no-thp
 
# vim /etc/tuned/no-thp/tuned.conf
 
[main]
include=virtual-guest
 
[vm]
transparent_hugepages=never
 
[script]
script=script.sh
 
[sysctl]
vm.overcommit_memory = 1
 
# Create a new script
# vim /etc/tuned/no-thp/script.sh
 
#!/bin/sh
 
. /usr/lib/tuned/functions
 
start() {
    echo never > /sys/kernel/mm/transparent_hugepage/defrag
    return 0
}
 
stop() {
    echo always > /sys/kernel/mm/transparent_hugepage/defrag
    return 0
}
 
process $@
 
# Enable the new profile
tuned-adm profile no-thp
 
# Test you changes
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
 
 
cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
posted @ 2022-02-24 17:09  vekair  阅读(70)  评论(0编辑  收藏  举报