签到成功

知道了

CNDBA社区CNDBA社区

TDSQL 集群 proxy 模块 扩容与缩容 操作手册

2021-08-24 10:00 3267 0 原创 TDSQL
作者: dave

在之前的博客,我们了解到了TDSQL 架构和相关模块的升级、扩容操作,如下。

TDSQL 架构 组件 说明
https://www.cndba.cn/dave/article/4586

TDSQL 集群 主要模块(Scheduler/OSS/agent/proxy) 功能 说明
https://www.cndba.cn/dave/article/4683http://www.cndba.cn/dave/article/4691

TDSQL 集群 组件升级(mysql / agent / proxy) 操作手册
https://www.cndba.cn/dave/article/4625http://www.cndba.cn/dave/article/4691

http://www.cndba.cn/dave/article/4691

TDSQL 扩容 zookeeper 节点(1到3) 操作手册
https://www.cndba.cn/dave/article/4608http://www.cndba.cn/dave/article/4691

本篇我们来学习proxy 组件的扩容和缩容。 在实际环境中,当proxy资源不足时可以进行扩容,从而增加proxy计算资源,或在资源有浪费时,进行资源的回收。

因为我这边的测试环境只有3个节点,都部署了proxy,所以我们先演示缩容操作,在演示扩容操作。 Proxy的扩容和缩容相对比较简单,直接在赤兔平台上进行操作就可以了。http://www.cndba.cn/dave/article/4691

1 proxy缩容

1.1 修改缩容生效时间

在TDSQL 10.3.16.2.0 版本之前,需要在zk中手工修改proxy 缩容的时间,修改proxy缩容的默认生效时间是240分钟,在PoC场景中,如果要马上生效,需要修改zk节点。

在TDSQL 10.3.16.2.0 版本之后,在设置缩容时可以在赤兔界面直接指定缩容时间,避免了麻烦。

后台修改zk中的缩容时间,将240分钟修改为1分钟

[dave@www.cndba.cn ~]# cd /data/application/zookeeper/bin/
[dave@www.cndba.cn bin]#  ./zkCli.sh -server tdsql2:2118
[zk: tdsql2:2118(CONNECTED) 0] get /tdsqlzk/manager/manager_proxy/proxy_variable 
[zk: tdsql2:2118(CONNECTED) 1] set /tdsqlzk/manager/manager_proxy/proxy_variable {"dns_ttl":"30","shrink_minute":"1"} 

修改后验证: 
[zk: tdsql2:2118(CONNECTED) 2] get /tdsqlzk/manager/manager_proxy/proxy_variable

1.2 删除proxy

赤兔设置
http://www.cndba.cn/dave/article/4691

等1分钟左右,操作结束,在赤兔界面就会看到proxy 变成了2台机器。 http://www.cndba.cn/dave/article/4691

2 proxy 扩容

2.1 用原缩容后的主机来扩容

缩容后的机器,proxy 相关的文件都在,所以直接在赤兔界面操作就可以了。

如果是新的设备,需要先在设备管理里添加网关资源:

因为我们这里是之前删除的proxy,不需要操作,直接添加proxy即可。

http://www.cndba.cn/dave/article/4691

我这里没有指定IP地址,自动从网关资源里获取,也可以指定,添加完成后查看,又恢复成3个proxy了:

http://www.cndba.cn/dave/article/4691

2.2 新设备来扩容proxy

如果是用新设备来扩容,那么在赤兔平台操作之前,还需要做一些准备工作。

2.2.1 配置时间同步和ansible机器到目标的免密登录

具体操作参考之前的博客:

TDSQL 分布式集群(10.3.16.2.0) 搭建手册 详细截图版
https://www.cndba.cn/dave/article/4595

2.2.2 在主控机playbooks目录下创建newproxy.yml脚本

[dave@www.cndba.cn  playbooks]# pwd
/data/tdsql_10.3.16.2.0/tdsql_install/playbooks

[dave@www.cndba.cn  playbooks]# cat newproxy.yml
- name: install newproxy beginning
  hosts: newproxy
  remote_user: root
  gather_facts: false
  roles:
    - tdsql_beginning

- name: install proxy_module server
  hosts: newproxy
  remote_user: root
  gather_facts: false
  roles:
    - tdsql_db_module
[dave@www.cndba.cn  playbooks]#

2.2.3 修改tdsql_hosts文件内容

tdsql_hosts文件中添加类似如下内容:

[newproxy]
newproxy1 ansible_ssh_host=10.206.0.9

2.2.4 后台安装proxy

执行安装新proxy

[dave@www.cndba.cn  tdsql_install]# pwd
/data/tdsql_10.3.16.2.0/tdsql_install

[dave@www.cndba.cn  tdsql_install]# ls
group_vars  playbooks  roles  scripts  tdsql_add_hosts  tdsql_hosts  tdsql_update_hosts

[dave@www.cndba.cn  tdsql_install]# ansible-playbook -i tdsql_hosts playbooks/newproxy.yml

PLAY [install newproxy beginning] ************************************************************************************

TASK [tdsql_beginning : create the directory] ************************************************************************
[WARNING]: Consider using the file module with state=directory rather than running 'mkdir'.  If you need to use
command because file is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False'
in ansible.cfg to get rid of this message.
changed: [newproxy1]

TASK [tdsql_beginning : ansible local create the directory] **********************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the tdsql_common] ***********************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the tdsql_lib] **************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the init_env_packet.sh and init_env_make.sh to dest host] *******************************
changed: [newproxy1] => (item=init_env_make.sh)
changed: [newproxy1] => (item=init_env_packet.sh)

