各位新朋友~记得先点蓝字关注我哦~
192.168.238.190:6379> config get requirepass1) "requirepass"2) "hzmcdba"192.168.238.190:6379> auth hzmcdbaOK
该功能是可以给定每个用户不同的访问权限,当然为了兼容之前的版本,也是保留了之前的密码设置功能。
设置ACL我们有几种方式:
192.168.238.190:6379> acl list1) "user default on sanitize-payload #684a427ede5381357cfb99c6ef61a84376a0639830b26a511e458d3398fefa4e ~* &* +@all"
其中user为关键词,default为用户名,后面的内容为ACL规则描述,on表示活跃的,sanitize-payload表示密码, ~* 表示所有key,+@all表示所有命令。所以上面的命令表示活跃用户default无密码且可以访问所有命令以及所有数据。
192.168.238.190:6379> acl setuser xjm on >xjm123 ~a* +get +setOK切换到xjm用户192.168.238.190:6379> auth xjm xjm123OK我们尝试info命令,提示该用户没有该权限192.168.238.190:6379> info keyspacesNOPERM this user has no permissions to run the 'info' command or its subcommand
192.168.238.190:6379> acl getuser xjm1) "flags"2) 1) "on"2) "allchannels"3) "passwords"4) 1) "74457be44c4802af06b99c27b6fd4097f89a9055f57b4f6d00422e40dfd19bb3"5) "commands"6) "-@all +set +get"7) "keys"8) 1) "a*"9) "channels"10) 1) "*"
192.168.238.190:6379> acl help1) ACL[[value] [opt] ...]. Subcommands are:2) CAT []3) List all commands that belong to, or all command categories4) when no category is specified.5) DELUSER[...]6) Delete a list of users.7) GETUSER8) Get the user's details.9) GENPASS []10) Generate a secure 256-bit user password. The optional `bits` argument can11) be used to specify a different size.12) LIST13) Show users details in config file format.14) LOAD15) Reload users from the ACL file.16) LOG [| RESET]17) Show the ACL log entries.18) SAVE19) Save the current config to the ACL file.20) SETUSER[...]21) Create or modify a user with the specified attributes.22) USERS23) List all the registered usernames.24) WHOAMI25) Return the current connection username.26) HELP27) Prints this help.
192.168.238.190:6379> CONFIG REWRITEOK
aclfile redis/redis-6.2.6/test/users.acl192.168.238.190:6379> acl save(error) ERR This Redis instance is not configured to use an ACL file. You may want to specify users via the ACL SETUSER command and then issue a CONFIG REWRITE (assuming you have a Redis configuration file set) in order to store users in the Redis configuration.
4508:M 22 Mar 2022 01:58:25.153 # Configuring Redis with users defined in redis.conf and at the same setting an ACL file path is invalid. This setup is very likely to lead to configuration errors and security holes, please define either an ACL file or declare users directly in your redis.conf, but not both.192.168.238.190:6379> acl saveOK
[root@node1 test]# more users.acluser default on #684a427ede5381357cfb99c6ef61a84376a0639830b26a511e458d3398fefa4e ~* &* +@alluser xjm on #74457be44c4802af06b99c27b6fd4097f89a9055f57b4f6d00422e40dfd19bb3 ~a* &* -@all +set +get
[root@node1 test]# more users.acluser default on #684a427ede5381357cfb99c6ef61a84376a0639830b26a511e458d3398fefa4e ~* &* +@alluser xjm on #74457be44c4802af06b99c27b6fd4097f89a9055f57b4f6d00422e40dfd19bb3 ~a* &* -@all +set +get192.168.238.190:6379> acl loadOK
美创是国内领先的数据库服务提供商。服务团队拥有PG ACED 1名、Oracle&PG ACE 3人、DSI智库专家5名、DSMM测评师7名、OCM 20余人、数十名Oracle OCP、MySQL OCP、TDSQL TCP、OceanBase OBCP、TiDB PTCP、达梦 DCP、人大金仓、红帽RHCA、中间件weblogic、tuxedo、CISP-DSG、CISSP、CDGA、CDPSE、CZTP、CDSP等认证人员,著有《DBA攻坚指南:左手Oracle,右手MySQL》,《Oracle数据库性能优化方法和最佳实践》,《Oracle内核技术揭秘》,《Oracle DBA实战攻略》等多本数据库书籍。运维各类数据库合计5000余套,精通Oracle、MySQL、SQLServer、DB2、PostgreSQL、MongoDB、Redis、TDSQL、OceanBase、达梦、人大金仓等主流商业和开源数据库。美创拥有完善的运维体系和人员培养体系,并同时提供超融合、私有云整体服务解决方案、数据安全咨询及运营服务方案等,已为金融、政府、企业、能源等多个行业的客户提供量身定制的各类服务,赢得了客户的高度赞誉和广泛认可。

文章转载自新运维新数据,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。





