2.how-to-upgrade-obproxy-to-obproxy-ce-3.2.3.md 2.5 KB
Newer Older
F
v1.6.0  
frf12 已提交
1 2
# 如何升级 obproxy 到 obproxy-ce 3.2.3

R
Rongfeng Fu 已提交
3
由于开源 OBProxy 组件正式更名为 obproxy-ce,因此使用以下命令升级会报 `No such package obproxy-3.2.3` 错误。
F
v1.6.0  
frf12 已提交
4 5 6 7 8

```shell
obd cluster upgrade <deploy name> -c obproxy -V 3.2.3
```

R
Rongfeng Fu 已提交
9
您需在 OBD 的执行用户下执行下述 **脚本** 修改 meta 信息,而后使用以下命令对 OBProxy 进行升级。
F
v1.6.0  
frf12 已提交
10 11 12 13 14 15 16

```shell
obd cluster upgrade <deploy name> -c obproxy-ce -V 3.2.3
```

## 脚本

R
Rongfeng Fu 已提交
17
```bash
F
v1.6.0  
frf12 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
OBD_HOME=${OBD_HOME:-${HOME}}/.obd
obproxy_repository=${OBD_HOME}/repository/obproxy
obproxy_ce_repository=${OBD_HOME}/repository/obproxy-ce

function shadow_repo() {
    repository_path=$1
    ce_repository_path=$2
    [[ $repository_path =~ ^/  ]] && a=$repository_path || a=`pwd`/$repository_path
    while [ -h $a ]
    do
        b=`ls -ld $a|awk '{print $NF}'`
        c=`ls -ld $a|awk '{print $(NF-2)}'`
        [[ $real_patn =~ ^/ ]] && a=$b  || a=`dirname $c`/$b
    done
    instance_hash=`basename $a`
    ce_version_path=`dirname ${ce_repository_path}`
    ln -sf ${ce_version_path}/${instance_hash} ${ce_repository_path}
}

function copy_repository() {
    VS=(`ls $obproxy_repository`)
    for version in ${VS[@]}; do
        version_path="${obproxy_repository}/${version}"
        ce_version_path="${obproxy_ce_repository}/${version}"
        repositories=(`ls $version_path`)
        mkdir -p $ce_version_path
        for repository in ${repositories[@]}; do
            repository_path="${version_path}/${repository}"
            ce_repository_path="${ce_version_path}/${repository}"
            if [ -d "$ce_repository_path" ]; 
            then
                echo "${ce_repository_path} exist"
            else
                if [ -L ${repository_path} ];
                then 
                    shadow_repo ${repository_path} ${ce_repository_path}
                else
                    cp -r ${repository_path} ${ce_repository_path}
                fi
            fi
        done
    done
}

function change_cluster_meta() {
    cluster_home_path=${OBD_HOME}/cluster
    CS=(`ls ${cluster_home_path}`)
    for cluster in ${CS[@]}; do
        cluster_path=${cluster_home_path}/$cluster
        if [ -f ${cluster_path}/.data ]; then
            sed -i 's/^  obproxy:/  obproxy-ce:/g' ${cluster_path}/.data
        fi
        sed -i 's/^obproxy:/obproxy-ce:/' ${cluster_path}/*.yaml
    done
}

copy_repository && change_cluster_meta && echo 'ok'
```