龙空技术网

CentOS 7 编译安装 redis6

linux运维菜 722

前言:

而今同学们对“centos6编译安装”大概比较关注,我们都想要学习一些“centos6编译安装”的相关资讯。那么小编也在网摘上收集了一些关于“centos6编译安装””的相关内容,希望各位老铁们能喜欢,你们一起来学习一下吧!

简介

CentOS 7 默认的 gcc 版本为:4.8.5 ,无法满足编译条件,可以使用CentOS的第三方源安装gcc。

安装gcc

添加源,并安装gcc

sudo yum -y install centos-release-sclsudo yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

需要自动切换到新版本的gcc可以在profile里面添加命令

echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

临时切换到新版本的gcc进行编译安装

scl enable devtoolset-9 bashmake make PREFIX=/opt/redis install

创建目录,并配置

mkdir -p /opt/redis/etc  /data/redis/data /data/redis/logs
vim /opt/redis/etc/redis.conf
bind 0.0.0.0protected-mode yesport 7000tcp-backlog 511timeout 0tcp-keepalive 300daemonize yespidfile /data/redis/logs/redis_7000.pidloglevel noticelogfile "/data/redis/logs/redis_7000.log"databases 16always-show-logo yes# save 900 1# save 300 10# save 60 10000save ""stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump_7000.rdbrdb-del-sync-files nodir /data/redis/datareplica-serve-stale-data yesreplica-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-diskless-load disabledrepl-disable-tcp-nodelay noreplica-priority 100acllog-max-len 128requirepass Ux0us4rcbs0ke3SggzmaHk5PPQ3ZQX1dlazyfree-lazy-eviction nolazyfree-lazy-expire nolazyfree-lazy-server-del noreplica-lazy-flush nolazyfree-lazy-user-del nooom-score-adj nooom-score-adj-values 0 200 800appendonly yesappendfilename "appendonly_7000.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-use-rdb-preamble yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000stream-node-max-bytes 4096stream-node-max-entries 100activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit replica 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10dynamic-hz yesaof-rewrite-incremental-fsync yesrdb-save-incremental-fsync yesjemalloc-bg-thread yes
降权执行

创建一个权限比较低的用户执行redis-server

useradd -s /sbin/nologin -M redischown redis.redis /opt/redis /data/redis -R
启动
echo madvise > /sys/kernel/mm/transparent_hugepage/enabledsudo -u redis  /opt/redis/bin/redis-server /opt/redis/etc/redis.conf
设置开机启动
echo 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled'  >> /etc/rc.localecho 'sudo -u redis  /opt/redis/bin/redis-server /opt/redis/etc/redis.conf'  >> /etc/rc.local

标签: #centos6编译安装 #centos 安装 redis #centos511安装教程 #centos编译安装tcpdump工具 #centos7安装redis5