redis安装配置参考
admin
2023-02-07 00:00:04
0

1.操作系统参数和服务配置:
sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld

echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
echo "vm.swappiness=10" >> /etc/sysctl.conf
echo 10 > /proc/sys/vm/swappiness
echo "net.core.somaxconn=65535" >> /etc/sysctl.conf
echo "net.ipv4.tcp_max_syn_backlog=65535" >> /etc/sysctl.conf
echo "net.ipv4.tcp_max_syn_backlog=65535" >> /etc/sysctl.conf
echo "net.core.somaxconn=65535" >> /etc/sysctl.conf
echo " soft nofile 288000" >> /etc/security/limits.conf
echo "
hard nofile 288000" >> /etc/security/limits.conf
sysctl -p

关闭大页内存:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.d/rc.local
echo "echo never > /sys/kernel/mm/transparent_hugepage/defrag" >> /etc/rc.d/rc.local
chmod a+x /etc/rc.d/rc.local

操作系统ntp服务设置:
#检查当前系统时区,如果不是上海,修改为上海
timedatectl |grep "Time zone"
timedatectl set-timezone Asia/Shanghai
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

安装ntp服务
yum install ntpdate -y
#写入定时任务同步时间
crontab -e
0-59/10 /usr/sbin/ntpdate ntp1.aliyun.com | logger -t NTP
#测试同步时间是否可以成功
/usr/sbin/ntpdate ntp1.aliyun.com

服务部署、依赖部署:
yum install gcc wget -y

2.redis软件下载及安装:
cd /usr/local
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
tar xvzf redis-4.0.11.tar.gz
ln -s redis-4.0.11 redis
cd redis
make
make install
cd ~

vim .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/redis/src
source .bash_profile
#验证是否安装成功,如果出现版本号则说明安装成功:
redis-cli -v

mkdir -p /data/redis-6379/logs/
mkdir -p /data/redis-6379/run/
编辑redis配置文件:
根据需要修改maxmemory和port参数以及对应的bind,例如端口号为6379,sed -i 's/6379/xxxx/g' xxxx.conf
配置文件port6379,IP地址192.168.56.201:

bind 127.0.0.1 192.168.56.201
protected-mode no
port 6379
tcp-backlog 10000
timeout 0
tcp-keepalive 60
daemonize yes
supervised no
pidfile "/data/redis-6379/run/redis_6379.pid"
loglevel notice
logfile "/data/redis-6379/logs/6379.log"
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump6379.rdb"
dir "/data/redis-6379"
#slaveof 192.168.56.201 6379 #master ip地址和端口
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-timeout 60
repl-disable-tcp-nodelay no
repl-backlog-size 10mb
repl-backlog-ttl 3600
slave-priority 100
maxclients 10000
maxmemory 5000000kb
maxmemory-policy volatile-lru
appendonly yes
appendfilename "appendonly6379.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 0
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 1000
slowlog-max-len 1000
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 512mb 128mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

启动Redis:
redis-server /data/redis-6379/6379.conf
登录:
redis-cli -p 6379
添加定时任务定时做rdb备份和aof备份:
0 redis-cli -p 6379 bgsave
0 1 * redis-cli -p 6379 BGREWRITEAOF

相关内容

热门资讯

工信部部长:搞“脱钩断链”对谁... 7月23日,2026年亚太经合组织(APEC)数字和人工智能部长会议新闻发布会在成都召开。会议主席、...
AMD展示最强AI加速器MI4... IT之家 7 月 24 日消息,今天(7 月 24 日)在美国旧金山召开的年度盛会 Advancin...
河北:知行研学度盛夏 多彩实践... 冀时新闻报道暑假期间,我省各地推出形式多样的青少年研学活动,让孩子们在实践中增长见识、锤炼品格,度过...
世界互联网大会数智健康工作组以... 7月22日,2026年世界互联网大会数字丝路发展论坛在陕西西安开幕。这是世界互联网大会连续第三年举办...
开立医疗获得实用新型专利授权:... 证券之星消息,根据天眼查APP数据显示开立医疗(300633)新获得一项实用新型专利授权,专利名为“...
成都深入实施“人工智能+”行动 成都深入实施“人工智能+”行动 到2027年实现人工智能核心产业规模突破2600亿元 华西都市报讯(...
原创 中... 说真的,看到欧洲科学家一本正经拿粪水浇菜做研究,最后还得出了个“安全无害、肥力充足”的结论,我第一反...
小米智能手环11 Active... IT之家 7 月 23 日消息,科技媒体 WinFuture 昨日(7 月 22 日)发布博文,分享...
胡塞武装袭击红海油轮,特朗普威... 据路透社报道,当地时间7月23日,也门胡塞武装表示已在红海袭击两艘沙特油轮,并称这两艘油轮违反该组织...
刚签就要黄了?特朗普:核能协议... 据彭博社报道,当地时间7月23日,美国总统特朗普表示,美国与沙特阿拉伯的民用核能合作协议能否落地,将...