Ubuntu Couchbase社区版6.0无法创建索引?

Ubuntu Couchbase社区版6.0无法创建索引?,ubuntu,go,couchbase,Ubuntu,Go,Couchbase,我尝试通过以下步骤安装Couchbase community edition来测试: echo ' deb [ arch=amd64 ] http://packages.couchbase.com/releases/couchbase-server/enterprise/deb/ xenial xenial/main deb [ arch=amd64 ] http://packages.couchbase.com/releases/couchbase-server/community/deb/

我尝试通过以下步骤安装Couchbase community edition来测试:

echo '
deb [ arch=amd64 ] http://packages.couchbase.com/releases/couchbase-server/enterprise/deb/ xenial xenial/main
deb [ arch=amd64 ] http://packages.couchbase.com/releases/couchbase-server/community/deb/ xenial xenial/main
deb http://packages.couchbase.com/ubuntu xenial xenial/main
' | sudo tee /etc/apt/sources.list.d/couchbase.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6EF1EAC479CF7903
sudo apt-get update
sudo apt-get install couchbase-server-community
apt list -a couchbase-server-community

# make command line available
echo '
export PATH=$PATH:/opt/couchbase/bin
' | tee -a .bashrc
export PATH=$PATH:/opt/couchbase/bin

# init cluster
couchbase-cli cluster-init -c 127.0.0.1 \
--cluster-username Administrator \
--cluster-password YourPassword \
--services data,index,query \
--cluster-ramsize 512 \
--cluster-index-ramsize 256

# create bucket
couchbase-cli bucket-create -c 127.0.0.1:8091 --username Administrator \
 --password YourPassword --bucket test1 --bucket-type couchbase \
 --bucket-ramsize 512

# start n1ql
cbq -u Administrator -p YourPassword -engine=http://127.0.0.1:8091/
和源代码:

主程序包
进口(
“fmt”
“github.com/kokizzu/gotro/L”
“gopkg.in/couchbase/gocb.v1”
“数学/兰德”
“时间”
)
const Username=`管理员`
const Password=`YourPassword`
const Bucket=`test1`
类型分数结构{
用户int64`json:“用户”`
RefId int64`json:“ref_id”`
Epoch int64`json:“Epoch”`
Score int`json:“Score”`
类型字符串`json:“类型”`
}
func main(){
群集,错误:=gocb.Connect(“couchbase://127.0.0.1")
如果L.IsError(错误,`无法连接到couchbase`){
返回
}
cluster.Authenticate(gocb.PasswordAuthenticator{Username:Username,Password:Password})
bucket,\:=cluster.OpenBucket(bucket,“”)
m:=bucket.Manager(“,”)
err=m.CreatePrimaryIndex(“”,true,false)
如果L.IsError(错误,`创建主索引失败'){
返回
}
索引:=[]字符串{`type`、`epoch`、`user`、`refid`}
对于u,索引:=范围索引{
err=m.CreateIndex(索引,[]字符串{index},true,false)
如果L.IsError(错误,`创建索引%s失败',索引){
返回
}
}
对于x:=0;x<10000;x++{
userId:=1+rand.Intn(1000)
refId:=1+rand.Intn(100)
epoch:=time.Now().AddDate(0,0,rand.Intn(365)+1).Unix()
分数:=10+兰特整数(100)
_,err:=bucket.Upsert(
fmt.Sprintf(“用户%dref%d”,用户ID,refId),
得分{
用户:int64(userId),
RefId:int64(RefId),
纪元:纪元,,
分数:分数,
类型:`score`,
}, 0)
如果L.IsError(错误,`failed upsert`){
返回
}
}
//使用查询
sql:=`选择用户,从`+Bucket+`中求和(分数),其中历元>$1按用户顺序按2描述分组`
查询:=gocb.NewN1qlQuery(sql)
窗口:=[]int{1,7,30,365}
对于_,delta:=范围窗口{
fmt.Println(三角洲)
epoch:=time.Now().AddDate(0,0,delta).Unix()
行,err:=bucket.execute1qlquery(查询,[]接口{}{epoch})
如果L.IsError(错误,`failed query%s`,sql){
返回
}
变量行接口{}
延迟行。关闭()
用于行。下一行(&row){
fmt.Printf(“行:%v”,行)
}
}
}
它显示错误:

2020-02-15 23:58:33.271 IsError ▶ &gocb.n1qlMultiError{
    {Code:0x1388, Message:"GSI CreateIndex() - cause: Fails to create index.  There is no available index service that can process this request at this time. Index Service can be in bootstrap, recovery, or non-reachable. Please retry the operation at a later time."},
}

我是否遗漏了一些步骤?或者这是Couchbase社区版6.0的局限性


在web UI上,集群已经有了“数据、索引、查询”标签,所以不应该在该集群上创建索引吗?

虽然我不能确定,但问题的核心可能是通过REST接口发送到Couchbase的命令是异步的。如错误所示,索引的某些组件可能尚未初始化,并且无法接受下一个命令。在编写命令脚本时,您可能会看到这种情况。Couchbase的REST接口确实表明工作将与HTTP 201应答异步。也就是说,REST接口无法检查是否完成,而且
couchbase cli
也无法检查,因此我相信它只会返回成功

由于像索引创建这样的操作可能是幂等的,所以只需使用backoff retry重试一段时间,作为解决方法


改进此接口的问题是。

出现这种情况的一个可能原因是,Couchbase正在侦听的同一端口上运行另一个进程,以便创建索引

您可以在此处查看Couchbase使用的端口:

要解决此问题,您可以按照本文所述更改索引端口,或者结束当前正在使用该端口的进程/服务

要使用端口查找进程的PID,可以在以管理员身份运行时在Windows命令提示符下运行netstat-aob


对我来说,我删除了9100端口上运行的服务,然后能够创建索引。

可能的重复项:,嗯。。。如果尝试手动创建主索引,会发生什么情况?@deniswsrosa相同错误
“code”:5000,“msg”:“GSI CreateIndex()-原因:无法创建索引。此时没有可用的索引服务可以处理此请求。索引服务可能处于引导、恢复或不可访问状态。请稍后重试此操作。“
我刚刚用相同的命令从头开始重新安装了我的Couchbase Community 6.0(cluster init,然后bucket create)我能够创建一级索引,没有任何问题。我想知道是否是磁盘/计算机的某些问题导致索引服务失败。再次尝试重新安装时,出现了相同的错误“_u”),但我卸载了couchbase,并尝试使用mongodb来代替。听到这个消息,我很难过。我想说的是,你遇到的问题很容易解决,而不是真正重要的部分——因此,如果你只是添加一个循环,你可能会得到你想要的结果,并能够检查Couchbase的其余部分。啊,可能这是对的,我让普罗米修斯监听端口9100,但太糟糕了,现在我对使用这个数据库XD没有兴趣了