zoukankan      html  css  js  c++  java
  • 老大说saltstack,本姑娘不敢不遵【1】----saltstack安装

    我们的服务器,前前后后,左左右右,上上下下,屈手指脚趾算数,恰恰刚好,再差径我的数学课程也是语文补充传授的,本姑娘始终未懂老板为什么偏偏喜欢用saltstack。

    道听途说,谁谁谁推荐忽悠上司,天没理,我就是想打个酱油。

    人生无奈,要怪就怪本姑娘当初选择IT,苦不堪言,谁来谁知道,谁滚谁清楚。

    逼上梁山,无可奈何花落去,天若有情天亦老,开始独自学习安装saltstack,本姑娘也是拼了的。

    什么是saltstack,三言两语:批量。批量管理服务器信息,批量新增用户,批量安装软件,批量更新配置文件。

    反正N多服务器时需要【批量】干嘛时,估计这贷能泒到场面中间溜达。

    我的虚拟机信息:

    [root@localhost ~]# cat /etc/centos-release 
    CentOS release 6.5 (Final)
    [root@localhost ~]# uname -r
    2.6.32-431.el6.x86_64

    狡黠地笑笑,本来想源码安装saltstack,哎,熟知一入豪门深似贱,从此无知似朋友。

    各种奇葩问题都从我指缝流窜,还川流不息,当初还自诩什么风浪本小姐没见过,当你真正领教之后,便知:爱过方知情重,试过方知悔浓。

    本姑娘果断拒绝源码安装,转向epel源安装saltstack。

    [root@localhost ~]# yum list epel*
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
     * base: mirrors.sina.cn
     * extras: mirrors.cn99.com
     * updates: mirrors.sina.cn
    updates                                                                 | 3.4 kB     00:00     
    updates/primary_db                                                      | 2.0 MB     00:01     
    Available Packages
    epel-release.noarch                                 6-8                                  extras
    [root@localhost ~]# yum install epel-release.noarch  -y
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
     * base: mirrors.sina.cn
     * extras: mirrors.cn99.com
     * updates: mirrors.sina.cn
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package epel-release.noarch 0:6-8 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ===============================================================================================
     Package                    Arch                 Version            Repository            Size
    ===============================================================================================
    Installing:
     epel-release               noarch               6-8                extras                14 k
    
    Transaction Summary
    ===============================================================================================
    Install       1 Package(s)
    
    Total download size: 14 k
    Installed size: 22 k
    Downloading Packages:
    epel-release-6-8.noarch.rpm                                             |  14 kB     00:00     
    warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    Importing GPG key 0xC105B9DE:
     Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
     Package: centos-release-6-5.el6.centos.11.1.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
     From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : epel-release-6-8.noarch                                                     1/1 
      Verifying  : epel-release-6-8.noarch                                                     1/1 
    
    Installed:
      epel-release.noarch 0:6-8                                                                    
    
    Complete!

    然后一切突然来的这么的猝不及防,没问题,安装成功,对于源码安装成功的自然牛逼哄哄,毕竟输掉心情,即使就算赢得掌声。

    如果你想尝试,我信,甭提:伤心总是多余的。我唱歌给你听~~~~

    服务端安装:

    [root@localhost ~]# yum list salt*
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
    epel/metalink                                                           | 6.0 kB     00:00     
     * base: mirrors.sina.cn
     * epel: ftp.cuhk.edu.hk
     * extras: mirrors.cn99.com
     * updates: mirrors.sina.cn
    epel                                                                    | 4.3 kB     00:00     
    epel/primary_db                                                         | 5.9 MB     00:01     
    Available Packages
    salt.noarch                                    2015.5.10-2.el6                             epel
    salt-api.noarch                                2015.5.10-2.el6                             epel
    salt-cloud.noarch                              2015.5.10-2.el6                             epel
    salt-master.noarch                             2015.5.10-2.el6                             epel
    salt-minion.noarch                             2015.5.10-2.el6                             epel
    salt-ssh.noarch                                2015.5.10-2.el6                             epel
    salt-syndic.noarch                             2015.5.10-2.el6                             epel
    [root@localhost ~]# yum install salt.noarch salt-master.noarch  -y

    客户端安装【也要先安装epel: yum install epel-release.noarch -y】

    [root@localhost ~]# yum install salt.noarch salt-minion.noarch  -y

    这干净利落,简值爱得不要不要的。

    我的虚拟机是克隆的,虽然气质不俗,亦不至伤风雅,改改名称,稍微装饰一下hostname更漂亮一点。

    服务端:
    [root@localhost ~]# hostname
    localhost.localdomain
    [root@localhost ~]#  cat /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=salt.master.localdomain
    
    客户端:
    [root@localhost ~]# cat /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=salt.minion.localdomain
    
    
    两端都得重启 network
    [root@localhost ~]# service network restart
    Shutting down interface eth0:  Device state: 3 (disconnected)
                                                               [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth0:  Active connection state: activating
    Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
    state: activated
    Connection activated
                                                               [  OK  ]

     先瞥一眼yum都安装啥东西,这里面的听说都是家常便饭,有空常喵喵。例如:重点配置文件:/etc/salt/master,什么乱五六遭都修改此配置,另外客户端也有一配置:/etc/salt/minion 就不罗列了。

    [root@localhost salt]# rpm -ql salt-master
    /etc/rc.d/init.d/salt-master
    /etc/salt/master
    /usr/bin/salt
    /usr/bin/salt-cp
    /usr/bin/salt-key
    /usr/bin/salt-master
    /usr/bin/salt-run
    /usr/bin/salt-unity
    /usr/share/man/man1/salt-cp.1.gz
    /usr/share/man/man1/salt-key.1.gz
    /usr/share/man/man1/salt-master.1.gz
    /usr/share/man/man1/salt-run.1.gz
    /usr/share/man/man1/salt-unity.1.gz
    /usr/share/man/man7/salt.7.gz
    
    

    此时只修改客户端的配置/etc/salt/minion,只改一项目,master配置为服务端的IP,这样差不多服务端与客户端就可以勾结一块,法律允许的话。

    # Set the location of the salt master server. If the master server cannot be
    # resolved, then the minion will fail to start.
    master: 192.168.37.131

    耐不住心情,掩不住的愉悦,服务端与客户端的服务启动

    [root@localhost salt]# service salt-master start
    Starting salt-master daemon:                               [  OK  ]
    [root@localhost salt]# 
    [root@localhost salt]# service salt-minion start
    Starting salt-minion daemon:                               [  OK  ]
    [root@localhost salt]# 

     心情淡定如浅水,眼睛幽蓝得深邃,结果扫描一遍后,差强人意,原来防火蔷惹的锅,本姑娘较真对这防火墙咬牙切齿,一问三不知,谁让我:防人之心我没有,唯有狠心说句:宝贝,白白!

    [root@localhost salt]# service iptables stop
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]

    来个简单测试,缓解一下压力:

    [root@localhost salt]# salt-key -L
    Accepted Keys:
    Denied Keys:
    Unaccepted Keys:
    salt.minion.localdomain
    Rejected Keys:
    [root@localhost salt]# salt-key -A -y
    The following keys are going to be accepted:
    Unaccepted Keys:
    salt.minion.localdomain
    Key for minion salt.minion.localdomain accepted.
    [root@localhost salt]#  salt-key -L
    Accepted Keys:
    salt.minion.localdomain
    Denied Keys:
    Unaccepted Keys:
    Rejected Keys:
    [root@localhost salt]# salt 'salt.minion.localdomain' test.ping
    salt.minion.localdomain:
        True
    [root@localhost salt]# salt 'salt.minion.localdomain' cmd.run 'ifconfig'
    salt.minion.localdomain:
        eth1      Link encap:Ethernet  HWaddr 00:0C:29:83:E7:8C  
                  inet addr:192.168.37.132  Bcast:192.168.37.255  Mask:255.255.255.0
                  inet6 addr: fe80::20c:29ff:fe83:e78c/64 Scope:Link
                  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                  RX packets:1695 errors:0 dropped:0 overruns:0 frame:0
                  TX packets:1588 errors:0 dropped:0 overruns:0 carrier:0
                  collisions:0 txqueuelen:1000 
                  RX bytes:224880 (219.6 KiB)  TX bytes:216262 (211.1 KiB)
        
        lo        Link encap:Local Loopback  
                  inet addr:127.0.0.1  Mask:255.0.0.0
                  inet6 addr: ::1/128 Scope:Host
                  UP LOOPBACK RUNNING  MTU:16436  Metric:1
                  RX packets:4 errors:0 dropped:0 overruns:0 frame:0
                  TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
                  collisions:0 txqueuelen:0 
                  RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)

    这简单测试我也懒得释解,本姑娘都懂的,你若是不懂的话,甚至还好意思疑问的话,估计,哈哈。

    经本小姐研究一翻,这saltstack好像似乎有哪么一丁点差不多人见人爱,车见车载的,可是我这吃喝拉撒睡的时间都快没了,呜呜。。。。

  • 相关阅读:
    SQL中distinct的用法
    JMeter压测“java.net.SocketException: Socket closed”解决方法
    Jmeter里http接口的执行顺序是顺序执行
    【Web安全】越权操作——横向越权与纵向越权
    【WPF】使用CefSharp嵌入HTML网页
    【Visual Studio】项目的引用显示黄色叹号
    未能加载文件或程序集”xxxx”或它的某一个依赖项,试图加载格式不正确的程序。
    IDEA无法启动debugger,报错Address localhost:1099 is already in use
    Windows系统32位、64位DLL文件的存放位置
    Charles做代理的Map Remote路径配置
  • 原文地址:https://www.cnblogs.com/1034009199ruby/p/5869116.html
Copyright © 2011-2022 走看看