Redis-Ligecycle
如何安装 redis, 启动 Redis 和 redis 集群设置。
Installation
There are many ways to install redis on different version system. Using package managment tool like brew, apt-get, yum ans so on is more convenient than other ways. But in this case we would install redis by tarball.
Prerequisite to be installed
- Install necessary package
yum -y install gcc-c++
-y: always yes
- Install ruby
- Download ruby tarball
- Unarchive ruby package
- Set access authority(Optional): chmod -R 700 ruby-2.6.3
- cd redis_install_path/ruby-2.6.3/
- Set ruby install path: ./configure –prefix=redis_install_path/ruby
- Compile code: make
- Compile and install: make install
- Add ruby command folder to system path: export PATH=redis_install_path/ruby/bin:$PATH
Tips: If there are two executable files with same name in different folder and their path are both in PATH. The previous ones in PATH will be executed, and the latter will be ignored.
- Install rubygem(gem is a package management tool in ruby)
- Download rubygems tarball
- Unarchive rubygems packages: unzip rubygems-3.0.4.zip
- Set access authority(Optional): chmod -R 700 rubygems-3.0.4
- cd rubygems-3.0.4
- Install ruby-gems: ruby setup.rb
- Install redis-gem(Install the redis-gem package using gem)
- Download redis-gems tarball
- Install: gem install -l redis-4.1.2.gem
Download, build, and install Redis server
- Install redis
- Download redis installation package
- Unarchive package: tar -xvzf redis-stable.tar.gz
- cd redis-stable
- Compile: make
- Install: make install
Start redis instance
Update redis configuratio file(Refer to redis_config.conf.j2 file)
Create the pid, log, configuration folder
Start redis by configuration file:
redis-server /.conf
1 | # The following configuration is important |
Create redis cluster
- Cd redis installation path
- Create redis cluster
./redis-cli –cluster create itsrhv22205.it.statestr.com:6380 itsrhv17064.it.statestr.com:6379 itsrhv17065.it.statestr.com:6379
- View the topology of redis cluster
./redis-cli -c -h -p -a cluster nodes
Add redis slave instance into redis cluster
- Cd redis installation path
- Add redis slave instance into redis cluster
./redis-cli –cluster add-node : : –cluster-slave –cluster-master-id -a
- View the topology of redis cluster
./redis-cli -c -h -p -a cluster nodes
Add redis master instance into redis cluster
- Cd redis installation path
- Add redis master instance into redis cluster
./redis-cli –cluster add-node : : -a
- Reshard slots from existed master nodes to newly added master node
./redis-cli –cluster reshard : –cluster-from all –cluster-to –cluster-slots –cluster-yes -a
- View the topology of redis cluster
./redis-cli -c -h -p -a cluster nodes