redis的下载与安装(linux版)
redis的下载与安装(linux版)
1.下载路径
https://redis.io/download
2.上传到linux
3.进入解压之后的redis,并且make && make install
4.安装成功之后,进入Redis的src目录
启动服务端:./redis-server
启动客户端:./redis-cli
启动之后输入 ping 回复pong 表明成功
安装过程中遇到的问题:
解决方案:升级到最新的gcc:
[root@localhost redis-6.0.1]# gcc -v [root@localhost redis-6.0.1]# yum -y install centos-release-scl [root@localhost redis-6.0.1]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils [root@localhost redis-6.0.1]# scl enable devtoolset-9 bash [root@localhost redis-6.0.1]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
解决方案:
替换yum源:
[base] name=Base baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/ enabled=1 [epel] name=epel baseurl=https://mirrors.aliyun.com/epel/7/x86_64/ enabled=1
替换为:
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
再次编译即可!
在后台运行redis:
redis-server --daemonize yes
客户端远程连接redis服务器:
-h 远程服务器ip,-p远程服务器端口(redus服务器默认占用端口6379),-a远程服务器密码
redis-cli -h 192.168.26.38 -p 6379 -a waftest
注意,如果要启用远程服务器连接redis,需要在redis服务器中,/etc/redis.conf中,修改以下两处配置:
redis服务器配置文件需要,存放到:/etc/下,启动redis服务器命令如下:
./redis-server /etc/redis.conf
当执行:./redis-server /etc/redis.conf命令之后,redis服务器没有起来时,应该是端口被占用了
执行:ps -aux |grep redis 查看占用的进程pid
执行:kill -9 pid 杀掉该进程;然后再重新启用该进程。
redis服务器,如果需要远程连接:需要开发6379端口:
查看开发端口:
firewall-cmd --list-ports
关闭防火墙:
systemctl stop firewalld
添加端口:
firewall-cmd add-tcp=port=6379/tcp --permanent
重启防护墙
firewall-cmd --reload
firewall命令:https://www.jianshu.com/p/a5bd8a6d7e8f
yum源:http://realtechtalk.com/Centos_59_Working_Vault_Repo_file-1921-articles