这期内容当中小编将会给大家带来有关linux系统如何安装Redis服务,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。一、配置本地yum源,用于安装Redis所需要包:Http://blog.itpub.n
这期内容当中小编将会给大家带来有关linux系统如何安装Redis服务,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
准备工作:将包括redis在内的redis-3.2.8.tar.gz安装包放到指定位置(此位置可以自建,为了统一,全部放在/var/software/目录下)
(1)解压redis安装包:
[root@caiji software]# tar -xvf redis-3.2.8.tar.gz............
进入解压后的文件中:
[root@caiji software]# cd redis-3.2.8[root@caiji redis-3.2.8]# ls00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel testsBUGS deps MANIFESTO runtest sentinel.conf utilsCONTRIBUTING INSTALL README.md runtest-cluster src
使用yum命令安装redis所需要的包和编译工具:
[root@caiji software]# yum -y install wget make GCc gcc-c++ zlib-devel openssl openssl-devel pcre-devel kernel keyutils patch perl
(以下为输出内容,如果有的包已经安装过的话,输出内容会有所差别,大体是一样的!)
Loaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not reGIStered to Red Hat Subscription Management. You can use subscription-manager to register.Setting up Install ProcessPackage wget-1.12-1.8.el6.x86_64 already installed and latest versionPackage 1:make-3.81-20.el6.x86_64 already installed and latest versionPackage openssl-1.0.1e-15.el6.x86_64 already installed and latest versionPackage kernel-2.6.32-431.el6.x86_64 already installed and latest versionPackage keyutils-1.4-4.el6.x86_64 already installed and latest versionPackage patch-2.6-6.el6.x86_64 already installed and latest versionPackage 4:perl-5.10.1-136.el6.x86_64 already installed and latest versionResolving Dependencies--> Running transaction check---> Package gcc.x86_64 0:4.4.7-4.el6 will be installed--> Processing Dependency: cpp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-4.el6.x86_64---> Package gcc-c++.x86_64 0:4.4.7-4.el6 will be installed--> Processing Dependency: libstdc++-devel = 4.4.7-4.el6 for package: gcc-c++-4.4.7-4.el6.x86_64--> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.7-4.el6.x86_64---> Package openssl-devel.x86_64 0:1.0.1e-15.el6 will be installed--> Processing Dependency: krb5-devel for package: openssl-devel-1.0.1e-15.el6.x86_64---> Package pcre-devel.x86_64 0:7.8-6.el6 will be installed---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed--> Running transaction check---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64---> Package cpp.x86_64 0:4.4.7-4.el6 will be installed---> Package krb5-devel.x86_64 0:1.10.3-10.el6_4.6 will be installed--> Processing Dependency: libselinux-devel for package: krb5-devel-1.10.3-10.el6_4.6.x86_64--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.10.3-10.el6_4.6.x86_64--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.10.3-10.el6_4.6.x86_64---> Package libstdc++-devel.x86_64 0:4.4.7-4.el6 will be installed---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed--> Running transaction check---> Package keyutils-libs-devel.x86_64 0:1.4-4.el6 will be installed---> Package libcom_err-devel.x86_64 0:1.41.12-18.el6 will be installed---> Package libselinux-devel.x86_64 0:2.0.94-5.3.el6_4.1 will be installed--> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-5.3.el6_4.1.x86_64--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-5.3.el6_4.1.x86_64---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed--> Running transaction check---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================ Package Arch Version Repository Size================================================================================Installing: gcc x86_64 4.4.7-4.el6 local 10 M gcc-c++ x86_64 4.4.7-4.el6 local 4.7 M openssl-devel x86_64 1.0.1e-15.el6 local 1.2 M pcre-devel x86_64 7.8-6.el6 local 318 k zlib-devel x86_64 1.2.3-29.el6 local 44 kInstalling for dependencies: cloog-ppl x86_64 0.15.7-1.2.el6 local 93 k cpp x86_64 4.4.7-4.el6 local 3.7 M keyutils-libs-devel x86_64 1.4-4.el6 local 28 k krb5-devel x86_64 1.10.3-10.el6_4.6 local 495 k libcom_err-devel x86_64 1.41.12-18.el6 local 32 k libselinux-devel x86_64 2.0.94-5.3.el6_4.1 local 136 k libsepol-devel x86_64 2.0.41-4.el6 local 64 k libstdc++-devel x86_64 4.4.7-4.el6 local 1.6 M mpfr x86_64 2.4.1-6.el6 local 156 k ppl x86_64 0.10.2-11.el6 local 1.3 MTransaction Summary================================================================================Install 15 Package(s)Total download size: 24 MInstalled size: 59 MDownloading Packages:--------------------------------------------------------------------------------Total 48 MB/s | 24 MB 00:00 Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: RPMDB altered outside of yum. Installing : mpfr-2.4.1-6.el6.x86_64 1/15 Installing : cpp-4.4.7-4.el6.x86_64 2/15 Installing : ppl-0.10.2-11.el6.x86_64 3/15 Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 4/15 Installing : gcc-4.4.7-4.el6.x86_64 5/15 Installing : zlib-devel-1.2.3-29.el6.x86_64 6/15 Installing : libcom_err-devel-1.41.12-18.el6.x86_64 7/15 Installing : keyutils-libs-devel-1.4-4.el6.x86_64 8/15 Installing : libsepol-devel-2.0.41-4.el6.x86_64 9/15 Installing : libselinux-devel-2.0.94-5.3.el6_4.1.x86_64 10/15 Installing : krb5-devel-1.10.3-10.el6_4.6.x86_64 11/15 Installing : libstdc++-devel-4.4.7-4.el6.x86_64 12/15 Installing : gcc-c++-4.4.7-4.el6.x86_64 13/15 Installing : openssl-devel-1.0.1e-15.el6.x86_64 14/15 Installing : pcre-devel-7.8-6.el6.x86_64 15/15 local/productid | 1.7 kB 00:00 ... Verifying : pcre-devel-7.8-6.el6.x86_64 1/15 Verifying : libstdc++-devel-4.4.7-4.el6.x86_64 2/15 Verifying : libsepol-devel-2.0.41-4.el6.x86_64 3/15 Verifying : keyutils-libs-devel-1.4-4.el6.x86_64 4/15 Verifying : cpp-4.4.7-4.el6.x86_64 5/15 Verifying : libcom_err-devel-1.41.12-18.el6.x86_64 6/15 Verifying : openssl-devel-1.0.1e-15.el6.x86_64 7/15 Verifying : libselinux-devel-2.0.94-5.3.el6_4.1.x86_64 8/15 Verifying : mpfr-2.4.1-6.el6.x86_64 9/15 Verifying : zlib-devel-1.2.3-29.el6.x86_64 10/15 Verifying : gcc-4.4.7-4.el6.x86_64 11/15 Verifying : krb5-devel-1.10.3-10.el6_4.6.x86_64 12/15 Verifying : gcc-c++-4.4.7-4.el6.x86_64 13/15 Verifying : ppl-0.10.2-11.el6.x86_64 14/15 Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 15/15 Installed: gcc.x86_64 0:4.4.7-4.el6 gcc-c++.x86_64 0:4.4.7-4.el6 openssl-devel.x86_64 0:1.0.1e-15.el6 pcre-devel.x86_64 0:7.8-6.el6 zlib-devel.x86_64 0:1.2.3-29.el6 Dependency Installed: cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-4.el6 keyutils-libs-devel.x86_64 0:1.4-4.el6 krb5-devel.x86_64 0:1.10.3-10.el6_4.6 libcom_err-devel.x86_64 0:1.41.12-18.el6 libselinux-devel.x86_64 0:2.0.94-5.3.el6_4.1 libsepol-devel.x86_64 0:2.0.41-4.el6 libstdc++-devel.x86_64 0:4.4.7-4.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6 Complete!
(以上输出表示包和编译工具安装成功!)
安装成功后在进入redis解压的目录中执行make命令:
[root@caiji redis-3.2.8]# make(以下是命令输出)cd src && make allmake[1]: Entering directory `/var/software/redis-3.2.8/src'rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html(cd ../deps && make distclean)make[2]: Entering directory `/var/software/redis-3.2.8/deps'(cd hiredis && make clean) > /dev/null || true(cd linenoise && make clean) > /dev/null || true(cd lua && make clean) > /dev/null || true(cd geohash-int && make clean) > /dev/null || true(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true..........省略部分输出。。。。。.......... CC crc16.o CC endianconv.o CC slowlog.o CC scripting.o CC bio.o CC rio.o CC rand.o CC memtest.o CC crc64.o CC bitops.o CC sentinel.o CC notify.o CC setproctitle.o CC blocked.o CC hyperloglog.o CC latency.o CC sparkline.o CC redis-check-rdb.o CC geo.o LINK redis-server INSTALL redis-sentinel CC redis-cli.o LINK redis-cli CC redis-benchmark.o LINK redis-benchmark INSTALL redis-check-rdb CC redis-check-aof.o LINK redis-check-aofHint: It's a Good idea to run 'make test' ;)make[1]: Leaving directory `/var/software/redis-3.2.8/src'
(自此执行make成功!)
PS: 注意如果make显示错误,按照以下方法解决: 如果提示couldn’t execute tcl : no such file or
dicrectory,请自行安装tcl; 如果提示请执行make distclean,然后再make
make成功之后,会在/var/software/redis-3.2.8/src目录下多出一些文件,如下:
然后执行make install:
[root@caiji redis-3.2.8]# make installcd src && make installmake[1]: Entering directory `/var/software/redis-3.2.8/src'Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL installmake[1]: Leaving directory `/var/software/redis-3.2.8/src'
执行完make install后会在目录/usr/local/bin下生成以下文件:
[root@caiji redis-3.2.8]# ll /usr/local/bintotal 26344-rwxr-xr-x. 1 root root 5578239 May 5 11:01 redis-benchmark-rwxr-xr-x. 1 root root 22185 May 5 11:01 redis-check-aof-rwxr-xr-x. 1 root root 7827882 May 5 11:01 redis-check-rdb-rwxr-xr-x. 1 root root 5707107 May 5 11:01 redis-clilrwxrwxrwx. 1 root root 12 May 5 11:01 redis-sentinel -> redis-server-rwxr-xr-x. 1 root root 7827882 May 5 11:01 redis-server
查看redis版本号:
[root@caiji redis-3.2.8]# /usr/local/bin/redis-server -vRedis server v=3.2.8 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=1882e7b0ae5da5a3
(自此redis安装完成)
配置redis:
[root@caiji redis-3.2.8]# ./utils/install_server.sh Welcome to the redis service installerThis script will help you easily set up a running redis serverPlease select the redis port for this instance: [6379] ----直接默认下一步,端口号默认为6379Selecting default: 6379Please select the redis config file name [/etc/redis/6379.conf] ----默认下一步,此处配置文件名和位置Selected default - /etc/redis/6379.confPlease select the redis log file name [/var/log/redis_6379.log] ----默认下一步,此处日志名和位置Selected default - /var/log/redis_6379.logPlease select the data directory for this instance [/var/lib/redis/6379] ----默认下一步,数据文件存放位置Selected default - /var/lib/redis/6379Please select the redis executable path [/usr/local/bin/redis-server] ----默认下一步,redis服务路径位置 Selected config:Port : 6379Config file : /etc/redis/6379.confLog file : /var/log/redis_6379.logData dir : /var/lib/redis/6379Executable : /usr/local/bin/redis-serverCli Executable : /usr/local/bin/redis-cliIs this ok? Then press ENTER to go on or Ctrl-C to abort.Copied /tmp/6379.conf => /etc/init.d/redis_6379Installing service...Successfully added to chkconfig!Successfully added to runlevels 345!Starting Redis server...Installation successful!
(自此redis配置成功,并且为开机启动方式)
然后根据要求对redis的配置文件进行修改:
[root@caiji redis-3.2.8]# vim /etc/redis/6379.conf
修改项看截图,根据截图找到修改项,修改成截图中的值:
配置文件修改完毕后将redis服务停止:
[root@caiji redis-3.2.8]# /etc/init.d/redis_6379 stopStopping ...Waiting for Redis to shutdown ...Redis stopped
然后重新启动:
[root@caiji redis-3.2.8]# /etc/init.d/redis_6379 startStarting Redis server...
查看进程无误,表示修改成功:
[root@caiji redis-3.2.8]# ps -ef | grep redisroot 32106 1 0 11:31 ? 00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379 root 32111 3030 0 11:31 pts/0 00:00:00 grep redis
(自此redis安装配置完毕,并且是启动状态!)
通过ps -ef|grep redis命令查看Redis进程:
[root@caiji redis-3.2.8]# ps -ef | grep redisroot 32106 1 0 11:31 ? 00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379 root 32111 3030 0 11:31 pts/0 00:00:00 grep redis
开启Redis服务操作通过/etc/init.d/redis_6379 start命令,也可通过:service redis_6379 start
关闭Redis服务操作通过/etc/init.d/redis_6379 stop命令,也可通过:service redis_6379 stop
为了提高安全性可以对Redis中root用户设置密码。
方法如下:
1.临时修改,重启后失效:
[root@local ~]# cd /usr/local/bin[root@local bin]# llotal 26344-rwxr-xr-x. 1 root root 5578239 May 5 11:01 redis-benchmark-rwxr-xr-x. 1 root root 22185 May 5 11:01 redis-check-aof-rwxr-xr-x. 1 root root 7827882 May 5 11:01 redis-check-rdb-rwxr-xr-x. 1 root root 5707107 May 5 11:01 redis-clilrwxrwxrwx. 1 root root 12 May 5 11:01 redis-sentinel -> redis-server-rwxr-xr-x. 1 root root 7827882 May 5 11:01 redis-server[root@local bin]# ./redis-cli127.0.0.1:6379> config set requirepass pwtest10OK127. 0.0.1:6379> auth pwtest10OK127.0.0.1:6379> config get requirepass1) "requirepass"2) "pwtest10"
以上设置密码命令 “config set requirepass pwtest10” 将Redis的root用户密码设置为pwtest10,查询密码使用命令 “config get requirepass”,但是这是临时设置,如果重启Redis,密码就会失效。
永久设置密码:
打开Redis的配置文件 /etc/redis/6379.conf 找到配置参数 ** # requirepass foobared ** 此参数是备注释掉的,去掉注释修改为 ** requirepass pwtest10 **。
配置文件修改后重启Redis即可。
上述就是小编为大家分享的Linux系统如何安装Redis服务了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注编程网操作系统频道。
--结束END--
本文标题: Linux系统如何安装Redis服务
本文链接: https://lsjlt.com/news/243541.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0