In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the cluster management tool ansible commonly used commands which, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Common commands of cluster management tool ansible
The procedure for using ansible is as follows:
Master: install ansible
# install the epel-release RPM if needed on CentOS, RHEL, or Scientific Linux
[root@tidb01 ~] # yum install epel-release [root@tidb01 ~] # yum-y install ansible [root@tidb01 ~] # ansible-- versionansible 2.9.10 config file = / etc/ansible/ansible.cfg configured module search path = [uplink _ peg _ r _ r 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Configure hosts to add managed hosts
[root@tidb01 ~] # cat / etc/ansible/hosts
[servers] 192.168.30.101192.168.30.102#192.168.30.103#192.168.30.104192.168.30.105#192.168.30.106
Generate key
[root@tidb01 ~] # ssh-keygen
Use the ssh-copy-id command to copy the ansible public key to each node
[root@tidb01 ~] # ssh-copy-id root@192.168.30.101 [root@tidb01 ~] # ssh-copy-id root@192.168.30.102 [root@tidb01 ~] # ssh-copy-id root@192.168.30.105
Execute the ping command
[root@tidb01 ~] # ansible servers-m ping# or: [root@tidb01 ~] # ansible servers-I / etc/ansible/hosts-m ping# or: [root@tidb01 ~] # ansible-m ping servers# or: [root@tidb01 ~] # ansible-m ping all192.168.30.102 | SUCCESS = > {"ansible_facts": {"discovered_interpreter_python": "/ usr/bin/python"}, "changed": false "ping": "pong"} 192.168.30.105 | SUCCESS = > {"ansible_facts": {"discovered_interpreter_python": "/ usr/bin/python"}, "changed": false, "ping": "pong"} 192.168.30.101 | SUCCESS = > {"ansible_facts": {"discovered_interpreter_python": "/ usr/bin/python"} "changed": false, "ping": "pong"}
Specify the user and execute the ping command
[root@tidb01 ~] # ssh-copy-id chen@192.168.30.101 [root@tidb01 ~] # ssh-copy-id chen@192.168.30.102 [root@tidb01 ~] # ssh-copy-id chen@192.168.30.105 [root@tidb01 ~] # ansible all-m ping-u chen192.168.30.105 | SUCCESS = > {"ansible_facts": {"discovered_interpreter_python": "/ usr/bin/python"}, "changed": false "ping": "pong"} 192.168.30.102 | SUCCESS = > {"ansible_facts": {"discovered_interpreter_python": "/ usr/bin/python"}, "changed": false, "ping": "pong"} 192.168.30.101 | SUCCESS = > {"ansible_facts": {"discovered_interpreter_python": "/ usr/bin/python"} "changed": false, "ping": "pong"}
Execute the command echo hello
[root@tidb01 ~] # ansible-a "echo hello" servers192.168.30.105 | CHANGED | rc=0 > > hello192.168.30.101 | CHANGED | rc=0 > > hello192.168.30.102 | CHANGED | rc=0 > > hello
Execute the command date-R
[root@tidb01 ~] # ansible-m command-a "date-R" servers192.168.30.102 | CHANGED | rc=0 > > Sun, 28 Jun 2020 09:15:55 + 0800192.168.30.105 | CHANGED | rc=0 > > Sun, 28 Jun 2020 09:15:54 + 0800192.168.30.101 | CHANGED | rc=0 > > Sun, 28 Jun 2020 09:15:56 + 0800
Execute the command uptime
[root@tidb01 ~] # ansible-m command-a "uptime" servers192.168.30.102 | CHANGED | rc=0 > > 09:17:21 up 23 min, 2 users, load average: 0.00,0.01,0.05192.168.30.105 | CHANGED | rc=0 > > 09:17:21 up 22 min, 2 users, load average: 0.24,0.06,0.07192.168.30.101 | CHANGED | rc=0 > > 09:17:22 up 11 min, 2 users, load average: 0.08,0.09 0.07
Execute the command touch / root/cjc.log
[root@tidb01] # ansible-m command-a "touch / root/cjc.log" servers [WARNING]: Consider using the file module with state=touch rather than running 'touch'. Ifyou need to use command because file is insufficient you can add 'warn: false' to this commandtask or set' command_warnings=False' in ansible.cfg to get rid of this message.192.168.30.102 | CHANGED | rc=0 > > 192.168.30.105 | CHANGED | rc=0 > > 192.168.30.101 | CHANGED | rc=0 > >
Execute the command ls / root/cjc.log
[root@tidb01 ~] # ansible-m command-a "ls / root/cjc.log" servers192.168.30.105 | CHANGED | rc=0 > > / root/cjc.log192.168.30.102 | CHANGED | rc=0 > > / root/cjc.log192.168.30.101 | CHANGED | rc=0 > > / root/cjc.log
Execute the command getenforce
[root@tidb01 ~] # ansible-m command-a "getenforce" servers192.168.30.102 | CHANGED | rc=0 > > Disabled192.168.30.105 | CHANGED | rc=0 > > Disabled192.168.30.101 | CHANGED | rc=0 > > Disabled
Or:
[root@tidb01 ~] # ansible-a "getenforce" servers192.168.30.105 | CHANGED | rc=0 > > Disabled192.168.30.102 | CHANGED | rc=0 > > Disabled192.168.30.101 | CHANGED | rc=0 > > Disabled
Specify one of the hosts to execute the command
[root@tidb01 ~] # ansible-a "getenforce" 192.168.30.101192.168.30.101 | CHANGED | rc=0 > > Disabled
Execute the command df-h
[root@tidb01] # ansible-a "df-h /" servers192.168.30.102 | CHANGED | rc=0 > > Filesystem Size Used Avail Use% Mounted on/dev/mapper/vg_cjc-lv_root 18G 7.1G 11G 40% / 192.168.30.105 | CHANGED | rc=0 > > Filesystem Size Used Avail Use% Mounted on/dev/mapper/vg_cjc-lv_root 18G 7.0G 11G 40% / 192.168. 30.101 | CHANGED | rc=0 > > Filesystem Size Used Avail Use% Mounted on/dev/mapper/vg_srv-lv_root 25g 8.1g 17g 33% /
Execute the command free-m
[root@tidb01 ~] # ansible-a "free-m" servers192.168.30.105 | CHANGED | rc=0 > > total used free shared buff/cache availableMem: 974 411 116 8 446 350Swap: 2043 02043192.168.30.102 | CHANGED | rc=0 > > total Used free shared buff/cache availableMem: 974 414 156 8 403 350Swap: 2043 0 2043 192.168.30.101 | CHANGED | rc=0 > > total used free shared buff/cache availableMem: 974 413 98 8 462 367Swap: 3071 0 3071
Execute the command to view the sshd process
[root@tidb01 ~] # ansible-m shell-a'ps-ef | grep sshd | grep-v grep' servers192.168.30.105 | CHANGED | rc=0 > > root 1374 10 08:54? 00:00:00 / usr/sbin/sshd-Droot 2090 1374 0 08:56? 00:00:00 sshd: root@pts/0root 8581 1374 0 10:38? 00:00:00 sshd: root@pts/1192.168. 30.102 | CHANGED | rc=0 > > root 1370 08:54? 00:00:00 / usr/sbin/sshd-Droot 2089 1370 0 08:56? 00:00:00 sshd: root@pts/0root 9041 1370 0 10:38? 00:00:00 sshd: root@pts/2root 10181 1370 0 10:41? 00:00:00 sshd: root@pts/1192.168. | 30.101 | CHANGED | rc=0 > > root 1009: 06? 00:00:00 / usr/sbin/sshd-Droot 1242 1009 1009: 06? 00:00:00 sshd: root@pts/1root 8590 1009 0 10:38? 00:00:00 sshd: root@pts/2 on the cluster management tool ansible commonly used commands to share here I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.