In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
First, for stand-alone installation and deployment, pseudo-clusters only need to operate the first 1-8 steps, and then browse to find: second, stand-alone-pseudo-cluster installation and deployment continue to build. If you need to set a password, please refer to step 10.
1. Install basic tools
Yum install-y gcc-c++ vim lrzsz wget
2. Create and enter the directory
Mkdir / opt/rediscd / opt/redis
3. Download
Wget http://download.redis.io/releases/redis-5.0.5.tar.gz
4. Decompress and view files
Tar zxvf redis-5.0.5.tar.gzll
5. Empowerment
Chmod 777-R redis-5.0.5
6. Enter the directory and view the list of files
Cd redis-5.0.5
7. Compile and install files
Installation directory / usr/local/redismake install PREFIX=/usr/local/redis
8. Enter the directory and view the list of files
Cd / usr/local/redis/
9. Start the console and use the command. / redis-server
Bin/redis-server
The following results prove that the startup is successful:
10. Start in the background
(1) copy redis.conf from the redis directory to the redis installation directory
Cp / opt/redis/redis-5.0.5/redis.conf / usr/local/redis/
(2) modify redis.conf
Vim / usr/local/redis/redis.conf
Modify daemonize yes
Parameter note port 7000 port 7000Magol 7002bind native ip default ip is 127.0.0.1 need to be changed to ip accessible to other node machines, otherwise the corresponding port cannot be accessed when creating a cluster Unable to create cluster daemonize yesredis backend running pidfile / var/run/redis_7000.pidpidfile file corresponding to 7000jingle 7001jue 7002clustertalk enabled yes/ enable cluster comment # remove the configuration file of cluster-config-file nodes_7000.conf cluster start automatic generation of 7000jome 7002clustercolor timeout 15000 request timeout default 15 seconds, you can set your own appendonly yesaof log to enable if necessary It records a log for each write operation. Maxmemory 7516192768 limits the existence of 7Gmasterauth123lxo [9 ^ Ki34 & x pass123lxo9 ^ Ki34 & x]
Copy the code
Then, on another machine, repeat the above three steps, just change the directory to 7003, 7004, 7005, and modify the corresponding configuration file according to this rule.
If the host restarts unexpectedly, add a new node to the cluster
Redis-cli-- cluster add-node-a "123lxo [9 ^ Ki 34 & x" 192.168.47.212VR 7002 192.168.91.244V7000
Add slave node
Redis-cli-- cluster add-node-a "123lxo [9 ^ Ki 34 & x" 192.168.172.127VR 7003 192.168.83.158123lxo 7003-- cluster-slave
Delete nod
Redis-cli-- cluster del-node-a "123lxo [9 ^ Ki 34 & x" 192.168.47.212 b31ef3b428d20915248b07f1f32694e3caff8a1c
Set boot self-boot
[Unit] Description=redis-serverAfter=network.target [Service] Type=forkingExecStart=/home/ec2-user/redis-5.0.5/src/redis-server / home/ec2-user/redis-5.0.5/redis_cluster/7003/redis.confPrivateTmp= truth [in stall] WantedBy=multi-user.targetsudo systemctl enable redis boot sudo systemctl status redis check status
Execute the following command on the host of any redis node:
Redis-cli-c-h 192.168.0.100-p 7000 cluster info
If there is a password to add
Redis-cli-c-h 192.168.0.100-p 7000-a "123lxo [9 ^ Ki 34 & x" cluster info
List cluster nodes
Execute the following command on the host of any redis node to list all the nodes (node) currently known to the cluster and related information about those nodes.
Redis-cli-c-h 192.168.68.117-p 7000-a "123lxo [9 ^ Ki 34 & x" cluster nodes
(3) enter the directory and start the service
Cd / usr/local/redis/bin/redis-server redis.conf
11. View startup information
Ps-ef | grep redis
12. Basic operation
/ usr/local/redis/bin/redis-cli
13. Stop service
Redis-cli-h localhost-p 6379 (port) shutdown / / stop servic
Or kill-9 (pid)
II. Stand-alone-pseudo-cluster installation and deployment
1. Compile and install
Part III (steps 1 to 8 for stand-alone installation and deployment)
And copy the configuration file redis.conf from the redis extracted directory to the redis installation directory
Cp / opt/redis/redis-5.0.5/redis.conf / usr/local/redis/
2. Install basic tools
Yum install-y net-tools wget lrzsz vim
3. Copy redis.conf from the redis decompression directory to the redis installation directory
If there is a dump.rdb file under / usr/local/redis or / usr/local/redis/bin, delete it
Rm-rf / usr/local/redis/dump.rdbrm-rf / usr/local/redis/bin/dump.rdb
4. Create a directory / usr/local/redis-cluster to store cluster instances
Mkdir / usr/local/redis-cluster
Enter the directory / usr/local/redis-cluster
Cd / usr/local/redis-cluster
5. Create a node directory (6 stores six instances)
Mkdir node1 node2 node3 node4 node5 node6
6. Copy the files (copy the compiled and installed instances to the 6 directories created in Hong Kong)
Cp-R / usr/local/redis/* / usr/local/redis-cluster/node1/cp-R / usr/local/redis/* / usr/local/redis-cluster/node2/cp-R / usr/local/redis/* / usr/local/redis-cluster/node3/cp-R / usr/local/redis/* / usr/local/redis-cluster/node4/cp-R / usr/local/redis/* / usr/local/redis-cluster/node5/cp-R / usr / local/redis/* / usr/local/redis-cluster/node6/
7. Edit the configuration files of their respective nodes (instances) (take the configuration file redis.conf of node1 as an example, and the other 5 nodes refer to node1)
Vim node1/redis.conf
(1) daemonize yes
(2) port 7001 # (other nodes: 7002, 7003, 7004, 7005, 7006)
(3) pidfile / var/run/redis_7001.pid # (other nodes: 7002, 7003, 7004, 7005, 7006) when redis runs in daemon mode, the system writes pid to / var/run/redis_7001.pid by default
(4) cluster-enabled yes # this redis instance acts as a node in the cluster
(5) cluster-config-file nodes-7001.conf # (other nodes: nodes-7002, 3, 4, 5, 6.conf) cluster configuration file, which is automatically maintained by the system and cannot be edited manually. It mainly records the nodes, status and other parameters in the cluster.
(6) the maximum time that the cluster-node-timeout 15000 # node can be lost.
Edit the configuration files of the remaining nodes, modify their configuration information, and change them to their corresponding ports (refer to node1 for specific process).
8. Download gem file
Wget https://rubygems.org/downloads/redis-4.1.2.gem
(download address: https://rubygems.org/gems/redis/versions/4.1.2)
Empowering
Chmod 777 redis-4.1.2.gem
9. Install the ruby environment
Yum install-y rubygem install / usr/local/redis-cluster/redis-4.1.2.gem
Installing the gem file directly will indicate that the ruby version is too low and requires a ruby version above 2.3.
Solution:
1. Install basic tools
Yum install-y curl ruby
2. View the existing version
Ruby-vruby 2.0.0p648 (2015-12-16) [x86_64-linux]
3. Get rvm.io (found that installation failed)
Curl-L get.rvm.io | bash-s stable
4. Add references according to the prompts
Curl-sSL https://rvm.io/mpapis.asc | gpg2-import-or curl-sSL https://rvm.io/pkuczynski.asc | gpg2-- import-
5. Get rvm.io again (success! )
Curl-L get.rvm.io | bash-s stable
6. Find the configuration file
Find /-name rvm.sh/etc/profile.d/rvm.sh
Make the configuration file effective
Source / etc/profile.d/rvm.sh
7. Download RVM dependency
Rvm requirements
8. Check the configuration file again
Find /-name rvm-print
9. View the rvm list
Rvm list known
10. Install v2.4.1 of rvm
Rvm install 2.4.1
11. Configure environment variables
Rvm use 2.4.1Using / usr/local/rvm/gems/ruby-2.4.1rvm use 2.4.1-defaultUsing / usr/local/rvm/gems/ruby-2.4.1
12. Delete the old version of ruby
Rvm remove 2.0.0p648ruby-2.0.0p648-# already goneUsing / usr/local/rvm/gems/ruby-2.4.1
13. View the final version
Ruby-- versionruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
Execute again
Gem install / usr/local/redis-cluster/redis-4.1.2.gem
10. Use gem to install redis
Gem install redis
11. Enter the directory / usr/local/redis-cluster/ to create a startup script
Cd / usr/local/redis-cluster/vim start-all.sh
Write the following:
/ node1/bin/redis-server redis.conf/node2/bin/redis-server redis.conf/node3/bin/redis-server redis.conf/node4/bin/redis-server redis.conf/node5/bin/redis-server redis.conf/node6/bin/redis-server redis.conf
Empower startup scripts
Chmod 777 start-all.sh
12. Startup script
. / start-all.sh
13. Check the startup status
Ps-ef | grep redisps aux | grep redisnetstat-lntp
Create a cluster
. / redis-cli-- cluster create 127.0.0.1 cluster-replicas 7002 127.0.1 cluster-replicas 7002 127.0.0.1
Description:
(1) Performing hash slots allocation on 6 nodes... # means there are a total of 6 nodes
(2) Using 3 masters: # there are three primary nodes that are ports 7001, 7002 and 7003, respectively
(3) Adding replica 127.0.0.1 to 7005 Port 7005 is the slave node of Port 7001 node, and so on
(4) M: 014d11a25cb3ea6999bd8a3237ad27252b324c54 127.0.0.1 7001 # the string in front is the unique logo of ID
(5) slots:0-5460 (5461 slots) master # means that the hash slot of the current node is 0-5460, and only the primary node has a hash slot. There are 16384 (0-16383) hash slots built into the redis cluster.
(6) yes # starts to build
III. Client testing
Client linked to redis: redis-cli
Cd / usr/local/redis-cluster/
Copy script file redis-cli
Cp / opt/redis/redis-5.0.5/src/redis-cli / usr/local/redis-cluster/ll./redis-cli-h 127.0.0.1-p 7001-c./redis-cli-h 127.0.0.1-p 7005-c
View cluster information
127.0.0.1 7001 > cluster info
View node information
128.127.0.0.1 info server 7001 > cluster nodes127.0.0.1:7001 > info replication127.0.0.1:7001 > info server
Description:
(1)-h corresponds to the IP address, which is the local machine by default if you don't write it.
(2)-p corresponds to the port of the specified instance in the cluster.
(3)-c this is necessary and represents cluster startup.
(4) [9189] and [4998] are the current key hash slots calculated by the algorithm. Each node has a corresponding hash slot range, and the stored data is stored to the corresponding node according to the key hash slot.
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.