In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to install redis master-slave cluster in ubuntu16.04". The content in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "how to install redis master-slave cluster in ubuntu16.04".
Install stand-alone version
Pre-environment
Apt-get updateapt install makeapt install gcc gcc+ build-essential tcl
Download and install
Cd / appwget http://download.redis.io/releases/redis-5.0.5.tar.gztar zxvf redis-5.0.5.tar.gzcd redis-5.0.5make MALLOC=libcmake testcd src & & make install PREFIX=/usr/local/redis# after successful installation root@redis-node1:/app/redis-5.0.5/src# make install PREFIX=/usr/local/redisHint: It's a good idea to run 'make test';) INSTALL install INSTALL install
Make test error
!!! WARNING The following tests failed:*** [err]: PEXPIRE/PSETEX/PEXPIREAT can set sub-second expires in tests/unit/expire.tclExpected 'somevalue {}' to equal or match'{} {} 'Cleanup: may take some time... OKMakefile:262: recipe for target 'test' failedmake [1]: * * [test] Error 1make [1]: Leaving directory' / app/redis-5.0.5/src'Makefile:6: recipe for target 'test' failedmake: * * [test] Error 2 some operations require more time Modify tests/unit/expire.tcltags {"slow"} {test {EXPIRE-After 2.1 seconds the key should no longer be here} {after 21000 # add 0 list [r get x] [r exists x]} {{} 0}} test {EXPIRE-write on expire should work} {r del x r lpush x foo r expire x 10000 # add a 0 r lpush x bar r lrange x 0-1} {bar foo} # the following output successfully installed\ o / All tests passed without errorscleaning Cleanup: may take some time... OKmake [1]: Leaving directory'/ app/redis-5.0.5/src'
Configuration
Mkdir-p / data/redis/logmkdir-p / data/redis/dirmkdir-p / data/redis/runcd / usr/local/redismkdir confvim conf/6379
The configuration file is as follows
Bind 10.13.6.21protected-mode yesport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile / data/redis/run/redis_6379.pidloglevel noticelogfile "/ data/redis/log/6379.log" databases 16always-show-logo yessave 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump_6379.rdbdir / data/redis/dirreplica-serve-stale-data yesreplica-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noreplica-priority 100lazyfree-lazy-eviction nolazyfree -lazy-expire nolazyfree-lazy-server-del noreplica-lazy-flush noappendonly yesappendfilename "appendonly_6379.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 00 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 yesslave-priority 100
Start
/ usr/local/bin/redis-server / usr/local/redis/conf/6379-after daemonize no# starts, the following warning will be issued: 3195 Sep M 15 Sep 2019 22 daemonize no# 17 WARNING: The TCP backlog setting of 511 cannot be enforced because / proc/sys/net/core/somaxconn is set to the lower value of 128.3 195V M 15 Sep 2019 22 daemonize no# 17 daemonize no# 50.852 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory=1' to / etc/sysctl.conf and then reboot or run the command' sysctl vm.overcommit_memory=1' for this to take effect.3195:M 15 Sep 2019 22 etc/sysctl.conf and then reboot or run the command 17V 50.852 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > / sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your / etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.3195:M 15 Sep 2019 22 Ready to accept connections# 17 Ready to accept connections# installation prompt solution # solve the first, second vim / etc/sysctl.conf add net.core.somaxconn = 1024vm.overcommit_memory = effective sysctl-p # solve the third # shell execution Restart will fail echo never > / sys/kernel/mm/transparent_hugepage/enabled# permanently effective vim / etc/rc.local add echo never > / sys/kernel/mm/transparent_hugepage/enabled
Join systemctl
The contents of vim / etc/systemd/system/redis.servicesystemctl daemon-reloadsystemctl enable redis.servicesystemctl start redis# are as follows: root@redis-node1:/data/redis# cat / etc/systemd/system/ redis.service [Unit] Description=Redis In-Memory Data StoreAfter= network.target [Service] User=rootGroup=rootExecStart=/usr/local/redis/bin/redis-server / usr/local/redis/conf/6379-- daemonize noExecStop=/usr/local/redis/bin/redis-cli-h 10.13.6.21-p 6379 shutdownRestart= always [install] WantedBy=multi-user.target
Client test
Root@redis-node1:/data/redis# redis-cli-h 10.13.6.21-p 637910.13.6.21 empty list or set 6379 > keys * (empty list or set) 10.13.6.21 empty list or set 6379 > info replication# Replicationrole:masterconnected_slaves:0master_replid:98832eb375d0399255e1094bf546c88efb8ccd97master_replid2:0000000000000000000000000000000000000000master_repl_offset:0second_repl_offset:-1repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0 installation master-slave mode
Master-slave mode-slave is installed in the same way as above, with slightly different configuration files
Slaveof 10.13.6.21 6379slave-priority 90
Complete configuration
Bind 10.13.6.22protected-mode yesport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile / data/redis/run/redis_6379.pidloglevel noticelogfile "/ data/redis/log/6379.log" databases 16always-show-logo yessave 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump_6379.rdbdir / data/redis/dirreplica-serve-stale-data yesreplica-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noreplica-priority 100lazyfree-lazy-eviction nolazyfree -lazy-expire nolazyfree-lazy-server-del noreplica-lazy-flush noappendonly yesappendfilename "appendonly_6379.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 00 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 yesslaveof 10.13.6.21 6379slave-priority 90 Master Slave Test 10.13.6.21 6379slave-priority 6379 > info replication# Replicationrole:masterconnected_slaves:2slave0:ip=10.13.6.22 Port=7000,state=online,offset=168,lag=0slave1:ip=10.13.6.22,port=7001,state=online,offset=168,lag=1master_replid:ee4636f02a76df701b61507656c833de3cde259emaster_replid2:0000000000000000000000000000000000000000master_repl_offset:168second_repl_offset:-1repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:1repl_backlog_histlen:16810.13.6.21:6379 > exit
You can see that the connected_slaces is 2
Thank you for your reading, the above is the content of "how to install redis master-slave cluster in ubuntu16.04". After the study of this article, I believe you have a deeper understanding of how to install redis master-slave cluster in ubuntu16.04, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.