当前位置:网站首页>Ubuntu18.04+centos7 configure redis master-slave [learning notes]
Ubuntu18.04+centos7 configure redis master-slave [learning notes]
2022-07-28 06:52:00 【[dissimilarity space]】
One 、 Premise description and environmental settings
explain
| Lord redis(Ubuntu18.04) | from redis(Centos7) |
|---|---|
| IP Address :192.168.1.106 | IP Address :192.168.1.110 |
Install environment settings
- Both systems require the installation of compilers ( Compiling and installing requires )
- Two system installations vim Editor ( It's not necessary , Use the system default vi It's fine too )
- Both systems need to turn off the firewall ( If you don't turn it off, you need to set firewall filtering rules )
- If you don't want to compile and install , Two systems can be yum Modify source to Ali , Conduct yum Source installation is also OK .
Two 、redis install
Ubuntu18.04 install redis
Here are yum Source installation 【 Change the source to Alibaba's source 】
modify yum Source reference
- Source installation
[email protected]:~$ sudo apt-get install redis
- see redis process
[email protected]:~$ ps aux | grep redis
root 45922 0.2 0.1 58556 3996 ? Ssl 13:46 0:04 redis-server 192.168.1.106:6379
wang 45983 0.0 0.0 21540 1056 pts/2 S+ 14:14 0:00 grep --color=auto redis
here ubuntu On redis Installation successful .
Centos7 install redis
Here is the compilation and installation
- Create installation directory , take redis Download to this directory , And finish decompressing
[[email protected] /]# mkdir /software
[[email protected] /]# cd /software/
[[email protected] software]# wget http://download.redis.io/releases/redis-4.0.9.tar.gz
[[email protected] software]# tar -zxvf redis-4.0.9.tar.gz
[[email protected] software]# ls
redis-4.0.9 redis-4.0.9.tar.gz
2. Create installation directory , Unzip the above directory redis-4.0.9 Copy to the installation directory , Build and install
[[email protected] software]# mkdir -p /usr/local/redis
[[email protected] software]# cp redis-4.0.9 /usr/local/redis/
[[email protected] software]# cd /usr/local/redis/
[[email protected] redis]# ls
redis-4.0.9
[[email protected] redis]# cd redis-4.0.9/
[[email protected] redis-4.0.9]# ls
00-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
[[email protected] redis-4.0.9]# make
[[email protected] redis-4.0.9]# make test [ Test compilation ]
Cleanup: may take some time... OK [ The occurrence of this sentence means that there is no problem with compilation ]
[[email protected] redis-4.0.9]# make install
- Return to the download directory , take redis.conf Copy the configuration file to /usr/local/bin below , After entering /usr/local/bin/ Check whether the directory exists
[[email protected] redis-4.0.9]# cd /software/redis-4.0.9/
[[email protected] redis-4.0.9]# ls
00-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
[[email protected] redis-4.0.9]# cp redis.conf /usr/local/bin/
[[email protected] redis-4.0.9]# cd /usr/local/bin/
[[email protected] bin]# ls
dump.rdb redis-benchmark redis-check-aof redis-check-rdb redis-cli redis.conf redis-sentinel redis-server
3、 ... and 、 Modify the redis.conf The configuration file
Ubuntu18.04 On redis.conf Modification of configuration file 【 Lord redis】
[email protected]:~$ sudo vim /etc/redis/redis.conf
bind 192.168.1.106 127.0.0.1
protected-mode no
port 6379
After modification , To restart redis( Make sure the firewall is turned off )
[email protected]:~$ sudo redis-server /etc/redis/redis.conf
Get into redis client , Add some data
[email protected]:~$ redis-cli
127.0.0.1:6379> set name Tom
OK
127.0.0.1:6379> set age 23
OK
127.0.0.1:6379> keys *
1) "age"
2) "name"
127.0.0.1:6379>
Centos7 On redis.conf Modification of configuration file 【 from redis】
[[email protected] /]# cd /usr/local/bin/
[[email protected] bin]# ls
dump.rdb redis-benchmark redis-check-aof redis-check-rdb redis-cli redis.conf redis-sentinel redis-server
[[email protected] bin]# vim redis.conf
bind 192.168.1.110 127.0.0.1
port 6379
# slaveof <masterip> <masterport>
slaveof 192.168.1.106 6379
After modification , start-up redis service
[[email protected] bin]# redis-server redis.conf
10135:C 02 May 13:47:15.529 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10135:C 02 May 13:47:15.529 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=10135, just started
10135:C 02 May 13:47:15.529 # Configuration loaded
10135:S 02 May 13:47:15.530 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._ _.-`` `. `_. ''-._ Redis 4.0.9 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 10135
`-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'
10135:S 02 May 13:47:15.532 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10135:S 02 May 13:47:15.532 # Server initialized
10135:S 02 May 13:47:15.532 # 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.
10135:S 02 May 13:47:15.532 # 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.
10135:S 02 May 13:47:15.532 * DB loaded from disk: 0.000 seconds
10135:S 02 May 13:47:15.532 * Ready to accept connections
10135:S 02 May 13:47:15.532 * Connecting to MASTER 192.168.1.106:6379
10135:S 02 May 13:47:15.532 * MASTER <-> SLAVE sync started
10135:S 02 May 13:47:15.533 * Non blocking connect for SYNC fired the event.
10135:S 02 May 13:47:15.533 * Master replied to PING, replication can continue...
10135:S 02 May 13:47:15.534 * Partial resynchronization not possible (no cached master)
10135:S 02 May 13:47:15.535 * Full resync from master: d570c47a8e1fa630f15eaf2c240cf861fae69740:0
10135:S 02 May 13:47:15.599 * MASTER <-> SLAVE sync: receiving 416 bytes from master
10135:S 02 May 13:47:15.599 * MASTER <-> SLAVE sync: Flushing old data
10135:S 02 May 13:47:15.599 * MASTER <-> SLAVE sync: Loading DB in memory
10135:S 02 May 13:47:15.601 * MASTER <-> SLAVE sync: Finished with success
10135:S 02 May 14:47:36.243 * 1 changes in 900 seconds. Saving...
10135:S 02 May 14:47:36.248 * Background saving started by pid 13844
13844:C 02 May 14:47:36.255 * DB saved on disk
13844:C 02 May 14:47:36.256 * RDB: 6 MB of memory used by copy-on-write
10135:S 02 May 14:47:36.352 * Background saving terminated with success
The above information indicates that the setting is from redis success , Then reopen a terminal , Enter from redis client , Check the master redis Whether the information on is synchronized to from redis On
[[email protected] bin]# cd /usr/local/bin/
[[email protected] bin]# redis-cli
127.0.0.1:6379> keys *
1) "name"
2) "age"
127.0.0.1:6379> get name
"Tom"
127.0.0.1:6379> get age
"23"
127.0.0.1:6379>
Find out from redis Shangyouhe zhuredis Same information on , Set up the success .
View master-slave relationship commands
[email protected]:~$ redis-cli -h 192.168.1.106 info Replication
# Replication
role:master
connected_slaves:0
master_replid:b89f94ec9e6b115e40d7d815b8f82c507f0cb270
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
边栏推荐
- Hdu-5805-nanoape loves sequence (thinking questions)
- prometheus监控nacos
- 思寒漫谈测试人职业发展
- ISO 3.0-server three power separation configuration
- Code tidiness (I)
- 2022 Tanabata gift recommendation! Nice, cheap and practical gift recommendation
- Dynamic memory management function of C language
- Graphic pipeline foundation (II)
- [C language] custom structure type
- Pku-2739-sum of constructive prime numbers
猜你喜欢
随机推荐
File operation in C language
VMware Workstation 配置net模式
技术分享 | 如何模拟真实使用场景?mock 技术来帮你
What is the good brand of air conduction Bluetooth headset and the best brand recommendation of air conduction headset
搭建PHP7私有仓库
Installation and configuration of unit test framework jest with typescript
Qgraphicsview promoted to qchartview
mongoDB快速入门
DHCP原理与配置
JS variable is equal to 0, etc. '
测试面试题集锦(三)| 计算机网络和数据库篇(附答案)
测试人生 | 二线城市年薪超40W?疫情之下涨薪100% + 是怎么做到的?
Which is the best one to make air conduction headphones? Inventory of the best air conduction headphones
MySQL主从
Skimming records -- sequence traversal of binary tree
@Postconstruct annotations and useful examples
Analysis of reentrantlock source code of AQS
Graphic pipeline foundation (part outside)
DNS域名解析服务
SSAO by computer shader (II)









