什么是dcli?
这个是Exadata上特有的工具,从下面的说明也能够看出来(distributed shell for Oracle storage)。这个工具也可在有Python的其他环境使用,使用很方便。下面的测试在在Linux 64bit上连接mysq数据库做的一个小测试。
dcli.py
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
NAME
dcli.py - distributed shell for Oracle storage
DESCRIPTION
distributed shell for Oracle storage
NOTES
requires Python version 2.3 or greater
查看dcli版本
[root@od ~]# python -V Python 2.6.6 [root@od ~]# [root@od ~]# dcli --version version 1.4 [root@od ~]#dcli帮助
[root@od ~]# dcli Error: No command specified. Usage: dcli [options] [command] Options: --version show program's version number and exit --batchsize=MAXTHDS limit the number of target cells on which to run the command or file copy in parallel -c CELLS comma-separated list of cells -d DESTFILE destination directory or file -f FILE files to be copied -g GROUPFILE file containing list of cells -h, --help show help message and exit --hidestderr hide stderr for remotely executed commands in ssh -k push ssh key to cell's authorized_keys file -l USERID user to login as on remote cells (default: celladmin) --maxlines=MAXLINES limit output lines from a cell when in parallel execution over multiple cells (default: 100000) -n abbreviate non-error output -r REGEXP abbreviate output lines matching a regular expression -s SSHOPTIONS string of options passed through to ssh --scp=SCPOPTIONS string of options passed through to scp if different from sshoptions --serial serialize execution over the cells --showbanner show banner of the remote node in ssh -t list target cells --unkey drop keys from target cells' authorized_keys file -v print extra messages to stdout --vmstat=VMSTATOPS vmstat command options -x EXECFILE file to be copied and executed [root@od ~]#首先要生成ssh key
[root@od ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: d3:fa:26:54:60:0b:b6:32:e6:55:5d:9e:3f:c5:5c:54 root@od.ohsdba.cn The key's randomart image is: +--[ RSA 2048]----+ | . .. .E| | o + .. . o.| | . = o o +| | + o ... . . | | o + S.. o | | . .o . | | .. | | ... | | o. | +-----------------+建立信任关系,默认是celladmin用户
[root@od ~]# dcli -l root -g dbgroup -k The authenticity of host 'mysql (10.0.2.133)' can't be established. RSA key fingerprint is 4f:68:99:eb:54:4b:61:fb:aa:f3:d9:fa:cd:09:f2:f4. Are you sure you want to continue connecting (yes/no)? yes root@mysql's password: mysql: ssh key added [root@od ~]#
测试:执行一个mysql语句
[root@od ~]# dcli -l root -g dbgroup "id;mysql -uroot -e \"select version()\""
mysql: uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
mysql: version()
mysql: 5.7.16
[root@od ~]#