办法一:通过yum装置
yum -y install redissystemctl start redis
vim /etc/redis.conf
[root@prometheus-influxdb02 ~]# grep -v "#" /etc/redis.confbind 10.26.5.xxprotected-mode noport 6379tcp-backlog 511timeout 30tcp-keepalive 300daemonize yessupervised nopidfile /var/run/redis_6379.pidloglevel noticelogfile /var/log/redis/redis.logdatabases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir /var/lib/redisslave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100requirepass XiaohongshUappendonly noappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated 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 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes
为了能够使Redis能被近程连贯,须要批改配置文件,门路为/etc/redis.conf
首先,正文这一行:
#bind 127.0.0.1批改为0.0.0.0守护过程模式运行(后盾运行)daemonize yes
另外,举荐给Redis设置明码,勾销正文这一行:
#requirepass foobaredfoobared即以后明码,能够自行批改为requirepass 明码systemctl restart redissystemctl 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.gztar -xf redis-5.0.5.tar.gz -C ..cd /data/redis-5.0.5/
通过make来编译,make是主动编译,会依据Makefile中形容的内容来进行编译。
makemake 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-clilrwxrwxrwx 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<<EOFredis-server /data/redis-5.0.5/redis.confEOF