前提:先安裝tomcat,請參考之前寫的在centos7上安裝tomcat的博文
http://12395331.blog.51cto.com/12385331/1884980
安裝jenkins
1> 下載jenkins包。
進入tomcat/webapps/ 目錄下,下載jenkins.war包到這里,如下載有問題,可自行下載傳到這個目錄下,部署的過程中半天都下不下來,提供了jenkins的附件
wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
2> Jekins環境變量設置
[root@localhost bin]sudo vi /etc/profile export JENKINS_HOME=/data/program/tomcat/webapps/Jenkins [root@localhost bin]. /etc/profile #使配置文件生效
3> 修改tomcat默認端口號
vi /usr/local/apache-tomcat/conf/server.xml
把下面這段的port修改為不是8080的其它端口,這里修改為8081,還有個條件:在之前修改iptables的規則文件時已經開放了8081的端口,如果沒有請重新修改,重啟iptables的服務。
<Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443" />
4> 重啟tomcat,進入tomcat的安裝目錄下的bin目錄
[root@localhost bin]./startup.sh
tomcat會解壓war包,生成一個jenkins文件夾,而且會在root目錄下生成一個.jenkins的文件夾
5> Jenkins 驗證。在瀏覽器里,輸入網址:http://localhost:8081/jenkins
6> 輸入密碼 .首次進入jenkins如要輸入密碼
密碼位置:/root/.jenkins/secrets/initialAdminPassword,找不到這個文件就find . -name .jenkins
7> 安裝需要的插件
第一次進入,會出現默認插件安裝不成功,進入插件管理列表也為空,點擊advanced下面的CheckNow,即可輸出available的列表,多試幾次。除了基礎安裝的插件外,主要安裝的插件有:git, git Client, gitlab hook, ansible等
安裝ansible
前提:要安裝ansible系統中必須要安裝python的版本在2.7及以上。
1> Ansible是屬于Extra Packages for Enterprise Linux (EPEL)庫的一部分,因此要先安裝EPEL
[root@localhost ~]yum install epel-release
2> 直接安裝ansible,目前默認安裝的版本是2.2,官方持續在更新
[root@localhost ~]yum install ansible
3> 為支持windows client,要安裝以下的包:安裝Python Winrm模塊
pip install “pywinrm>=0.1.1”
4> 底層通信基于PowerShell,管理機和遠程主機基于Kerbero認證,需額外安裝python-kerbero和MIT krb5依賴庫。
步驟1、 安裝python-kerberos依賴,命令如下:
yum -y install python-devel krb5-devel krb5-libs krb5-workstation
步驟2 、安裝python-kerberos,OSX和Linux發行版均默認安裝,安裝命令如下:
pip install Kerberos
遇到的問題及解決辦法:
1. 端口沖突,tomcat的端口改成8081. 8080端口是jenkins自帶的內部端口,這也是上面步驟中改8081的目的。
2. tomcat service啟動之后,頁面加載不正常。解決辦法:systemctl start tomcat.service 啟動不行。進入到/usr/local/tomcat/bin,./startup.sh這樣啟動tomcat就可以解決。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。