关于redis:centos-安装redis

办法一:通过yum装置

yum -y install redis
systemctl start redis

vim /etc/redis.conf

[root@prometheus-influxdb02 ~]# grep -v "#" /etc/redis.conf
bind 10.26.5.xx
protected-mode no
port 6379
tcp-backlog 511
timeout 30
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis/redis.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
requirepass XiaohongshU
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
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
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

为了能够使Redis能被近程连贯,须要批改配置文件,门路为/etc/redis.conf

首先,正文这一行:

#bind 127.0.0.1
批改为

0.0.0.0
守护过程模式运行(后盾运行)

daemonize yes

另外,举荐给Redis设置明码,勾销正文这一行:

#requirepass foobared
foobared即以后明码,能够自行批改为

requirepass 明码
systemctl restart redis
systemctl start redis.service #启动redis服务器
systemctl stop redis.service #进行redis服务器
systemctl restart redis.service #重新启动redis服务器
systemctl status redis.service #获取redis服务器的运行状态
systemctl enable redis.service #开机启动redis服务器
systemctl disable redis.service #开机禁用redis服务器

办法二:通过源代码装置

wget https://download.redis.io/releases/redis-5.0.5.tar.gz
tar -xf redis-5.0.5.tar.gz -C ..
cd /data/redis-5.0.5/

通过make来编译,make是主动编译,会依据Makefile中形容的内容来进行编译。

make
make install

实际上,就是将这个几个文件复制或链接到/usr/local/bin目录了。这样就能够间接执行这几个命令了。

如果不想装置到默认门路/user/local/bin,能够通过PREFIX选项指定其余门路
[root@prometheus-influxdb src]# ll /usr/local/bin/
总用量 32736
-rwxr-xr-x 1 root root 4366640 7月   4 03:24 redis-benchmark
-rwxr-xr-x 1 root root 8111896 7月   4 03:24 redis-check-aof
-rwxr-xr-x 1 root root 8111896 7月   4 03:24 redis-check-rdb
-rwxr-xr-x 1 root root 4806864 7月   4 03:24 redis-cli
lrwxrwxrwx 1 root root      12 7月   4 03:24 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8111896 7月   4 03:24 redis-server

启动服务器,来看看装置是否胜利。

Redis目录中会有一个配置文件redis.conf,咱们能够基于这个文件进行批改,启动时只需指定该配置文件即可

跟办法一雷同步骤设置redis的配置文件,最初,将启动命令写进开机启动项

cat >>/etc/rc.local<<EOF
redis-server /data/redis-5.0.5/redis.conf
EOF

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理