我正在尝试使用 mongodb 3.4 设置副本集,但遇到以下错误。尝试四处搜索但无法找到解决方案。
root@mongo-db-1:~# mongo MongoDB shell version v3.4.0 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.0
> use admin
switched to db admin
> db.auth('admin','****');
1
> db.system.users.find();
{ "_id" : "admin.admin", "user" : "admin", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "DKkxOnMHCSSPwJCJyLA9Eg==", "storedKey" : "9aD//lm3eyeBN2LqZeTdqvvKXlU=", "serverKey" : "OX07H3FVQ447OqGMD7mCmX0WU0M=" } }, "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }
> rs.conf()
2016-12-20T09:58:45.579+0530 E QUERY [main] Error: Could not retrieve replica set config: {
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { replSetGetConfig: 1.0 }",
"code" : 13,
"codeName" : "Unauthorized"
} :
rs.conf@src/mongo/shell/utils.js:1262:11
@(shell):1:1
MongoDB 日志
2016-12-20T09:58:01.278+0530 I NETWORK [thread1] connection accepted from 127.0.0.1:60804 #2 (1 connection now open)
2016-12-20T09:58:01.279+0530 I NETWORK [conn2] received client metadata from 127.0.0.1:60804 conn2: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.0" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "14.04" } }
2016-12-20T09:58:01.282+0530 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { getLog: "startupWarnings" }
2016-12-20T09:58:01.285+0530 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { replSetGetStatus: 1.0, forShell: 1.0 }
2016-12-20T09:58:19.044+0530 I ACCESS [conn2] Successfully authenticated as principal admin on admin
2016-12-20T09:58:19.046+0530 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { replSetGetStatus: 1.0, forShell: 1.0 }
2016-12-20T09:58:45.578+0530 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { replSetGetConfig: 1.0 }
我在这里遗漏了什么吗?
Mongo 配置
root@mongo-db-1:~# cat /etc/mongod.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
security:
authorization: enabled
keyFile: /thefile
processManagement:
fork: true
replication:
replSetName: rs0
最佳答案
您必须将 clusterMagnager 权限授予您的“管理员”用户。要将 clusterManager 角色添加到您的管理员用户,您必须在身份验证后执行以下功能。
db.grantRolesToUser(
"admin",
[ "clusterManager" ]
)
关于MongoDB 未授权 : replSetGetConfig,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41235004/
Doorkeeper中Token和Grant的区别我搞不清楚。Doorkeeper在哪个时刻创建访问授权,何时创建访问token?文档似乎对此什么也没说,现在我正在阅读代码,但不是十几行。 最佳答案 我还建议阅读documentationofoauth2据我了解,Doorkeeper也是基于该文档中描述的协议(protocol)。在doorkeeper中,你会先获得accessgrant,然后是accesstoken。访问授权通常只存在很短的时间(doorkeeper中的默认值为10分钟)。您将通过向api-url/oauth/au
我正在尝试为自己创建一个直接连接到我的日历的应用程序……但我从不想参与重新验证。我只想编写一次身份验证代码并完成它。授权码如下:key=Google::APIClient::PKCS12.load_key(SERVICE_ACCOUNT_PKCS12_FILE_PATH,PASSWORD)asserter=Google::APIClient::JWTAsserter.new(SERVICE_ACCOUNT_EMAIL,'https://www.googleapis.com/auth/calendar',key)@client=Google::APIClient.new@client.a
我正在努力让google-api-ruby-clientgem按照这里的基本用法示例工作:基本用法require'google/apis/drive_v2'Drive=Google::Apis::DriveV2#Aliasthemoduledrive=Drive::DriveService.newdrive.authorization=...#SeeGoogleauthorSignetlibraries#SearchforfilesinDrive(firstpageonly)files=drive.list_files(q:"titlecontains'finances'")files
我正在使用Deviseauthtokengem用于验证我的Rails应用程序的某些部分。但是,当我尝试使用注册路径创建新用户时,出现以下错误{"errors":["Authorizedusersonly."]}。这是我用于测试的rspec代码,it'createsauserusingemail/passwordcombo'dopostapi_user_registration_path,{email:'xxx',password:'yyy',password_confirmation:'yyy'}putslast_response.bodyexpect(last_response.bo
有道无术,术尚可求,有术无道,止于术。本系列SpringBoot版本3.0.4本系列SpringSecurity版本6.0.2本系列SpringAuthorizationServer版本1.0.2源码地址:https://gitee.com/pearl-organization/study-spring-security-demo文章目录前言1.OAuth2AuthorizationServerMetadataEndpointFilter2.OAuth2AuthorizationEndpointFilter3.OidcProviderConfigurationEndpointFilter4.N
我正在寻找一个很好的基于角色的授权解决方案来与Authlogic一起使用。有人有什么好的建议吗?如果可能,请根据您的经验列出一些优缺点。 最佳答案 Acl9与AuthLogic配合得很好:http://github.com/be9/acl9/tree/master 关于ruby-on-rails-与Authlogic一起使用的一些好的角色授权解决方案是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.c
我正在为ruby使用googleapi,但不知道如何开始,请给我一个ABC示例,非常感谢? 最佳答案 如果您要创建服务帐户应用程序以访问GoogleAnalytics。通过https://code.google.com/apis/console向Google注册.在APIAccess选项卡上,单击CreateclientID,选择ServiceAccount。存储Google将生成的key文件,并记住该key的密码。这里有一些代码可以帮助您入门require'rubygems'require'google/api_client'
我们在服务器管理中有以下模式-所有用户都有自己的用户,但部署完全由特殊部署用户执行,没有直接登录的可能性。我们在Capistrano2.x中使用了这个方法:default_run_options[:shell]="sudo-udeploybash"$capstagedeploy-suser=thisisme我知道Capistrano3.x有直接切换用户的方法:task:installdoonroles(:all)doas:deploydoexecute:whoamiendendend但是这段代码会填充所有任务,默认任务不会继承deploy用户。是否可以直接设置登录用户而无需将此代码拖到
这个问题在这里已经有了答案:HowdoIupdateRubyGemsfrombehindaProxy(ISA-NTLM)(20个答案)关闭7年前。我在公司代理后面,需要授权才能使用它。当我尝试仅使用选项-phttp://ip.of.my.proxy:3128时,它会抛出错误407。有解决方法吗?
我可以在一个Rails应用程序中同时使用MongoDB和PostgreSQL吗?具体来说,我最终会想要使用像MongoHQ这样的东西。到目前为止,我未能在实验中进行这项工作。令我担心的是,MongoDB文档特别指出我必须禁用ActiveRecord。任何建议将不胜感激。 最佳答案 您无需禁用ActiveRecord即可使用MongoDB。查看Mongoid只需将gem加上任何模型与您现有的任何ActiveRecord模型一起添加。您应该注意到MongoHQ只是MongoDB的托管服务,可以与任何对象文档映射器(ODM)一起使用。更多