Centos7 saltstack deployment and construction

Introduction and features of SaltStack

SaltStack is a centralized management platform for server infrastructure based on the C/S architecture. The management end is called Master and the client is called Minion. SaltStack has functions such as configuration management, remote execution, and monitoring. It can generally be understood as a simplified version of Puppet and an enhanced version of Func.

SaltStack itself is developed and implemented based on the Python language, combined with the lightweight message queue software ZeroMQ and Python third-party modules (Pyzmq, PyCrypto, Pyjinjia2, python-msgpack, PyYAML, etc.).

By deploying the SaltStack environment, operation and maintenance personnel can execute commands in batches on thousands of servers, configure centralized management, distribute files, collect system data, and install and manage software packages according to different business characteristics.

The working principle of
Insert picture description here
SaltStack SaltStack uses a C/S structure to manage the operation and configuration of servers in the cloud environment. In order to better understand its working method and management model, this chapter will illustrate its principle through graphics.

When the SaltStack client (Minion) is started, it will automatically generate a set of keys, including a private key and a public key. Then the public key is sent to the server, and the server verifies and accepts the public key to establish a reliable and encrypted communication connection. At the same time, a message publishing connection is established between the client and the server through the message queue ZeroMQ. Description of
command execution
Insert picture description here
principle diagram:

Minion is a client installation component that SaltStack needs to manage. It will take the initiative to connect to the Master, obtain resource status information from the Master, and synchronize resource management information.

The Master runs on the host server as a control center and is responsible for the operation of Salt commands and the management of resource status.

An instruction executed on the Master is issued to each Minions through the queue for execution, and the result is returned.

This chapter makes you understand what SaltStack is and its communication and execution principles. The next chapter will mainly introduce the architecture design of this instance deployment.

Comparison of saltstack and ansible

Insert picture description here

Environmental preparation:

Server: 192.168.74.134 master
Client: 192.168.74.148 slave
Close the firewall and selinux

Server:
modify the host name

[root@localhost ~]# hostname master

Permanently change the name

vim /etc/sysconfig/network
Created by anaconda
HOSTNAME=master

Edit the hosts file

[root@localhost ~]# vim /etc/hosts
192.168.74.134 master
192.168.74.148 slaver

Insert picture description here

Server-side installation

yum install -y epel-release
yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm
yum clean expire-cache yum install -y salt-master salt-minion

Client:
modify the host name:

[root@localhost ~]# hostname slave

Permanently change the name

vim /etc/sysconfig/network
Created by anaconda
HOSTNAME=slave

Edit the hosts file

[root@localhost ~]# vim /etc/hosts
192.168.74.134 master
192.168.74.148 slaver

Client installation:

yum install -y epel-release
yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm
yum clean expire-cache yum install -y salt-minion

Configuration
server and client configuration master

vim /etc/salt/minion //Add on line 16, there is a space after the colon master:
192.168.0.109

Start service

systemctl start salt-master
systemctl start salt-minion

Configuration verification

[root@localhost ~]# salt-key -a slaver [root@localhost ~]# salt-key -a master [root@localhost ~]# salt-key

Insert picture description here
Insert picture description here

Insert picture description here
So far~~ It has been successfully installed,
let’s test it (# . #)

[root@localhost ~]# salt ‘*’ test.ping
slave:
True
master:
True

Insert picture description here

[root@localhost ~]# salt ‘*’ cmd.run ‘df -h’

slave:
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 3.9G 14G 22% /
devtmpfs 896M 0 896M 0% /dev
tmpfs 911M 60K 911M 1% /dev/shm
tmpfs 911M 19M 893M 3% /run
tmpfs 911M 0 911M 0% /sys/fs/cgroup
/dev/sda1 297M 148M 150M 50% /boot
tmpfs 183M 4.0K 183M 1% /run/user/42
tmpfs 183M 36K 183M 1% /run/user/0
master:
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 4.6G 14G 26% /
devtmpfs 896M 0 896M 0% /dev
tmpfs 911M 260K 911M 1% /dev/shm
tmpfs 911M 19M 893M 3% /run
tmpfs 911M 0 911M 0% /sys/fs/cgroup
/dev/sda1 297M 148M 150M 50% /boot
tmpfs 183M 32K 183M 1% /run/user/0
/dev/sr0 8.8G 8.8G 0 100% /run/media/root/CentOS 7 x86_64

Insert picture description here
OK, I hope I can help you to meet in gratitude~~

Guess you like

Origin blog.csdn.net/weixin_46174507/article/details/109642031