合 手动部署 OceanBase 单副本集群
- OceanBase Docker安装体验:https://www.dbaup.com/oceanbase-dockeranzhuangtiyan.html
说明
相关连接:
https://open.oceanbase.com/blog/10900159
https://open.oceanbase.com/answer/detail?id=13700696
练习目的
本次练习目的掌握 OceanBase 集群的手动部署技能,理解进程的相关目录、集群初始化、OBProxy和 OB 集群关系等。
练习条件
有笔记本或服务器,内存至少12G 。
练习内容
请记录并分享下列内容:
- (必选)手动部署一个 OB 单副本集群,包括一个 OBProxy 节点。
- (必选)创建一个业务租户、一个业务数据库,以及一些表等。
- (可选)如果单台服务器内存有32G,或者有三台服务器,改为部署一个 OB 三副本集群,包括一个 OBProxy 节点。
- (可选)如果有三台服务器并且服务器内存有 32 G,可以单服务器内启动 2 个节点,实现 1-1-1 扩容到 2-2-2 。
软件下载
下载地址:https://open.oceanbase.com/softwareCenter/community
从https://www.oceanbase.com/softwareCenter/community
下载3个软件,分别是obproxy-3.2.0-1.el7.x86_64.rpm
、oceanbase-ce-3.1.1-4.el7.x86_64.rpm
、oceanbase-ce-libs-3.1.1-4.el7.x86_64.rpm
。
1 2 3 | wget https://mdn.alipayobjects.com/ob_portal/afts/file/A*4VfBRbz_ncIAAAAAAAAAAAAADmF2AQ?af_fileName=oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm wget https://mdn.alipayobjects.com/ob_portal/afts/file/A*obcATbEfH_QAAAAAAAAAAAAADmF2AQ?af_fileName=oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm wget https://mdn.alipayobjects.com/ob_portal/afts/file/A*mMziSJneiZcAAAAAAAAAAAAADmF2AQ?af_fileName=obproxy-3.2.0-1.el7.x86_64.rpm |
手动部署一个 OB 单副本集群
环境准备
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | docker rm -f lhrob312 docker run -d --name lhrob312 -h lhrob312 \ -p 12881-12889:2881-2889 \ -v /sys/fs/cgroup:/sys/fs/cgroup \ --privileged=true lhrbest/lhrcentos76:8.5 \ /usr/sbin/init docker exec -it lhrob312 bash -- 创建用户 useradd admin echo "admin:lhr" | chpasswd echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -- 安装OB软件 rpm -ivh *.rpm echo "export PATH=$PATH:/home/admin/oceanbase/bin:/home/admin/obproxy-3.2.0/bin" >> /home/admin/.bash_profile echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/" >> /home/admin/.bash_profile source /home/admin/.bash_profile chown -R admin:admin /home/admin -- 安装OB和MySQL客户端 yum install -y yum-utils yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo yum install -y obclient mariadb mariadb-libs mariadb-devel |
安装过程:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 | [root@lhrob312 soft]# ll -h total 55M -rw-r--r-- 1 root root 7.9M Nov 5 09:10 obproxy-3.2.0-1.el7.x86_64.rpm -rw-r--r-- 1 root root 47M Dec 31 17:57 oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm -rw-r--r-- 1 root root 156K Dec 31 19:40 oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm [root@lhrob312 soft]# useradd admin [root@lhrob312 soft]# echo "admin:lhr" | chpasswd [root@lhrob312 soft]# [root@lhrob312 soft]# chown -R admin:admin /home/admin [root@lhrob312 soft]# echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers [root@lhrob312 soft]# [root@lhrob312 soft]# [root@lhrob312 soft]# rpm -ivh *.rpm warning: obproxy-3.2.0-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY Preparing... ################################# [100%] Updating / installing... 1:oceanbase-ce-libs-3.1.2-100003920################################# [ 33%] 2:oceanbase-ce-3.1.2-10000392021123################################# [ 67%] 3:obproxy-3.2.0-1.el7 ################################# [100%] [root@lhrob312 soft]# echo "export PATH=$PATH:/home/admin/oceanbase/bin:/home/admin/obproxy-3.2.0/bin" >> /home/admin/.bash_profile [root@lhrob312 soft]# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/" >> /home/admin/.bash_profile [root@lhrob312 soft]# source /home/admin/.bash_profile [root@lhrob312 soft]# [root@lhrob312 soft]# rpm -ql oceanbase-ce /home/admin/oceanbase/bin /home/admin/oceanbase/bin/import_time_zone_info.py /home/admin/oceanbase/bin/observer /home/admin/oceanbase/etc /home/admin/oceanbase/etc/oceanbase_upgrade_dep.yml /home/admin/oceanbase/etc/priv_checker.py /home/admin/oceanbase/etc/timezone_V1.log /home/admin/oceanbase/etc/upgrade_checker.py /home/admin/oceanbase/etc/upgrade_cluster_health_checker.py /home/admin/oceanbase/etc/upgrade_post.py /home/admin/oceanbase/etc/upgrade_post_checker.py /home/admin/oceanbase/etc/upgrade_pre.py /home/admin/oceanbase/etc/upgrade_rolling_post.py /home/admin/oceanbase/etc/upgrade_rolling_pre.py [root@lhrob312 soft]# rpm -ql oceanbase-ce-libs /home/admin/oceanbase/lib /home/admin/oceanbase/lib/libaio.so /home/admin/oceanbase/lib/libaio.so.1 /home/admin/oceanbase/lib/libaio.so.1.0.1 /home/admin/oceanbase/lib/libmariadb.so /home/admin/oceanbase/lib/libmariadb.so.3 [root@lhrob312 soft]# rpm -ql obproxy /home/admin/obproxy-3.2.0/bin /home/admin/obproxy-3.2.0/bin/obproxy /home/admin/obproxy-3.2.0/bin/obproxyd.sh [root@lhrob312 ~]# chown -R admin:admin /home/admin |
配置启动OB并初始化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | -- 单副本 su - admin mkdir -p /home/admin/oceanbase/store/sstable cd /home/admin/oceanbase/store/ && /home/admin/oceanbase/bin/observer -r "127.0.0.1:2882:2881" -o "__min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4" -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR #以上命令中指定的参数作用可参考obd自动部署过程yaml文件的说明,请移步 https://gitee.com/oceanbase/obdeploy/tree/master/example # 查看进程信息 ps -ef |grep observer netstat -tulnp | grep 288 -- bootstrap集群(初始化集群) mysql -h127.1 -uroot -P2881 -p -c -A # 默认空密码 set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '127.0.0.1:2882'; # 修改root密码 alter user root identified by 'lhr'; create user proxyro identified by 'lhr'; grant select on *.* to proxyro; |
过程:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 76 77 78 79 80 81 82 83 84 85 | [admin@lhrob312 oceanbase]$ mkdir -p /home/admin/oceanbase/store/sstable [admin@lhrob312 oceanbase]$ ll /home/admin/oceanbase/store/sstable total 0 [admin@lhrob312 oceanbase]$ [admin@lhrob312 oceanbase]$ [admin@lhrob312 oceanbase]$ /home/admin/oceanbase/bin/observer -r 127.0.0.1:2882:2881 -o "__min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4" -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR /home/admin/oceanbase/bin/observer -r 127.0.0.1:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4 -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR rs list: 127.0.0.1:2882:2881 optstr: __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4 zone: zone1 mysql port: 2881 rpc port: 2882 appname: lhrob-single cluster id: 20220108 data_dir: /home/admin/oceanbase/store devname: lo log level: ERROR [admin@lhrob312 oceanbase]$ ll total 24 drwxr-xr-x 2 admin admin 4096 Jan 8 11:34 bin drwxr-xr-x 2 admin admin 4096 Jan 8 11:34 etc drwxr-xr-x 2 admin admin 4096 Jan 8 11:33 lib drwxrwxr-x 2 admin admin 4096 Jan 8 14:51 log drwxrwxr-x 2 admin admin 4096 Jan 8 14:51 run drwxrwxr-x 6 admin admin 4096 Jan 8 14:51 store [admin@lhrob312 oceanbase]$ tree store/ store/ ├── clog │ └── 1 ├── ilog ├── slog └── sstable └── block_file 4 directories, 2 files [admin@lhrob312 oceanbase]$ ps -ef|grep ob admin 17740 0 99 14:51 ? 00:00:35 /home/admin/oceanbase/bin/observer -r 127.0.0.1:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4 -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR admin 18337 15142 0 14:51 pts/0 00:00:00 grep --color=auto ob [admin@lhrob312 oceanbase]$ cd [admin@lhrob312 ~]$ [admin@lhrob312 ~]$ netstat -tulnp | grep 288 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:2881 0.0.0.0:* LISTEN 2516/observer tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 2516/observer [admin@lhrob312 ~]$ [admin@lhrob312 ~]$ [admin@lhrob312 ~]$ mysql -h127.1 -uroot -P2881 -p -c -A Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3221225472 Server version: 5.7.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47:29) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '127.0.0.1:2882'; Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (3 min 30.85 sec) MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | SYS | | LBACSYS | | ORAAUDITOR | | test | +--------------------+ 7 rows in set (0.10 sec) MySQL [(none)]> alter user root identified by 'lhr'; grant select on *.* to proxyro;Query OK, 0 rows affected (0.88 sec) MySQL [(none)]> create user proxyro identified by 'lhr'; Query OK, 0 rows affected (0.48 sec) MySQL [(none)]> grant select on *.* to proxyro; Query OK, 0 rows affected (0.62 sec) |
配置obproxy
https://open.oceanbase.com/articles/1100243
obproxy跟OB集群通信是使用sys租户内的一个内部账户proxyro。这个账户需要创建。
obproxy启动后,默认用 root@proxysys 登录,密码为空。需要改密码(通过proxy参数obproxy_sys_password指定)。