教你安装部署 Redis 单节点详细步骤
第一步 下载Redis
下载地址:http://www.redis.cn/download/
第二步 安装Redis
[root@localhost /]# cd /home/logonuser/app/
[root@localhost app]# ll
总用量 2180
-rw-r–r–. 1 root root 2228781 12月 17 15:58 redis-6.0.6.tar.gz
[root@localhost app]# tar xzf redis-6.0.6.tar.gz
[root@localhost app]# ll
总用量 2184
drwxrwxr-x. 7 root root 4096 7月 21 2020 redis-6.0.6
-rw-r–r–. 1 root root 2228781 12月 17 15:58 redis-6.0.6.tar.gz
[root@localhost app]# cd redis-6.0.6/
[root@localhost redis-6.0.6]# ll
总用量 260
-rw-rw-r–. 1 root root 80561 7月 21 2020 00-RELEASENOTES
-rw-rw-r–. 1 root root 51 7月 21 2020 BUGS
-rw-rw-r–. 1 root root 2381 7月 21 2020 CONTRIBUTING
-rw-rw-r–. 1 root root 1487 7月 21 2020 COPYING
drwxrwxr-x. 6 root root 124 7月 21 2020 deps
-rw-rw-r–. 1 root root 11 7月 21 2020 INSTALL
-rw-rw-r–. 1 root root 151 7月 21 2020 Makefile
-rw-rw-r–. 1 root root 6888 7月 21 2020 MANIFESTO
-rw-rw-r–. 1 root root 20806 7月 21 2020 README.md
-rw-rw-r–. 1 root root 83392 7月 21 2020 redis.conf
-rwxrwxr-x. 1 root root 275 7月 21 2020 runtest
-rwxrwxr-x. 1 root root 280 7月 21 2020 runtest-cluster
-rwxrwxr-x. 1 root root 679 7月 21 2020 runtest-moduleapi
-rwxrwxr-x. 1 root root 281 7月 21 2020 runtest-sentinel
-rw-rw-r–. 1 root root 10743 7月 21 2020 sentinel.conf
drwxrwxr-x. 3 root root 4096 7月 21 2020 src
drwxrwxr-x. 11 root root 182 7月 21 2020 tests
-rw-rw-r–. 1 root root 3055 7月 21 2020 TLS.md
drwxrwxr-x. 9 root root 4096 7月 21 2020 utils
[root@localhost redis-6.0.6]# make
[root@localhost app]# ll
总用量 2180
-rw-r–r–. 1 root root 2228781 12月 17 15:58 redis-6.0.6.tar.gz
[root@localhost app]# tar xzf redis-6.0.6.tar.gz
[root@localhost app]# ll
总用量 2184
drwxrwxr-x. 7 root root 4096 7月 21 2020 redis-6.0.6
-rw-r–r–. 1 root root 2228781 12月 17 15:58 redis-6.0.6.tar.gz
[root@localhost app]# cd redis-6.0.6/
[root@localhost redis-6.0.6]# ll
总用量 260
-rw-rw-r–. 1 root root 80561 7月 21 2020 00-RELEASENOTES
-rw-rw-r–. 1 root root 51 7月 21 2020 BUGS
-rw-rw-r–. 1 root root 2381 7月 21 2020 CONTRIBUTING
-rw-rw-r–. 1 root root 1487 7月 21 2020 COPYING
drwxrwxr-x. 6 root root 124 7月 21 2020 deps
-rw-rw-r–. 1 root root 11 7月 21 2020 INSTALL
-rw-rw-r–. 1 root root 151 7月 21 2020 Makefile
-rw-rw-r–. 1 root root 6888 7月 21 2020 MANIFESTO
-rw-rw-r–. 1 root root 20806 7月 21 2020 README.md
-rw-rw-r–. 1 root root 83392 7月 21 2020 redis.conf
-rwxrwxr-x. 1 root root 275 7月 21 2020 runtest
-rwxrwxr-x. 1 root root 280 7月 21 2020 runtest-cluster
-rwxrwxr-x. 1 root root 679 7月 21 2020 runtest-moduleapi
-rwxrwxr-x. 1 root root 281 7月 21 2020 runtest-sentinel
-rw-rw-r–. 1 root root 10743 7月 21 2020 sentinel.conf
drwxrwxr-x. 3 root root 4096 7月 21 2020 src
drwxrwxr-x. 11 root root 182 7月 21 2020 tests
-rw-rw-r–. 1 root root 3055 7月 21 2020 TLS.md
drwxrwxr-x. 9 root root 4096 7月 21 2020 utils
[root@localhost redis-6.0.6]# make
make 编译完成以后提示 Hint: It’s a good idea to run ‘make test’ ? 则安装成功
如若在安装中出现报错:例如:
解决方式:
[root@localhost redis-6.0.6]# gcc -v
[root@localhost redis-6.0.6]# yum -y install centos-release-scl
[root@localhost redis-6.0.6]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost redis-6.0.6]# scl enable devtoolset-9 bash
[root@localhost redis-6.0.6]# echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile
[root@localhost redis-6.0.6]# yum -y install centos-release-scl
[root@localhost redis-6.0.6]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost redis-6.0.6]# scl enable devtoolset-9 bash
[root@localhost redis-6.0.6]# echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile
第三步 修改配置文件
[root@localhost redis-6.0.6]# gcc -v
[root@localhost redis-6.0.6]# yum -y install centos-release-scl
[root@localhost redis-6.0.6]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost redis-6.0.6]# scl enable devtoolset-9 bash
[root@localhost redis-6.0.6]# echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile
[root@localhost redis-6.0.6]# yum -y install centos-release-scl
[root@localhost redis-6.0.6]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost redis-6.0.6]# scl enable devtoolset-9 bash
[root@localhost redis-6.0.6]# echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile
要修改的配置文件内容:
bind :
port : 6385
pidfile /var/run/redis_6385.pid
daemonize yes 后台运行
第四步 启动服务
[root@localhost redis-6.0.6]# cd src/
[root@localhost src]# ls
[root@localhost src]# ./redis-server ../redis.conf
13385:C 17 Dec 2021 17:28:01.835 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
13385:C 17 Dec 2021 17:28:01.835 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=13385, just started
13385:C 17 Dec 2021 17:28:01.835 # Configuration loaded
[root@localhost src]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 690/rpcbind
tcp 0 0 192.168.209.129:6385 0.0.0.0:* LISTEN 13386/./redis-serve
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1767/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1184/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1183/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1541/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3239/sshd: root@pts
tcp6 0 0 :::111 :::* LISTEN 690/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1184/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1183/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1541/master
tcp6 0 0 ::1:6010 :::* LISTEN 3239/sshd: root@pts
[root@localhost src]# ls
[root@localhost src]# ./redis-server ../redis.conf
13385:C 17 Dec 2021 17:28:01.835 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
13385:C 17 Dec 2021 17:28:01.835 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=13385, just started
13385:C 17 Dec 2021 17:28:01.835 # Configuration loaded
[root@localhost src]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 690/rpcbind
tcp 0 0 192.168.209.129:6385 0.0.0.0:* LISTEN 13386/./redis-serve
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1767/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1184/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1183/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1541/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3239/sshd: root@pts
tcp6 0 0 :::111 :::* LISTEN 690/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1184/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1183/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1541/master
tcp6 0 0 ::1:6010 :::* LISTEN 3239/sshd: root@pts
检测Redis是否安装成功
[root@localhost src]# ./redis-cli -h 192.168.209.129 -p 6385
192.168.209.129:6385> set xiaohong hello-redis
OK
192.168.209.129:6385> get xiaohong
“hello-redis”
192.168.209.129:6385>
192.168.209.129:6385> set xiaohong hello-redis
OK
192.168.209.129:6385> get xiaohong
“hello-redis”
192.168.209.129:6385>
到此这篇关于Redis 单节点部署的实现的文章就介绍到这了,更多相关Redis 单节点部署内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!