本文意图帮助快速安装OceanBase这一金融级分布式数据库产品。
但部署设计仅供产品体验目的,非生产级别安装方案。
安装OceanBase主要有两种方式, 一为OCP,另一为脚本方式(即deploy.py)。
因不具备桌面环境,本人选择deploy.py方式安装。
四台机器:
192.168.1.10 (记为 IP10) 作为安装控制端
192.168.1.50 (记为 IP50) OB node
192.168.1.51 (记为 IP51) OB node
192.168.1.52 (记为 IP52) OB node
安装后,每台机器均创建admin账号,OB全部进程 (observer & obproxy) 及数据(含日志)均存在于admin账号下(/home/admin)。
OceanBase版本: oceanbase-1.4.60-1571952.el7.x86_64.rpm
[root@xxx ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
yum install rsync libaio*
useradd admin
passwd admin<
登录admin@IP10:
ssh-keygen -t rsa
ssh-copy-id [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]
note:
a. 遇到权限问题,执行: chmod -R 600 ~/.ssh,完成后手工验证无密登录成功即可。
b. 如果ssh不在22端口,需要配置~/.ssh/config (方法略)
登录admin@IP10:
cd ~
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
tar xzvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
ln -s ~/mysql-5.7.25-linux-glibc2.12-x86_64 ~/mysql
echo 'export PATH=$HOME/mysql/bin:$PATH' >> ~/.bash_profile
cat > ~/.my.cnf <
登录admin@IP10:
mkdir -p ~/ob-deploy/bin
wget https://gw.alipayobjects.com/os/downloads/ossupload/ocp-release.zip
unzip ocp-release.zip
cd ~/ocp-release
tar xzvf ocp-setup.tar.gz
cd ocp_yh
rpm2cpio oceanbase-1.4.60-1571952.el7.x86_64.rpm |cpio -ivd
cp ./home/admin/oceanbase/bin/observer ~/ob-deploy/bin
cp ./home/admin/oceanbase/bin/ob_admin ~/ob-deploy/bin
rpm2cpio obproxy-1.3.3-1506155.el7.x86_64.rpm |cpio -ivd
cp ./opt/taobao/install/obproxy/bin/obproxy ~/ob-deploy/bin
登录admin@IP10:
cd ~/ob-deploy
python deploy.py prepare_local_dir
python deploy.py gen_config
生成config.py,并改如下:
clog_dir = '/home/admin/obdata/log1'
data_dir = '/home/admin/obdata/1'
log_dir = ''
log_level='INFO'
port_gen = itertools.count(8040)
obs_cfg=dict(datafile_size='10G',
enable_merge_by_turn='False',
memory_limit='16G',
)
ip_list = dict(ip1='192.168.1.50', ip2='192.168.1.51', ip3='192.168.1.52')
ob1 = OBI(sub('rs@$ip1@z1 proxy@$ip1@z1 rs@$ip2@z2 proxy@$ip2@z2 rs@$ip3@z3 proxy$ip3@z3', ip_list))
obx = OBI(local_ip)
oby = OBI(sub('$ip1@z1 proxy@$ip1@z1', dict(ip1=local_ip)))
继续执行:
python deploy.py ob1.reboot
看到如下代表成功了:
2019-03-20 14:38:35.220318 13198 hap.py:255 call: top.ob1 obs0.check_bootstrap
['ob1.reboot',
[('check_local_bin', 'OK'),
('check_ssh', 'OK'),
('force_stop',
[('obs0.stop', 'succ'),
('obs1.stop', 'succ'),
('obs2.stop', 'succ'),
('proxy0.stop', 'succ'),
('proxy1.stop', 'succ'),
('proxy2.stop', 'succ')]),
('sleep', None),
('cleanup',
[('obs0.rmdir', 0),
('obs1.rmdir', 0),
('obs2.rmdir', 0),
('proxy0.rmdir', 0),
('proxy1.rmdir', 0),
('proxy2.rmdir', 0)]),
('check_dir',
[('obs0.check_dir', 'OK'),
('obs1.check_dir', 'OK'),
('obs2.check_dir', 'OK'),
('proxy0.check_dir', 'OK'),
('proxy1.check_dir', 'OK'),
('proxy2.check_dir', 'OK')]),
('mk_local_dir', 0),
('mkdir',
[('obs0.mkdir', 0),
('obs1.mkdir', 0),
('obs2.mkdir', 0),
('proxy0.mkdir', 0),
('proxy1.mkdir', 0),
('proxy2.mkdir', 0)]),
('rsync',
[('obs0.rsync', 0),
('obs1.rsync', 0),
('obs2.rsync', 0),
('proxy0.rsync', 0),
('proxy1.rsync', 0),
('proxy2.rsync', 0)]),
('prepare_proxy_cfg', 0),
('mkdir_for_gcda',
[('obs0.mkdir_for_gcda', 0),
('obs1.mkdir_for_gcda', 0),
('obs2.mkdir_for_gcda', 0),
('proxy0.mkdir_for_gcda', 0),
('proxy1.mkdir_for_gcda', 0),
('proxy2.mkdir_for_gcda', 0)]),
('gen_iobench',
[('obs0.gen_iobench', 0),
('obs1.gen_iobench', 0),
('obs2.gen_iobench', 0)]),
('start_servers',
[('obs0.start', 0), ('obs1.start', 0), ('obs2.start', 0)]),
('bootstrap', 'succ'),
('add_server', []),
('wait_service', 'succ'),
('exec_init_sql', ''),
('exec_help_init_sql', ''),
('start_proxy',
[('proxy0.start', 0), ('proxy1.start', 0), ('proxy2.start', 0)]),
('check_bootstrap', 0)]]
admin@IP50上的进程:
PID TTY STAT TIME COMMAND
9896 pts/0 S 0:00 -bash
9930 pts/0 R+ 0:00 \_ ps -u admin f
12434 ? Ssl 198:31 /home/admin/ob1.proxy2/bin/obproxy -p 8051 -n ob1.admin -o syslog_level=INFO,enable_cluster_checkout=false -r 192.168.1.50:8049;192.168.1.51:8041;192.168.1.52:8045
11764 ? Ssl 6036:32 /home/admin/ob1.obs2/bin/observer -P 8048 -p 8049 -z z3 -n ob1.admin -c 1 -d /home/admin/ob1.obs2/store -l INFO -r 192.168.1.50:8048:8049;192.168.1.51:8040:8041;192.168.1.52:8044:8045 -o memory_limit=64G,enable_merge_by_turn=False,datafile_size=10G
admin@IP51上的进程:
PID TTY STAT TIME COMMAND
19505 pts/0 S 0:00 -bash
19754 pts/0 R+ 0:00 \_ ps -u admin f
14282 ? Ssl 389:30 /home/admin/ob1.proxy0/bin/obproxy -p 8043 -n ob1.admin -o syslog_level=INFO,enable_cluster_checkout=false -r 192.168.1.50:8049;192.168.1.51:8041;192.168.1.52:8045
13481 ? Ssl 7922:04 /home/admin/ob1.obs0/bin/observer -P 8040 -p 8041 -z z1 -n ob1.admin -c 1 -d /home/admin/ob1.obs0/store -l INFO -r 192.168.1.50:8048:8049;192.168.1.51:8040:8041;192.168.1.52:8044:8045 -o memory_limit=64G,enable_merge_by_turn=False,datafile_size=10G
admin@IP52上的进程:
PID TTY STAT TIME COMMAND
3729 pts/1 S 0:00 -bash
3753 pts/1 R+ 0:00 \_ ps -u admin f
6400 ? Ssl 424:49 /home/admin/ob1.proxy1/bin/obproxy -p 8047 -n ob1.admin -o syslog_level=INFO,enable_cluster_checkout=false -r 192.168.1.50:8049;192.168.1.51:8041;192.168.1.52:8045
5737 ? Ssl 8784:56 /home/admin/ob1.obs1/bin/observer -P 8044 -p 8045 -z z2 -n ob1.admin -c 1 -d /home/admin/ob1.obs1/store -l INFO -r 192.168.1.50:8048:8049;192.168.1.51:8040:8041;192.168.1.52:8044:8045 -o memory_limit=64G,enable_merge_by_turn=False,datafile_size=10G
登录admin@IP10:
mysql --prompt "OceanBase (\u@\d)> " -h 192.168.1.50 -P 8041 -uroot -Doceanbase
-- 建RESOURCE UNIT:
CREATE RESOURCE UNIT res_unit1 max_cpu 2, max_memory '2G', max_iops 128, max_disk_size '1G', max_session_num 64, MIN_CPU=1, MIN_MEMORY='1G', MIN_IOPS=128;
-- 建RESOURCE POOL:
CREATE RESOURCE POOL pool1 unit='res_unit1', unit_num=1, zone_list=('z1', 'z2', 'z3');
-- 建租户:
CREATE TENANT tenant1 charset='utf8mb4', replica_num=1, zone_list=('z1', 'z2', 'z3'), primary_zone='z1', resource_pool_list=('pool1');
更多尝试,参考官方文档吧
https://oceanbase.alipay.com/docs