In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to install redis database on Linux server, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
Redis Brief Introduction
REmote DIctionary Server(Redis) is a key-value storage system written by Salvatore Sanfilippo.
Redis is an open-source, memory-based and persistent log, Key-Value database written in ANSI C, compliant with the BSD protocol, network support, and provides APIs in multiple languages.
It is often referred to as a data structure server because values can be strings, hashes, lists, sets, and sorted sets.
I. Installation in the case of external network (the configuration of external network has been talked about in the essays of linux classification)
Step 1: Install the compiler tool, redis is written in ANSI C language, we need to install the tool to compile it
Command: yum install wget make gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel kernel keyutils patch perl
Step 2: Install the tcl component package. We need tcl script language support when installing redis.
#Select a place where the package is stored and enter the directory file where the package is stored
Command: cd /usr/local/src
#download tcl package
Command: wget http://downloads.sourceforge.net/tcl/tcl8.6.6-src.tar.gz
#Extract tcl package in current directory
Command: tar zxvf tcl8.6.6-src.tar.gz
#Enter the unzipped installation directory file
Command: cd tcl8.6.6
#configure tcl component
Command: cd unix
Command: .../ configure --prefix=/usr --without-tzdata --mandir=/usr/share/man $([ $(uname -m) = x86_64 ] && echo --enable-64bit)
#Compile
Command: make
#Process input text file with script specified in option
Command: sed -e "s@^\(TCL_SRC_DIR ='\).*@\ 1/usr/include'@" -e "/TCL_B/s@='\(-L\)\?.* unix@='\1/usr/lib@" -i tclConfig.sh
#Installation
Command: make install
Command: make install-private-headers
#Create soft connections (like shortcuts in windows)
Command: ln -v -sf tclsh8.6 /usr/bin/tclsh
#Modify permissions to execute files
Command: chmod -v 755 /usr/lib/libtcl8.6.so
Step 3: Install Redis Database
#Select a place where the package is stored and enter the directory file where the package is stored
Command: cd /usr/local/src
#Download redis database package
Command: wget http://download.redis.io/redis-stable.tar.gz
#Unzip redis database package
Command: tar -zxvf redis-stable.tar.gz
#Create redis installation directory file
Command: mkdir /usr/local/redis
#Move files to installation directory
Command: mv redis-stable /usr/local/redis
#Enter installation directory
Command: cd /usr/local/redis
#Compile
Command: make
#Installation
Command: make install
#Then check if there are redis program files in/usr/local/bin directory, if not, copy redis program files from redis-stable
Command: cd /usr/local/bin
Command: LS
Note: If not, copy
Command: cd /usr/local/redis/redis-stable
Command: mkdir -p /usr/local/bin
#Copy operation command: cp -p redis-server /usr/local/bin Command: cp -p redis-benchmark /usr/local/bin Command: cp -p redis-cli /usr/local/bin Command: cp -p redis-check-dump /usr/local/bin Command: cp -p redis-check-aof /usr/local/bin
#Create a soft link to the redis profile (like a shortcut in windows)
Command: ln -s /usr/local/redis/redis-stable/redis.conf /etc/redis.conf
#Edit redis profile
Command: vi /etc/redis.conf
#Set background to start redis (vim editor press i to enter edit mode, exit edit mode to enter command mode)
daemonize yes
#Force Save Exit
:wq!
#Switch to/usr/local/bin directory to start redis service (cd switch command)
Command: redis-server /etc/redis.conf
#Close redis service
Command: redis-cli shutdown
#Edit, add the following code to the last line
Command: vi /etc/sysctl.conf
vm.overcommit_memory = 1
#Force Save Exit
:wq!
#Make settings take effect immediately
Command: sysctl -p
Step 4: Set redis to boot on linux server
#Copy the initialization script from redis tool to/etc/init.d/directory file and rename it
Command: cd /usr/local/redis/redis-stable/utils/
Command: cpredis_init_script/etc/init.d/
Command: cd/etc/init.d/
Command: mvredis_init_script redis
#Modify script execution permissions
Command: chmod 755 /etc/init.d/redis
#Add Boot Start
Command: chkconfig --add redis
At this time, you may encounter problems, that is, can not add redis to boot, so how to solve it?
#Edit/etc/init.d/redis file
Command: vi/etc/init.d/redis(i enters edit mode, exit returns command mode:wq! Forced Save Exit)
Add two lines of comments to the front of the/etc/init.d/redis file:
# chkconfig: 2345 90 10# description: Redis is a persistent key-value database
The comment above means that redis services must be enabled or disabled at runlevels 2, 3, 4, and 5, with priority 90 for enabling and priority 10 for disabling.
#Add Boot Start
Command: chkconfig --add redis
#Put redis on at runlevels 2, 3, 4, and 5
Command: chkconfig -level redis 2345 on
#Check whether the addition is successful, list all system services, check whether there is redis in them
Command: chkconfig --list
#Close redis service, start redis service
Command: service redis stop
Command: service redis start
Final step: test whether redis has successfully started the service
#View local IP address
#Testing in native java applications using third-party jar package jedis
I believe that many people will definitely not pass when executing, such as connection timeout and the like. Why is this? Let's solve one by one:
1. View redis configuration file, troubleshoot, edit and save
Command: vi /etc/redis.conf
The first possible problem is that the ip is bound and the other ip cannot be accessed:
After commenting out the attribute IP, he continued to investigate. There was still a possible problem. Protection mode was turned on:
Change it from yes to no, and then run java program tests, many people may still encounter similar errors, such as:
After the previous operation, we can confirm that redis service is started, ip port settings are correct, protection mode is also closed by us, but also can not access, it is likely that Linux firewall caused other computers can not access redis port 6379, we now test on windows, through cmd open command window, telnet command if not used, Baidu to open it.
Command: telnet 192.168.0.21 6379
If nothing happens for a long time, or an error occurs, you need to turn off the firewall on the Linux server or add this port to allow access.
#Log in to Linux server as root and execute command to open port
Command: /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
Then run a wave of Java application tests, and you'll have basically no problems, and you'll get the correct results like above.
II. Installation without external network. Suppose there is only local area network at this time. What should I do?
Step 1: Mount the image file corresponding to the Linux server to the/mnt directory file
For example: mount -o loop/data/downloads/redhat/rhel-server-6.5-x86_64-dvd. iso/mnt
#Image packages contain most of the software needed to play Linux
cd /mnt/Packages
Step 2: Install the gcc compilation tool. The relevant installation package is obtained from the package package of centos6.6.iso image file.
Execute the following command:
rpm -ivh mpfr-2.4.1-6.el6.i686.rpm Enter rpm -ivh cpp-4.4.6-4.el6.i686.rpm Enter rpm -ivh kernel-headers-2.6.32-279.el6.i686.rpm Enter rpm -ivh glibc-headers-2.12-1.80.el6.i686.rpm Enter rpm -ivh glibc-devel-2.12-1.80.el6.i686.rpm Enter rpm -ivh libgomp-4.4.6-Enter 4.el6.i686.rpm Enter rpm -ivh ppl-0.10.2-11.el6.i686.rpmrpm -ivh cloog-ppl-0.15.7-1.2.el6.i686.rpm Enter rpm -ivh gcc-4.4.6-4.el6.i686.rpm Enter rpm -ivh libstdc++-devel-4.4.7-11.el6.x86_64.rpm Enter rpm-ivh gcc-c ++-4.4.6-4.el6.i686.rpm Enter rpm -ivh gcc-c ++4.4.6-4.el6.i686.rpm Enter
If error: Failed dependencies: cpp = 4.4.7-4.el6 is needed by gcc-4.4.7-4.el6.x86_64
When installing gcc and other dependencies, add the parameter--force --nodeps
For example:
rpm -ivh gcc-4.4.7 - 4.el6.x86_64.rpm--nodeps --force#rpm unload command rpm -e --nodeps gcc-4.4.7-4.el6.x86_64#unload mounted resources umount /mnt
Step 3: Install the downloaded tcl package into the Linux server.
Copy the file to/usr/local/src (random directory)
chmod 777 tcl8.6.1-src.tar.gz tar xzvf tcl8.6.1-src.tar.gzcd tcl8.6.1/nuix./ configure or./ configure --prefix=/usr/local/tcl8.6.1/ --enable-sharedmakemake install
Step 4: Install the downloaded redis database installation package to the Linux server
Copy the file to/usr/local/src (random directory)
chmod 777 redis-2.8.8.tar.gztar xzf redis-2.8.8.tar.gzcd redis-2.8.8make MALLOC=libcmake testmake install
The latter way is probably to give you an idea, you can completely combine the above detailed online installation method to achieve no external network installation, the main difference here is that there is no external network gcc compilation tool can be obtained from the mounted ios image, and then all the installation packages are already downloaded, need to upload to the Linux server.
Thank you for reading this article carefully. I hope that the article "How to install redis database on Linux server" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support it a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!
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.