Gbase 数据库 | GBASE 8A خوشه نصب و استقرار خودکار با استفاده از Ansible

پیشنهاد ویژه
[button color="primary" size="big" link="https://nabfollower.com/buy-real-follower/" icon="" target="true" follow="false"]خرید فالوور واقعی[/button][button color="primary" size="big" link="https://nabfollower.com/buy-instagram-like/" icon="" target="true" follow="false"]خرید لایک اینستاگرام[/button][button color="primary" size="big" link="https://nabfollower.com/buy-instagram-views/" icon="" target="true" follow="false"]خرید ویو اینستاگرام[/button][button color="primary" size="big" link="https://nabfollower.com/" icon="" target="true" follow="false"]خرید فالوور اینستاگرام[/button]
در این مقاله ، ما شما را از طریق فرآیند خودکار سازی نصب و استقرار یک خوشه GBase 8A با استفاده از Ansible راهنمایی خواهیم کرد. این راه حل ، استقرار پایگاه داده GBase 8A (GBASE 数据库) را در یک محیط خوشه ای ساده می کند و مدیریت و مقیاس آن را آسان تر می کند.
پیکربندی میزبان
یک پیکربندی مثال به شرح زیر است:
[all]
192.168.56.3 gbaseRole=coor RoleId=1 vc_name="" private_ip1=192.168.56.3 private_ip2=192.168.56.3
192.168.56.4 gbaseRole=newcoor RoleId=1 vc_name=vc1 private_ip1=192.168.56.4 private_ip2=192.168.56.6
192.168.56.5 gbaseRole=newnode RoleId=2 vc_name=vc1 private_ip1=192.168.56.4 private_ip2=192.168.56.6
192.168.56.6 gbaseRole=node RoleId=1 vc_name=vc2 private_ip1=192.168.56.4 private_ip2=192.168.56.6
-
192.168.56.3
: IP شبکه تجاری -
gbaseRole
: نقش GBase (گره مدیریت:coor
، گره محاسبه:node
) -
RoleId
: شناسه نقش ، پی در پی را پر کنید -
vc_name
: نام خوشه مجازی برای گره های محاسباتی ، برای گره های مدیریتی خالی بگذارید ، تنظیم کنیدdata
در حالت سازگاری -
private_ip1
: آدرس IP شبکه خصوصی 1 برای گره های محاسبه -
private_ip2
: آدرس IP شبکه خصوصی 2 برای گره های محاسبه (برای تنظیمات تک در حالت لازم نیست)
توضیح متغیرها
# GBase installation package name
gbase_setup_file: 'xxxx.tar.bz2'
# Operating system root password
root_passwd: '111111'
# GBase password for the operating system
gbase_passwd: '111111'
# Database DBA user (root, gbase) password
dba_password: '111111'
# Database character set (utf8, utf8mb4, gbk, etc.)
db_charset: utf8
vc_lists: ['vc1']
# Management node ID list, generally recommended to be the IP address's last segment, separated by commas
coorHostNodeIDlist: '1,2,3'
توضیحات کار
آماده سازی نصب اولیه
- name: Install necessary RPM packages
yum: name={{ item }} state=installed
with_items:
- bzip2
- expect
- gcc
- '*cgroup*'
- bc
- numactl
- rsync
tags:
init_env
- name: Upload GBase installation package
copy:
src: files/{{ gbase_setup_file }}
dest: /opt/
when: "gbaseRole == 'coor' and RoleId == 1"
tags:
init_env
- name: Extract GBase installation package
unarchive:
src: /opt/{{ gbase_setup_file }}
dest: /opt/
remote_src: yes
when: "gbaseRole == 'coor' and RoleId == 1"
tags:
init_env
- name: Create GBase user
user:
name: gbase
state: present
update_password: always
password: '{{ gbase_passwd | password_hash('sha512') }}'
tags:
init_env
- name: Change ownership of /opt directory
file:
path: /opt
state: directory
owner: gbase
group: gbase
recurse: yes
tags:
init_env
- name: Upload system environment variable initialization script
copy:
src: SetSysEnv.py
dest: /tmp
tags:
init_env
- name: Initialize system environment variables
shell: 'python /tmp/SetSysEnv.py --dbaUser=gbase --installPrefix=/opt --cgroup'
tags:
init_env
فایل پیکربندی نصب را تولید کنید
- name: Generate installation configuration file
template:
src: demo.options.j2
dest: /opt/gbase_workspace/setup/gcinstall/demo.options
when: "gbaseRole == 'coor' and RoleId == 1 and InstanceType == 0"
tags:
install
become: true
become_user: gbase
demo.options.j2
الگوی:
installPrefix= /opt
coordinateHost = {% for host in groups['all'] -%}
{% if hostvars[host]['gbaseRole']=='coor' -%}
{% if hostvars[host]['RoleId'] == 1 -%}
{{ hostvars[host]['private_ip1'] }}
{%- else -%}
,{{ hostvars[host]['private_ip1'] }}
{%- endif %}
{%- endif %}
{%- endfor %}
coordinateHostNodeID = {{ coorHostNodeIDlist }}
dataHost = {% for host in groups['all'] -%}
{% if hostvars[host]['gbaseRole']=='node' -%}
{% if hostvars[host]['RoleId'] == 1 -%}
{{ hostvars[host]['private_ip1'] }}
{%- else -%}
,{{ hostvars[host]['private_ip1'] }}
{%- endif %}
{%- endif %}
{%- endfor %}
gcwareHost = {% for host in groups['all'] -%}
{% if hostvars[host]['gbaseRole']=='coor' -%}
{% if hostvars[host]['RoleId'] == 1 -%}
{{ hostvars[host]['private_ip1'] }}
{%- else -%}
,{{ hostvars[host]['private_ip1'] }}
{%- endif %}
{%- endif %}
{%- endfor %}
gcwareHostNodeID = {{ coorHostNodeIDlist }}
dbaUser = gbase
dbaGroup = gbase
dbaPwd = '{{ gbase_passwd }}'
rootPwd = '{{ root_passwd }}'
characterSet = {{ db_charset }}
نصب و استقرار محیط زیست
- name: Install and deploy GBase
shell: 'sh ansible_install.sh'
when: "gbaseRole == 'coor' and RoleId == 1"
tags:
install
become: true
become_user: gbase
ansible_install.sh
فیلمنامه:
#!/usr/bin/sh
###########################################################
##creator :
##create time:
##Description: Silent installation script
##Version:
###########################################################
cd /opt/gcinstall
spawn python gcinstall.py --silent=demo.options -i
expect {
"*])?" {send "y\r"; exp_continue}
"*])?" {send "y\r"; exp_continue}
}
متغیرهای محیط سیستم را دوباره آغاز کنید
- name: Reinitialize system environment variables
shell: 'python /tmp/SetSysEnv.py --dbaUser=gbase --installPrefix=/opt --cgroup'
tags:
init_env
فایل پیکربندی ایجاد VC ایجاد کنید
- name: Generate VC creation configuration file
vars:
cur_vcname: "{{ item }}"
template:
src: createvc.xml.j2
dest: /opt/gcinstall/createvc_{{ item }}.xml
when: "gbaseRole == 'coor' and RoleId == 1"
with_items:
"{{ vc_lists }}"
tags:
install
become: true
become_user: gbase
createvc.xml.j2
الگوی:
{% for host in groups['all'] %}
{% if hostvars[host]['vc_name']==cur_vcname %}
ip="{{ hostvars[host]['private_ip1'] }}"/>
{% endif %}
{% endfor %}
name="{{ cur_vcname }}"/>
message="{{ cur_vcname }}"/>
ایجاد VC
- name: Create VC
shell: 'source ~/.bash_profile; cd /opt/gcinstall; gcadmin createvc createvc_{{ item }}.xml'
when: "gbaseRole == 'coor' and RoleId == 1"
with_items:
"{{ vc_lists }}"
tags:
install
become: true
become_user: gbase
فایل پیکربندی ایجاد توزیع را ایجاد کنید
- name: Generate initialization configuration file
vars:
cur_vcname: "{{ item }}"
template:
src: gcChangeInfo_vcname.xml.j2
dest: /opt/gcinstall/gcChangeInfo_{{ item }}.xml
when: "gbaseRole == 'coor' and RoleId == 1"
with_items:
"{{ vc_lists }}"
tags:
install
become: true
become_user: gbase
برای ایجاد توزیع الگوی فایل پیکربندی ایجاد کنید (gcChangeInfo_vcname.xml.j2
)
installPrefix= /opt
coordinateHost = {% for host in groups['all'] -%}
{% if hostvars[host]['gbaseRole']=='coor' -%}
{% if hostvars[host]['RoleId'] == 1 -%}
{{ hostvars[host]['private_ip1'] }}
{%- else -%}
,{{ hostvars[host]['private_ip1'] }}
{%- endif %}
{%- endif %}
{%- endfor %}
coordinateHostNodeID = {{ coorHostNodeIDlist }}
dataHost = {% for host in groups['all'] -%}
{% if hostvars[host]['gbaseRole']=='node' -%}
{% if hostvars[host]['RoleId'] == 1 -%}
{{ hostvars[host]['private_ip1'] }}
{%- else -%}
,{{ hostvars[host]['private_ip1'] }}
{%- endif %}
{%- endif %}
{%- endfor %}
#existCoordinateHost =
#existDataHost =
#existGcwareHost=
gcwareHost = {% for host in groups['all'] -%}
{% if hostvars[host]['gbaseRole']=='coor' -%}
{% if hostvars[host]['RoleId'] == 1 -%}
{{ hostvars[host]['private_ip1'] }}
{%- else -%}
,{{ hostvars[host]['private_ip1'] }}
{%- endif %}
{%- endif %}
{%- endfor %}
gcwareHostNodeID = {{ coorHostNodeIDlist }}
dbaUser = gbase
dbaGroup = gbase
dbaPwd = '{{ gbase_passwd }}'
rootPwd = '{{ root_passwd }}'
#dbRootPwd = ''
#rootPwdFile = rootPwd.json
characterSet = {{ db_charset }}
#sshPort = 22
توزیع ایجاد کنید
- name: Initialize distribution for VC (multi-VC mode)
shell: "source ~/.bash_profile; cd /opt/gcinstall; gcadmin distribution gcChangeInfo_{{ item }}.xml p 1 d 1 db_user gbase db_pwd 'gbase20110531' dba_os_password '{{ gbase_passwd }}' vc {{ item }}"
when: "gbaseRole == 'coor' and RoleId == 1"
with_items:
"{{ vc_lists }}"
tags:
install
become: true
become_user: gbase
nodedatamap را اولیه کنید
- name: Initialize nodedatamap for VC
vars:
cur_vcname: "{{ item }}"
shell: 'source ~/.bash_profile; gccli -ugbase -pgbase20110531 -e"use vc {{ item }}; initnodedatamap;"'
when: "gbaseRole == 'coor' and RoleId == 1"
with_items:
"{{ vc_lists }}"
tags:
install
become: true
become_user: gbase
پایان
با خودکار سازی نصب و استقرار خوشه های GBase 8A (GBase 数据库) با Ansible ، می توانید مداخله دستی را به میزان قابل توجهی کاهش داده و کارایی محیط پایگاه داده خود را افزایش دهید. این روش به ویژه برای استقرار و محیطهای در مقیاس بزرگ مفید است که قوام آن بسیار مهم است.
اگر سؤالی دارید یا به توضیح بیشتر نیاز دارید ، در نظرات یا از طریق پیام های مستقیم احساس راحتی کنید.