使用ansible編譯安裝營運工具tmux

來源:互聯網
上載者:User

使用ansible編譯安裝營運工具tmux
實驗系統:CentOS 6.6_x86_64 實驗前提:提前準備好編譯環境,防火牆和selinux都關閉 軟體介紹:tmux是一個優秀的終端複用軟體,類似GNU Screen,但來自於OpenBSD,採用BSD授權。使用它最直觀的好處就是,通過一個終端登入遠程主機並運行tmux後,在其中可以開啟多個控制台而無需再“浪費”多餘的終端來串連這台遠程主機;當然其功能遠不止於此。 軟體下載:http://pan.baidu.com/s/1c0i9kf2 一、常規安裝 1.安裝tmux所需要的依賴: wget https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gztar xf libevent-2.0.22-stable.tar.gzcd libevent-2.0.22-stable./configuremake && make installln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5 2.安裝tmux軟體包: wget http://iweb.dl.sourceforge.net/project/tmux/tmux/tmux-2.0/tmux-2.0.tar.gztar xf tmux-2.0.tar.gzcd tmux-2.0./configure --prefix=/usr/local/tmuxmake && make install3.匯出二進位檔案: vim /etc/profile.d/tmux.sh---------------------------------------->PATH=$PATH:/usr/local/tmux/binexport PATH<----------------------------------------. /etc/profile.d/tmux.sh4.匯出man手冊: vim /etc/man.config--------------------------------------------->MANPATH /usr/local/tmux/share/man        //增加一行 5.編輯設定檔: 

vim ~/.tmux.conf------------------------------------------>set -g prefix C-a                                     //設定首碼命令為crtl+aunbind C-b                                            //解除ctrl+b的綁定setw -g mode-keys vi                                  //copy-mode將快速鍵設定為vi模式set -g default-terminal "screen-256color"             //設定終端顏色為256色set -g status-utf8 on                                 //開啟狀態列的uft-8支援set-window-option -g mode-mouse on                    //開啟滾屏

 

 6.常用快速鍵:

至此,tmux安裝完畢了,下面咱們做個拓展實驗,使用ansible安裝tmux! 二、拓展實驗 1.安裝ansible並建立yaml檔案: 
yum -y install ansiblemkdir -pv /root/ansible.roles/roles     //建立工作目錄cd /root/ansible.rolesvim tmux.yaml-------------------------------------------->- name: install tmux  remote_user: root                    //運行使用者  hosts: tmux                          //運行這個劇本的主機,後面有定義  roles:  - tmux                               //規則名稱,要與後面建立的檔案夾名稱相同

 

2.放入檔案: 
cd /root/ansible.roles/rolesmkdir -pv tmux/{files,handlers,tasks}                                         //建立與規則同名的檔案夾cp /root/tmux-2.0.tar.gz /root/libevent-2.0.22-stable.tar.gz tmux/files/      //將安裝包放入cp /root/.tmux.conf tmux/files/                                               //將設定檔放入

 

3.編寫主yaml檔案:  
vim /root/ansible.roles/roles/tmux/tasks/main.yaml------------------------------------------------------>- name: copy libevent package  copy: src=libevent-2.0.22-stable.tar.gz dest=/root- name: copy tmux package  copy: src=tmux-2.0.tar.gz dest=/root- name: copy conf  copy: src=.tmux.conf dest=/root- name: run script  script: tmux.sh

 

 4.編寫tmux.sh指令碼: 
vim /root/ansible.roles/roles/tmux/files/tmux.sh---------------------------------------------------------------->#!/bin/bash## Install libeventcd && cdtar xf libevent-2.0.22-stable.tar.gzcd libevent-2.0.22-stable./configuremake && make installln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5# Install tmuxcd && cdtar xf tmux-2.0.tar.gzcd tmux-2.0./configure --prefix=/usr/local/tmuxmake && make install# Extra Operationtouch /etc/profile.d/tmux.sh echo 'PATH=$PATH:/usr/local/tmux/bin' > /etc/profile.d/tmux.shecho 'export PATH' >> /etc/profile.d/tmux.shecho 'MANPATH /usr/local/tmux/share/man' >> /etc/man.config. /etc/profile.d/tmux.sh<----------------------------------------------------------------chmod +x /root/ansible.roles/roles/tmux/files/tmux.sh

 

5.加入要安裝的主機: vim /etc/ansible/hosts---------------------------------------------->[tmux]                                       //對應tmux.yaml檔案裡的名稱192.168.19.76 ansible_ssh_pass=password      //主機IP+登入密碼 6.嘗試使用: cd /root/ansible.roles/ansible-playbook tmux.yaml至此,實驗全部完成。使用中發現/etc/profile.d/tmux.sh這個檔案不能被正常source,所以可能需要手動執行一下 . /etc/profile.d/tmux.sh 。由於時間緊迫,所以過程還不是很完善,指令碼也並不嚴謹,沒有一些條件判斷等等,而且安裝主機必須要有編譯環境。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.