标签:通信 cte name exe evel hash put bin red
[root@deeam ~]# tar xf redis-4.0.9.tar.gz
[root@deeam ~]# cd redis-4.0.9
[root@deeam redis-4.0.9]# make
[root@deeam redis-4.0.9]# echo $?
0
[root@deeam local]# mkdir /usr/local/redis ##创建服务目录
[root@deeam local]# cp /root/redis-4.0.9/src/redis-server /usr/local/redis/ ##复制服务端程序
[root@deeam local]# cp /root/redis-4.0.9/src/redis-cli /usr/local/redis/ ##复制客户端程序
[root@deeam local]# cp /root/redis-4.0.9/redis.conf /usr/local/redis/ ##复制服务主配置文件
[root@deeam local]# ls /usr/local/redis/
redis-cli redis.conf redis-server
--redis-cli :客户端程序
--redis-server :服务端程序
--redis.conf :主配置文件
[root@deeam local]# vim /usr/local/redis/redis.conf ##进入到配置文件里;修改如下几行
69 bind 192.168.100.101 ##修改监听地址为本地服务器的IP
88 protected-mode yes ##关闭redis的保护模式
136 daemonize yes ##开启redis的后台守护进程模式
109 unixsocket /tmp/redis.sock ##打开sock文件;基于sock服务端与客户通信直接在内存中交换;数据包就不经由TCP协议层封装了
500 requirepass 123123 ##设置redis的密码为123123(生产环境中要强制密码)
[root@deeam local]# vim /etc/profile.d/redis.sh
export PATH=/usr/local/redis:$PATH
[root@deeam local]# . /etc/profile.d/redis.sh
[root@deeam local]# vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis
After=network.target
[Service]
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf --daemonize no
ExecStop=/usr/local/redis/redis-cli -h 192.168.100.101 -p 6379 shutdown
[Install]
WantedBy=multi-user.target
[root@deeam local]# systemctl daemon-reload
[root@deeam local]# systemctl start redis
[root@deeam local]# redis-cli -h 192.168.100.101 -p 6379 -a 123123
192.168.100.101:6379>
-h :指定本地监听的IP地址
-p : 指定端口
-a : 指定密码
daemonize yes
bind 0.0.0.0
protected-mode no
pidfile "/usr/local/redis/redis.pid"
port 6379
tcp-backlog 1024
timeout 0
tcp-keepalive 300
loglevel notice
logfile "/usr/local/redis/log/redis.log"
requirepass "HKrCL$e$acZ9"
masterauth "HKrCL$e$acZ9"
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 "/usr/local/redis/data"
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
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
min-slaves-to-write 1
min-slaves-max-lag 10
daemonize yes
bind 0.0.0.0
protected-mode no
pidfile "/usr/local/redis/redis.pid"
port 6379
tcp-backlog 1024
timeout 0
tcp-keepalive 300
loglevel notice
logfile "/usr/local/redis/log/redis.log"
requirepass "HKrCL$e$acZ9"
masterauth "HKrCL$e$acZ9"
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 "/usr/local/redis/data"
slave-serve-stale-data yes
slave-read-only yes
slaveof 192.168.29.128 6379 #指定master地址
repl-disable-tcp-nodelay no
slave-priority 100
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
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
min-slaves-to-write 1
min-slaves-max-lag 10
[root@node1 redis]# ./redis-cli
127.0.0.1:6379> AUTH HKrCL$e$acZ9
OK
127.0.0.1:6379> KEYS *
(empty list or set)
127.0.0.1:6379> SET name test
OK
127.0.0.1:6379> KEYS 8
(empty list or set)
127.0.0.1:6379> KEYS *
1) "name"
127.0.0.1:6379> GET name
"test"
[root@node3 redis]# ./redis-cli
127.0.0.1:6379>
127.0.0.1:6379> AUTH HKrCL$e$acZ9
OK
127.0.0.1:6379>
127.0.0.1:6379> GET name
"test"
标签:通信 cte name exe evel hash put bin red
原文地址:https://www.cnblogs.com/precipitation/p/14211432.html