交叉编译redis服务,并设置开机自启动
交叉编译需要下载redis源码
1、下载源码
源码可以前往redis下载链接
2、源码解压
tar zxvf 7.0.2.tar.gz
3、输入命令
cd redis-7.0.2/
make distclean
make clean
4、编译
交叉编译指令如下
make MALLOC=libc CC=/opt/cambricon/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc USE_SYSTEMD=no -j40
其中gcc换成自己的交叉编译工具链中的gcc路径
5、导出可执行文件放到嵌入式机器执行如下脚本
(可执行文件存放与src目录下,可编译结束后cd src)
#! /usr/bin/bash
##redis任何版本全程自动化源码编译安装
##用法: bash install.sh
#Redis基础配置
mkdir -p /usr/local/redis/{etc,logs,data}
cp ./redis-cli ./redis-server /usr/local/redis/
cp ./redis.conf /usr/local/redis/etc/
#PATH配置
echo "export PATH=$PATH:/usr/local/redis/" >>/etc/profile
source /etc/profile
#启动redis服务
/usr/local/redis/redis-server /usr/local/redis/etc/redis.conf
#查看redis监听端口
netstat -tanp | grep redis
#设置开机启动
echo "/usr/local/redis/redis-server /usr/local/redis/etc/redis.conf" >> /etc/rc.local
配置文件如下
bind 0.0.0.0 -::1
protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
pidfile /usr/local/redis/redis.pid
loglevel notice
logfile "/usr/local/redis/logs/redis.log"
databases 16
always-show-logo no
set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /usr/local/redis/data
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj no
oom-score-adj-values 0 200 800
disable-thp yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
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
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes