In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Ansible Automated Operation and maintenance (2)
(2) configure and use ansible
# copy configuration file
Mkdir / etc/ansible/
Cp examples/ansible.cfg / etc/ansible/
Cp examples/hosts / etc/ansible/
# modify / etc/ansible/hosts, you can use IP or domain name instead
[hadoop]
Master
Node1
Node2
Node3
[other]
All
# modify / etc/ansible/ansible.cfg
Private_key_file = / root/.ssh/id_rsa
# start testing and common commands
Ansible hadoop-m command-a 'uptime'
Ansible hadoop-m ping
# as shown
# Common modules
Ansible hadoop-m setup
# file sets file properties
Ansible hadoop-m file opt
# options are as follows (option description is selected from the network)
Force: you need to force the creation of a soft link in two cases, one is that the source file does not exist but will be established later; the other is that the destination soft link already exists and you need to cancel the previous soft link and then create a new one. There are two options: yes | no
Group: define the subordinate group of the file / directory
Mode: define permissions for files / directories
Owner: define the owner of the file / directory
Path: required, define the path to the file / directory
Recurse: recursively sets the properties of a file, valid only for directories
Src: the path to the linked source file, applicable only in the case of state=link
Dest: the path to be linked to, only in the case of state=link
State:
Directory: if the directory does not exist, create the directory
File: even if the file does not exist, it will not be created
Link: creating soft links
Hard: creating hard links
Touch: if the file does not exist, a new file is created, and if the file or directory already exists, its last modification time is updated.
Absent: delete directories, files, or unlink files
# create and delete symbolic links to remote files
Ansible hadoop-m file-a "src=/home/all.sh dest=/tmp/all.sh state=link"
Ansible hadoop-m file-a "path=/tmp/all.sh state=absent"
# copy copies files to a remote host (option description is selected from the network)
Backup: before overwriting, back up the source file, which contains time information. There are two options: yes | no
Content: used instead of "src", you can directly set the value of the specified file
Dest: required. The absolute path of the remote host to which the source file is to be copied, and if the source file is a directory, the path must also be a directory
Directory_mode: recursively sets the permissions of the directory, which defaults to the system default permissions
Force: if the target host contains the file, but the content is different, it is forced to be overwritten if it is set to yes, and if it is no, it is replicated only if the file does not exist at the target host's destination location. Default is yes
Others: the options in all file modules can be used here
Src: a local file copied to a remote host, either absolute or relative. If the path is a directory, it will be copied recursively. In this case, if the path ends with "/", only the contents of the directory are copied, and if it does not end with "/", the entire content, including the directory, is copied, similar to rsync.
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.