一、简介
github官网说Pika 是一个高性能、大容量、多租户、数据持久化的弹性 KV 数据存储系统,使用 RocksDB 作为存储引擎。它完全兼容 Redis 协议,并支持其常用的数据结构,如字符串/哈希/列表/有序集合/集合/地理位置/HyperLogLog/发布-订阅/位图/数据流等。
二、对标啥能干啥,为啥用
持久化的KV数据库,性能上肯定比MySQL InnoDB好,但是会比Redis有点差异毕竟是持久化的存读,速度关系大致:MySQL<Pika<Redis,Pika使用了很多优化来确保性能上趋于Redis,使得它也是一个可以满足高并发的KV数据库
使用它的原因有很多:Redis贵(基于内存),磁盘就便宜很多了,使用非常大空间也不心疼;持久化方面,Redis是有AOF和RDB的,但是pika直接属于持久化,更加可靠
三、安装
1.首先下载安装包
wget下载
wget https://github.com/OpenAtomFoundation/pika/releases/download/v3.5.5/pika-linux-x86_64-v3.5.5.tar.bz2
wget慢的话去github下载,下载地址:Release Release v3.5.5 · OpenAtomFoundation/pika
下载bz2版本的即可,tar只是打包,没压缩,而bz2是压缩后的空间占用小,它这里比tar大的原因是它里面有集成一些插件,就不用手动安装了。
2.安装解压bz2解压程序
yum install -y bzip2
问题1:yum安装出现镜像源访问失败的报错
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
.......一大堆........
Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64
最后一行的报错说明这个文件的镜像源需要换一下,先备份一下原来的文件再新建一个
-- 进入镜像源配置目录
cd /etc/yum.repos.d
-- 备份
cp ./源文件名 ./源文件名.bak
-- 删掉旧的
sudo rm -rf 文件名
然后再vim 文件名,把下面的镜像信息粘贴进去(亲测可用):
# 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/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/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/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/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/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/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/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
: wq保存,然后再执行刷新yum缓存命令,如果还出现上面的问题,估计是其他的镜像配置出了问题,也都改成上面可用的那个,然后重新执行下面命令即可
sudo yum clean all
sudo yum makecache
3.解压
我是把安装包方式在/data/pika目录了
tar -xvf pika-linux-x86_64-v3.5.3.tar.bz2
然后会出现output目录,进入它会看到conf和bin,一看就是配置和启动程序(绿色)
4.启动
进入bin目录,输入如下命令后台启动即可:
nohup ./pika -c ../conf/pika.conf
当前是用的默认配置,默认是没有账户和密码的,以及其他配置参考:pika/tools/pika_exporter/README.md at unstable · OpenAtomFoundation/pika · GitHub
5.使用RESP(windows上的Redis客户端软件)连接Pika
四、官方文档介绍
pika/README_CN.md at unstable · OpenAtomFoundation/pika