免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 79503 | 回复: 137
打印 上一主题 下一主题

[系统管理] 轻松管理上万台Linux服务器,5分钟安装,一键完成!--出新版本啦,改名为TriAquae [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-12-29 18:07 |只看该作者 |倒序浏览
本帖最后由 alex3714 于 2012-12-03 11:33 编辑

如果你有以下需求,本文章或许会对你有所帮助:
1. 网络里LINUX服务器较多,缺乏统一管理的工具。
2. 系统经常需要更改,如果定期更改所有服务器密码、批量更新特定文件等。
3. 需实时获得所有服务器的运行信息,例如,需立刻查看每台服务上装分别装了多少根内存条该怎么办,难道一台台登录 上去看?当然一般的系统监控软件是不会收集服务器有多少条内存条这样的信息的。
4. 如果想往所有服务器上放一个文件,怎么办?
5. 想在所有服务器上启动一个服务或执行一个脚本怎么办?

_____________________________________________________________________________________

推出新版本啦,新版本实现以下功能:
先Show下功能:
IT批量运维管理软件-- TriAquae  
1.        服务器分组管理
2.        批量命令执行
3.        批量文件传送、接收
4.        服务器运行状态抓取、分析
5.        服务器硬件信息收集
6.        定时计划任务
7.        批量软件部署
8.        系统密码更改

我推荐大家使用 TriAquae的理由:
1、        它如此方便,你可以像管理本地一台服务器一样可以轻松的让成千上万台服务器做同样的事情,比如 uname –a查一下系统版本,执行一个收集日志的脚本,修改所有服务器上的一个文件……,当然它能做的不至这些……
2、        它如此之轻,只要你的机器上装有Python,那么你就可以开始使用它,它不需要你装数据库,不需PHP、不需要JAVA虚拟机,only  Python。你甚至不需要在客户机上装客户端,只需要支持SSH,当然你得知道用户名密码
3、        它如此简单,你无需学习特殊的语法、花数天的时间研究软件的结构,只需5分钟,你就可以开始自如的使用它管理你的系统了
4、        它是开源的,它是免费的……

#####比以前的版本,多了好多功能呢,还不需要在被管理机上装客户端了呢,飞跃了亲……哈哈


详情请查看: http://bbs.chinaunix.net/forum.p ... =3775522&extra=




大家在读下文时如有不理解的地方或其它问题,可以随时联系我,大家互相交流,共同成长,我的qq:317828332
############################################

做Linux系统管理以来,由于维护过比较大的网络,例如在飞信做支持的时候,面对上千台的服务器,有时候可能要对每台机子打一个补丁,或者是修改一个文件,如果只有10台服务器,那一一修改也就罢了,但是如果让你一台一台的登录1000台服务器只是为了去改一个文件,那一定痛苦死,并且效率低下,没有任何技术含量,如果一直做这种工作,那被称为IT民工也不能怪别人了,因为我一直想找一个可以批量管理的工具,后来发现了两种方式可以实现:

1.    通过SSH密钥认证,这样登录到远程机器上后就不需要输入密码了,这样就可以通过脚本去批量登录到远程服务器并且修改你想要文件或操作等,但是这有一个缺点,就是这个在管理端的私钥你一定要保存好,万一管理服务器系统重装或其它原因导致私钥丢失,那你就没办法登录远程机器了。还有,如果需要管理的机器更改了IP,那你还得重新把公钥COPY到那台机子上,这样管理起来可能不是那么灵活。

2.    通过expect 工具进行批量管理,expect工具很强大,可以实现交互式管理,比如如果你想改密码,输入passwd命令后,系统会提示你输入New Password: ,如果使用普通脚本的话,那你是没办法进行交互式的。但是expect就可以做到检测系统的返回值并且根据返回的提示来自动交互


这样此脚本就会调用ha-switch.exp脚本并登录到192.168.193.100-200的机器上分别执行"/etc/init.d/heartbeat stop 命令了。

很强大吧,但使通过我使用的经验,我觉得expect 有个缺点就是有慢,因为它是一台一台的去登录 然后执行命令,因为有的时候由于DNS解析或什么原因 ,通过SSH登录到一台机子时可能需要等待30s才能登录进去,假如1000台机子的话那就需要50分钟才能完成在所有机器上的操作,对于要求在1分钟内实现数千台机器执行相同操作的需要来讲这显然达不到要求。



以上两种方法各有利弊,我个人建议在50-100台的小网络中可以考虑使用SSH认证或expect的方法。但是想像一下,如果我有一万台机器 ,分别处于全国各地不同的网络中,要求我在1分钟内更改所有机器的root密码,显然以上两种方法均是做不到的,当然有这样大型网络的公司中国也并不多见,但是从技术的角度上来讲这还是有一定挑战性的,由于在网上一直找不到这样的工具,我就自己索性写了一个,经过多天的努力,终于将这个批量管理工具写完了,此工具是用的Python写的,基于socket server的模式,即需要在所有的需要管理的服务器上启动一个客户端(可能好多朋友不太喜欢这种还需要装客户端的东东),客户端会开启一个端口,你的管理服务器就是通过此端口与被管理端通信,然后对被管理端进行操作,你可以远程修改密码,查看系统信息,内存情况等操作,操作结果会在你的管理端实现显示出来(这也是我比较喜欢的地方,就跟在本地操作命令一样)。并且还可以向远程服务器批量COPY文件,下面我就把这个工具在使用过程中的一些截图列出来:



bjnppb01:~/scripts/python_scripts/Remote_management_tool/Remote_management_tool_v1.3 # python RMT_server.py

##################################################################################
#       RMT(Remote Management tool)                                              #
#                                                                                #
#       Version 1.3,2011-01-21                                                   #
#       Author:Alex Li                                                           #
#       Email:lijie3721@126.com,QQ:317828332                                     #
##################################################################################

please slect the following menu:
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:0  #列出所有服务器列表
192.168.193.133
192.168.193.134
192.168.193.135
192.168.193.136
192.168.193.137
192.168.193.138
192.168.193.140
192.168.193.141
192.168.193.142

please slect the following menu: #
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:1 #扫描所有服务器列表上的客户端的状态
192.168.193.133  down
192.168.193.134  down
192.168.193.135  running
192.168.193.136  down
192.168.193.137  running
192.168.193.138  running
192.168.193.140  down
192.168.193.141  down
192.168.193.142  down
please slect the following menu:   
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:2   #登录到某台机器
Please enter the remote server IP: 192.168.193.135 #输入IP地址
You have successfully login to the remote server, now you can run most of the system command in this mode ,but do not suggest
you to run the command such as top,tail -f,because right now I haven't find a way to support the continuous data output

Please input the command:uname -a #输入的命令
Received log from /root/Remote_management_tool/192.168.193.135.log
##########################################################
Linux bjnpif02 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux   #显示的结果
####################################################################################
Please input the command:ls  #输入的命令
Received log from /root/Remote_management_tool/192.168.193.135.log
########################################################## #显示的结果

1900000
Desktop
Documents
RMT_client.py
Remote_management_tool
autoinst.xml
bin
nohup.out
ntp-client
script
vmware

####################################################################################
Please input the command:exit
please slect the following menu:
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:3
please slect the following menu:
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:4 #上传服务器列表
Please enter the full path of your file: ls
No such file,please make sure you inputed the right file.
Please enter the full path of your file: /tmp.^H
No such file,please make sure you inputed the right file.
Please enter the full path of your file: /tmp/list   
192.168.193.3
192.32.34.24
Adding uploaded list to Server list.########################## done.
please slect the following menu:
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:5  #同时在多台远程服务器上执行命令并返回结果
It might will takes a few minutes to scan all the avialiable servers......
The fllowing servers are avaliable:  #可以进行远程操作的列表
192.168.193.135   
192.168.193.137
192.168.193.138
please input your command: uname -a #输入命令
Received log from /root/Remote_management_tool/192.168.193.135.log

Linux bjnpif02 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux  #每台设备返回的结果
####################################################################################
Received log from /root/Remote_management_tool/192.168.193.137.log

Linux bjnpbo01 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux #每台设备返回的结果
####################################################################################
Received log from /root/Remote_management_tool/192.168.193.138.log

Linux bjnpbo02 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux
####################################################################################

please input your command: i^H
Received log from /root/Remote_management_tool/192.168.193.135.log

sh: : command not found
####################################################################################
Received log from /root/Remote_management_tool/192.168.193.137.log

sh: : command not found
####################################################################################
Received log from /root/Remote_management_tool/192.168.193.138.log

sh: : command not found
####################################################################################
please input your command: ls  #输入的命令
Received log from /root/Remote_management_tool/192.168.193.135.log  #每台设备返回的结果
  
1900000
Desktop
Documents
RMT_client.py
Remote_management_tool
autoinst.xml
bin
nohup.out
ntp-client
script
vmware
####################################################################################
Received log from /root/Remote_management_tool/192.168.193.137.log   #每台设备返回的结果

1900000
Desktop
Documents
RMT_client.py
Remote_management_tool
a
autoinst.xml
bin
etc
jdk-6u17-linux-amd64.rpm
jdk1.6.0_17
netperf-2.4.5
netperf-2.4.5.tar.gz
nohup.out
ntp-client
opt
sbin
sun-javadb-client-10.4.2-1.1.i386.rpm
sun-javadb-common-10.4.2-1.1.i386.rpm
sun-javadb-core-10.4.2-1.1.i386.rpm
sun-javadb-demo-10.4.2-1.1.i386.rpm
sun-javadb-docs-10.4.2-1.1.i386.rpm
sun-javadb-javadoc-10.4.2-1.1.i386.rpm
usr
workspace
####################################################################################
Received log from /root/Remote_management_tool/192.168.193.138.log  #每台设备返回的结果

1900000
Desktop
Documents
RMT_client.py
Remote_management_tool
autoinst.xml
bin
nohup.out
ntp-client
####################################################################################
please input your command: exit
please slect the following menu:
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:6  #批量更改多台服务器密码

                        Please use the follow method to change password on remote server:
                                 use command: echo "your password"|passwd your_user --stdin
                                 For example ,if you want to change oracle user's password to '123456', then you need run
                                 
                                        echo "123456"|passwd oracle --stdin
                                 
please slect the following menu:  
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:7  #批量往多台服务器上拷文件
Please enter the file name which you wanted to copy to remote servers:/tmp/list  #文件名
192.168.193.133

Connection refused by the remote server 192.168.193.133   #连接失败
,please make sure you IP is allowed by the remote server.
192.168.193.134

Connection refused by the remote server 192.168.193.134
,please make sure you IP is allowed by the remote server.
192.168.193.135     #COPY成功

192.168.193.136

Connection refused by the remote server 192.168.193.136
,please make sure you IP is allowed by the remote server.
192.168.193.137   #COPY成功


192.168.193.138  #COPY成功

192.168.193.140

Connection refused by the remote server 192.168.193.140
,please make sure you IP is allowed by the remote server.
192.168.193.141

Connection refused by the remote server 192.168.193.141
,please make sure you IP is allowed by the remote server.
192.168.193.142

Connection refused by the remote server 192.168.193.142
,please make sure you IP is allowed by the remote server.
192.168.193.3

Connection refused by the remote server 192.168.193.3
,please make sure you IP is allowed by the remote server.
192.32.34.24

Connection refused by the remote server 192.32.34.24
,please make sure you IP is allowed by the remote server.  
File list has successfully copied into /root/Remote_management_tool/recieved_files directory of above remote servers.

please slect the following menu:
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:8  #批量部署客户端到多台服务器上
This function is for you to install client application on mutiple servers , to achieve this, please follow the following step:

        1 Fill your IP address and password of remote server in to password.txt under expect_tool directory
        2 Make you have the access right to /root directory on remote server,the client file RMT_client.py will be copied into /root/ directory on all the   remote servers which you assigned in password.txt


Do you want install the client on mutiple servers? (yes/no) :y
Starting to install RMT_client.py on remote servers...
Checking for the remote server list...
Going to install on the following servers:
192.168.193.137
192.168.193.135
spawn scp -rp ../RMT_client.py 192.168.193.137:/root/
Password:
RMT_client.py                                                                                                              100% 1983     1.9KB/s   00:00   
spawn ssh root@192.168.193.137
Password:
Last login: Fri Jan 21 16:06:20 2011 from 192.168.193.132
bjnpbo01:~ # nohup python /root/RMT_client.py  &
[1] 17704
bjnpbo01:~ # exit
logout
nohup: appending output to `nohup.out'
Connection to 192.168.193.137 closed.
spawn scp -rp ../RMT_client.py 192.168.193.135:/root/
Password:
RMT_client.py                                                                                                              100% 1983     1.9KB/s   00:00   
spawn ssh root@192.168.193.135
Password:
nohup python /root/RMT_client.py  &
exit
Last login: Fri Jan 21 15:49:57 2011 from 192.168.193.132
bjnpif02:~ # nohup python /root/RMT_client.py  &
[1] 17759
bjnpif02:~ # exit
logout
nohup: appending output to `nohup.out'
Connection to 192.168.193.135 closed.
please slect the following menu:
                0 list servers
                1 Scan agent status
                2 login to remote server
                3 Reboot all the remote servers(does't support)
                4 Upload server list
                5 excute command on all the aviliable servers
                6 change password for all the servers
                7 copy scripts to remote servers
                8 install the client application on all the remote servers
                9 exit
Please enter the slected number:9

这样就可以轻松的管理所有的机器了,考虑到第一次运行时需要在所有的机器上安装客户端,建议使用expect工具来一次批量安装,这样就可以一劳永逸了,有需要的同鞋请下载附件。

Remote_management_tool_v1.4.tar

40 KB, 下载次数: 1549

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
2 [报告]
发表于 2010-12-29 21:15 |只看该作者
这是自己写的脚本把。

论坛徽章:
0
3 [报告]
发表于 2010-12-30 09:14 |只看该作者
回复 2# renxiao2003


    自已通过python写的小程序

论坛徽章:
0
4 [报告]
发表于 2010-12-30 09:30 |只看该作者
楼主强悍啊,做过飞信,难道是新媒传信的老相识?喜欢你的创新精神

论坛徽章:
0
5 [报告]
发表于 2010-12-30 09:31 |只看该作者
哈哈,我在新媒呆过,哈,你哪个部门?

论坛徽章:
0
6 [报告]
发表于 2010-12-30 09:36 |只看该作者
运维,不过是负责官网的。

招聘 : 技术支持/维
论坛徽章:
0
7 [报告]
发表于 2010-12-30 09:37 |只看该作者
主要是脚本啦

论坛徽章:
0
8 [报告]
发表于 2010-12-30 09:46 |只看该作者
我也是运维的,我跟官网的还打过交道,哈哈,你什么时候离开的?

论坛徽章:
0
9 [报告]
发表于 2010-12-30 09:48 |只看该作者
回复 7# nagaregawa


    嗯,通过python 的socket模块做的,希望能对各位有帮助,可实现对上万台服务器的集中,实时管理。

招聘 : 技术支持/维
论坛徽章:
0
10 [报告]
发表于 2010-12-30 09:50 |只看该作者
回复 9# alex3714


    谢谢分享啦~
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP