Apache Stratos的安裝與配置

目錄

以下所有軟件的OS環境均爲Ubuntu14.04

1. 創建OpenStack鏡像

# vi /etc/apt/source.list1

刪除所有官方的鏡像源,添加阿里雲的鏡像源,並執行apt-get update。

deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse12345
  • 修改時區爲中國時區,Puppet Master和Agent的時間完全同步,否則會出現無法正常通訊的情況。

# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime1
  • 修改Python源爲國內的豆瓣提供的源,否則會出現鏡像製作步驟中配置cartridge時超時的問題,錯誤信息爲:pip installs-gittle timeout。

# cd ~# mkdir .pip# cd .pip# vim pip.conf1234

添加並保存如下內容:

[global] index-url = http://pypi.douban.com/simple [install] trusted-host = pypi.douban.com1234
  • 執行如下命令,進行Cartriage配置

sudo -iapt-get install zip unzip
mkdir -p /root/bin
cd /root/bin
wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/config-scripts/ec2/config.sh;hb=HEAD" -O config.sh
chmod +x config.sh
wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/init-scripts/ec2/ubuntu/init.sh;hb=HEAD" -O init.sh
chmod +x init.sh
mkdir -p /root/bin/puppetinstall
wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/puppet3-agent/puppetinstall/puppetinstall;hb=HEAD" -O puppetinstall/puppetinstall
chmod +x puppetinstall/puppetinstall
wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/puppet3-agent/stratos_sendinfo.rb;hb=HEAD" -O stratos_sendinfo.rb
chmod +x stratos_sendinfo.rb12345678910111213

此處需要注意最後一步,官網的步驟中沒有對stratos_sendinfo.rb賦可執行權限的操作。

  • 設置時間與Puppet Master保持一致

sed -i 's:^TIMEZONE=.*$:TIMEZONE=\"Asia/Shanghai\":g' /root/bin/puppetinstall/puppetinstall1
  • 運行config.sh文件,此處的service-name可輸入default或者不輸入值,若輸入php,在運行期間會出現php配置失敗 的情況,可能是由於puppet腳本有錯誤。(剛配置php可以訪問ip:80,但cartriage agent運行完後無法訪問。Stratos Application的啓動狀態一直停留在starting,原因是程序會訪問80端口但無響應)。

2. 配置Puppet Master

  • 參考官網步驟:6. Setup Puppet Master

  • 此處注意,需要將apache-stratos-python-cartridge-agent-4.1.5.zip文件解壓後去掉4.1.5的版本號去掉後重新解壓後拷貝到puppet的modules的相關目錄下。

  • 配置base.pp文件中的內容時,需要與nodes目錄下的其他資源的定義相符合,比如在base.pp目錄下定義 了$tomcat_version這個變量,則需要在/etc/puppet/manifests/nodes/tomcat.pp目錄下的內容與之對 應,這樣才能正確的文件推送。

node /tomcat/ inherits base {  $tomcat_version            = '8.0.36'
  $docroot = "/mnt/apache-tomcat-${tomcat_version}/webapps/"
  $samlalias="/mnt/apache-tomcat-${tomcat_version}/webapps/"

  class {'tomcat':}
}1234567

3. 運行Stratos

  • 啓動Stratos
    調試運行時可啓動H2數據庫,連內置CEP。

  • 創建各Stratos對象
    創建Cartridge的代碼如下:

{
    "type": "java",
    "category": "framework",
    "provider": "oracle",
    "host": "leaptocloud.com",
    "displayName": "java",
    "description": "java Cartridge",
    "version": "7",
    "multiTenant": true,
    "portMapping": [
        {
            "name": "http-22",
            "protocol": "http",
            "port": 22,
            "proxyPort": 8280
        }
    ],
    "iaasProvider": [
        {
            "type": "openstack",
            "p_w_picpathId": "RegionOne/f8850fcb-a1a5-4288-a808-2c2a0b97adcb",
            "property": [
                {
                    "name": "instanceType",
                    "value": "RegionOne/2"
                }
            ],
            "networkInterfaces": [
                {
                    "networkUuid": "84eeb7b2-82f4-478a-b768-e24d7d0544ee"
                }
            ]        }
    ]}1234567891011121314151617181920212223242526272829303132333435

portMapping配置需要填正確的port配置。配置錯誤時,會出現applicaiton無法啓動的問題。

4. Troubleshooting

  • Cartridge agent運行時可查看syslog日誌,若出現不能正常啓動或者啓動出錯的情況,可手動刪除python agent進行,修改配置後,重新運行agent程序:

# nohup /mnt/apache-stratos-python-cartridge-agent-/agent.py &1

並查看nohup日誌進行調試運行。

  • 調試關鍵路徑
    /root/bin/puppetinstall
    /tmp/payload/launch-params
    /root/bin/puppetinstall/puppetinstall



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章