saltstack介紹

slatstack是一個基礎管理平臺 是一個配置管理系統,可以預約義狀態的遠程結點 是一個分佈式遠程執行系統,用來在遠程結點上執行命令和查詢數據python

slatstack核心功能:使用命令發送到遠程系統是並行而不是串行編程

                             使用安全加密協議vim

                             使用最小最快的網絡載荷centos

                             提供簡單的編程接口安全

slatstack優勢:服務器

                    使用python開發,輕量級網絡

                    底層採用zeromq,實現是的它很快速tcp

                    開源,經過python寫本身的模塊分佈式

slatstack端口說明:測試

                            salt-maste:4505爲salt消息發佈專用端口

                                              4506爲客戶端與服務端通訊端口

1.安裝saltstack

1.1安裝yum源

            使用的是阿里epel6的yum源 http://mirrors.aliyun.com/epel/6Server/x86_64/

            解決一些依賴關係使用阿里的centos6的yum源 http://mirrors.aliyun.com/centos/6/os/x86_64/

[root@slat-master ~]# yum install salt-master -y

[root@slat-minion~]# yum install salt-minion -y

安裝完畢會有一套關於salt的命令

[root@salt-master ~]# salt

salt salt-call salt-cp salt-key salt-master salt-minion salt-run salt-unity

salt主要指令

salt-key管理密鑰

修改minion端配置文件

             master:ip/fqdn name

             id:默認主機名

[root@salt-master ~]# vim /etc/salt/minion

                master: salt-master

                啓動master

                             [root@salt-master ~]# /etc/init.d/salt-master start

                            Starting salt-master daemon: [ OK ]

              啓動minion

                                [root@salt-master ~]# /etc/init.d/salt-minion start

                            Starting salt-minion daemon: [ OK ]

能夠修改服務端配置文件的日誌等級或者路徑來觀察啓動狀況

查看端口

[root@salt-master ~]# netstat -lnt

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:4505 0.0.0.0:* LISTEN

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:4506 0.0.0.0:* LISTEN

tcp 0 0 :::22 :::* LISTEN tcp 0 0 ::1:25 :::* LISTEN

第一個指令 salt-key

經常使用參數

Actions: -l ARG, --list=ARG List the public keys. The args "pre", "un", and "unaccepted" will list unaccepted/unsigned keys. "acc" or "accepted" will list accepted/signed keys. "rej" or "rejected" will list rejected keys. "den" or "denied" will list denied keys. Finally, "all" will list all keys.

-L, --list-all List all public keys. (Deprecated: use "--list all")

-a ACCEPT, --accept=ACCEPT Accept the specified public key (use --include-all to match rejected keys in addition to pending keys). Globs are supported.

-A, --accept-all Accept all pending keys

-r REJECT, --reject=REJECT Reject the specified public key (use --include-all to match accepted keys in addition to pending keys). Globs are supported.

-R, --reject-all Reject all pending keys

-d DELETE, --delete=DELETE Delete the specified key. Globs are supported.

-D, --delete-all Delete all keys [root@salt-master ~]# salt-key -L Accepted Keys: Denied Keys: Unaccepted Keys: salt-minion Rejected Keys:

添加密鑰

[root@salt-master ~]# salt-key -a salt-minion

The following keys are going to be accepted:

Unaccepted Keys: salt-minion Proceed? [n/Y] y

Key for minion

salt-minion accepted.

2測試指令

[root@salt-master ~]# salt '*' test.ping

salt-minion: True

*實際上是匹配全部id 實際上是minion去ping master

[root@salt-master ~]# salt '*' cmd.run 'uptime'

salt-minion: 00:55:23 up 27 min, 2 users, load average: 0.04, 0.03, 0.05

若是換了master主機應該怎麼操做

1.新服務器安裝salt-master

2.打包原master的pki目錄,並拷貝到新的master上的配置目錄下進行解壓

3.修改minion端的master主機名映射便可完成遷移

例如 master 192.168.1.1 100

.salt '*' cmd.run "sed -i s/100/200/ /etc/hosts"

2.salt '*' service.restart salt-minion

這樣就完成全部minion端對於master的ip地址改變,而後重啓minion端就能夠鏈接到新的master端上

注意:

修改主機名的話

minion端

1./etc/salt/minion_id刪除或者清空

2./etc/salt/pki 刪除或者清空

3.master上salt-key -d old-host 清除這個主機

重啓minion

相關文章
相關標籤/搜索