TASK [tdsql_beginning : do init_env_packet.sh] ***********************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : do init_env_make.sh] *************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the fiotest.sh to the dst host] *********************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the tdsql_python to the dst host] *******************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the install_python3.sh to the dst host] *************************************************
changed: [newproxy1]

TASK [tdsql_beginning : install python3] *****************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : generate the init_os_para.sh on dest host] ***************************************************
changed: [newproxy1]

TASK [tdsql_beginning : do init_os_para.sh] **************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : local read profile_add] **********************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : write /etc/profile] **************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the jdk.zip file to the dst host] *******************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the install_jdk.sh to the dst host] *****************************************************
changed: [newproxy1]

TASK [tdsql_beginning : do install_jdk.sh] ***************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : local read profile_add] **********************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : write /etc/profile] **************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the hdfsinstall packets to the dst host] ************************************************
changed: [newproxy1]

TASK [tdsql_beginning : upload the scripts file to the dest host] ****************************************************
changed: [newproxy1]

TASK [tdsql_beginning : install the hdfsinstall packet] **************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the tdsql_monitorcmd to the dst host] ***************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the install_monitor.sh to the dst host] *************************************************
changed: [newproxy1]

TASK [tdsql_beginning : install monitortop packet] *******************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the oc_agent file to the dst host] ******************************************************
changed: [newproxy1]

TASK [tdsql_beginning : copy the oc_agent script to the dst host] ****************************************************
changed: [newproxy1]

TASK [tdsql_beginning : install oc_agent packet] *********************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : generate oc server password] *****************************************************************
changed: [newproxy1 -> 10.206.0.7]

TASK [tdsql_beginning : generate oc client password] *****************************************************************
changed: [newproxy1 -> 10.206.0.7]

TASK [tdsql_beginning : copy the oc_agent config file] ***************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : update the oc_agent config file] *************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : replace oc_agent.xml] ************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : start oc_agent] ******************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : upload the checkalive file to the dest host] *************************************************
changed: [newproxy1]

TASK [tdsql_beginning : local read tdsql_crontab] ********************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : write /etc/crontab] **************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : generate the zk_hosts.j2 on dest host] *******************************************************
ok: [newproxy1]

TASK [tdsql_beginning : local read zk_hosts] *************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : write /etc/hosts] ****************************************************************************
changed: [newproxy1]

TASK [tdsql_beginning : touch and mark file /data/tools/.beginning_finished] *****************************************
[WARNING]: Consider using the file module with state=touch rather than running 'touch'.  If you need to use command
because file is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in
ansible.cfg to get rid of this message.
changed: [newproxy1]

PLAY [install proxy_module server] ***********************************************************************************

TASK [tdsql_db_module : create the directory] ************************************************************************
changed: [newproxy1]

TASK [tdsql_db_module : copy the tdsqlinstall packets to the dst host] ***********************************************
changed: [newproxy1]

TASK [tdsql_db_module : copy the scripts file to the dst host] *******************************************************
changed: [newproxy1]

TASK [tdsql_db_module : install tdsqlinstall packet] *****************************************************************
changed: [newproxy1]

TASK [tdsql_db_module : modify max_open_files in oc_pull_mysqld.sh] **************************************************
changed: [newproxy1]

TASK [tdsql_db_module : overwrite oc_tool from oc_agent on db_module] ************************************************
changed: [newproxy1]

TASK [tdsql_db_module : overwrite binlogproducter] *******************************************************************
changed: [newproxy1]

TASK [tdsql_db_module : overwrite binlogproducter_percona] ***********************************************************
changed: [newproxy1]

TASK [tdsql_db_module : add privi mysqlagent bin] ********************************************************************
[WARNING]: Consider using the file module with mode rather than running 'chmod'.  If you need to use command because
file is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in ansible.cfg to
get rid of this message.
changed: [newproxy1]

PLAY RECAP ***********************************************************************************************************
newproxy1                  : ok=51   changed=50   unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

[dave@www.cndba.cn  tdsql_install]#

2.2.5 赤兔前台上报proxy机器和网关组扩容

前台上报新增proxy机器
http://www.cndba.cn/dave/article/4691

前台网关组扩容

扩容成功后验证:

新增proxy机器上也会有对应的进程:

[dave@www.cndba.cn  ~]# ps -ef|grep proxy
tdsql    28216     1  0 11:58 ?        00:00:00 ./mysql-proxy /data/tdsql_run/15001/gateway/conf/instance_15001.cnf
tdsql    28217 28216  0 11:58 ?        00:00:01 ./mysql-proxy /data/tdsql_run/15001/gateway/conf/instance_15001.cnf
tdsql    28605     1  0 11:58 ?        00:00:00 ./mysql-proxy /data/tdsql_run/15002/gateway/conf/instance_15002.cnf
tdsql    28606 28605  0 11:58 ?        00:00:01 ./mysql-proxy /data/tdsql_run/15002/gateway/conf/instance_15002.cnf
tdsql    29461     1  0 11:58 ?        00:00:00 ./mysql-proxy /data/tdsql_run/15003/gateway/conf/instance_15003.cnf
tdsql    29462 29461  0 11:58 ?        00:00:01 ./mysql-proxy /data/tdsql_run/15003/gateway/conf/instance_15003.cnf
tdsql    29753     1  0 11:58 ?        00:00:00 ./mysql-proxy /data/tdsql_run/15004/gateway/conf/instance_15004.cnf
tdsql    29754 29753  0 11:58 ?        00:00:02 ./mysql-proxy /data/tdsql_run/15004/gateway/conf/instance_15004.cnf
root     46270  2577  0 12:03 pts/1    00:00:00 grep --color=auto proxy
[dave@www.cndba.cn  ~]#

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7970494次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