1. 准备工作
准备工作参考:https://www.cnblogs.com/haha029/p/17336622.html 中的“准备工作”
初始化基础环境:创建admin用户、配置ssh互信、修改内核、修改会话变量、配置防火墙、配置时钟同步。
2. 部署OceanBase集群
2.1 安装oceanbase-ce软件包
[admin]# sudo rpm -ivh oceanbase-ce-*.rpm
Preparing... ################################# [100%]
Updating / installing...
1:oceanbase-ce-libs-4.0.0.0-1000002################################# [ 50%]
2:oceanbase-ce-4.0.0.0-100000272022################################# [100%]
[admin]# sudo chown -R admin:admin /home/admin/oceanbase
2.2 创建相应的目录
提示:生产环境要求data和redo目录是两个独立的物理磁盘,或者最低要求是两个独立的逻辑盘。
[admin]# mkdir -p /data/observer/store/ob_cluster/{clog,ilog,slog,etc2}
[admin]# mkdir -p /data/observer/store/ob_cluster/{sstable,etc3}
2.3 启动observer进程
192.168.1.71端:
[admin]# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib" >> .bashrc
[admin]# source .bashrc
[admin]# cd /home/admin/oceanbase && bin/observer -i ens33 -p 2881 -P 2882 -z zone1 -d /data/observer/store/ob_cluster -r '192.168.1.71:2882:2881;192.168.1.72:2882:2881;192.168.1.73:2882:2881' -c 1 -n ob_cluster -o "memory_limit=6G,cache_wash_threshold=1G,system_memory=1G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/observer/store/ob_cluster/etc3;/data/observer/store/ob_cluster/etc2"
192.168.1.72端:
[admin]# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib" >> .bashrc
[admin]# source .bashrc
[admin]# cd /home/admin/oceanbase && bin/observer -i ens33 -p 2881 -P 2882 -z zone2 -d /data/observer/store/ob_cluster -r '192.168.1.71:2882:2881;192.168.1.72:2882:2881;192.168.1.73:2882:2881' -c 1 -n ob_cluster -o "memory_limit=6G,cache_wash_threshold=1G,system_memory=1G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/observer/store/ob_cluster/etc3;/data/observer/store/ob_cluster/etc2"
192.168.1.73端:
[admin]# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib" >> .bashrc
[admin]# source .bashrc
[admin]# cd /home/admin/oceanbase && bin/observer -i ens33 -p 2881 -P 2882 -z zone3 -d /data/observer/store/ob_cluster -r '192.168.1.71:2882:2881;192.168.1.72:2882:2881;192.168.1.73:2882:2881' -c 1 -n ob_cluster -o "memory_limit=6G,cache_wash_threshold=1G,system_memory=1G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/observer/store/ob_cluster/etc3;/data/observer/store/ob_cluster/etc2"
2.4 检查observer服务以及相关端口
sql_port: 2881
rpc_port: 2882
192.168.1.71端:
[admin]# ps -ef | grep observer | grep -v grep
admin 34022 1 99 Apr24 ? 1-04:09:15 bin/observer -i ens33 -p 2881 -P 2882 -z zone1 -d /data/observer/store/ob_cluster -r 192.168.1.71:2882:2881;192.168.1.72:2882:2881;192.168.1.73:2882:2881 -c 1 -n ob_cluster -o memory_limit=6G,cache_wash_threshold=1G,system_memory=1G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/observer/store/ob_cluster/etc3;/data/observer/store/ob_cluster/etc2
[admin]# ss -ant | egrep "2881|2882" | grep LISTEN
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2882 *:*
192.168.1.72端:
[admin]# ps -ef | grep observer | grep -v grep
admin 34022 1 99 Apr24 ? 1-04:09:15 bin/observer -i ens33 -p 2881 -P 2882 -z zone2 -d /data/observer/store/ob_cluster -r 192.168.1.71:2882:2881;192.168.1.72:2882:2881;192.168.1.73:2882:2881 -c 1 -n ob_cluster -o memory_limit=6G,cache_wash_threshold=1G,system_memory=1G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/observer/store/ob_cluster/etc3;/data/observer/store/ob_cluster/etc2
[admin]# ss -ant | egrep "2881|2882" | grep LISTEN
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2882 *:*
192.168.1.73端:
[admin]# ps -ef | grep observer | grep -v grep
admin 34022 1 99 Apr24 ? 1-04:09:15 bin/observer -i ens33 -p 2881 -P 2882 -z zone3 -d /data/observer/store/ob_cluster -r 192.168.1.71:2882:2881;192.168.1.72:2882:2881;192.168.1.73:2882:2881 -c 1 -n ob_cluster -o memory_limit=6G,cache_wash_threshold=1G,system_memory=1G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/observer/store/ob_cluster/etc3;/data/observer/store/ob_cluster/etc2
[admin]# ss -ant | egrep "2881|2882" | grep LISTEN
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2881 *:*
LISTEN 0 1024 *:2882 *:*
2.5 OceanBase集群初始化
连接任意一节点(默认无密码)
[admin]# obclient -h127.0.0.1 -P2881 -uroot@sys -p -A
obclient [(none)]> set session ob_query_timeout=1000000000;
Query OK, 0 rows affected (0.014 sec)
obclient [(none)]> alter system bootstrap ZONE 'zone1' SERVER '192.168.1.71:2882', ZONE 'zone2' SERVER '192.168.1.72:2882', ZONE 'zone3' SERVER '192.168.1.73:2882';
Query OK, 0 rows affected (1 min 18.640 sec)
2.6 查看OceanBase集群节点信息
obclient [oceanbase]> select zone,id,svr_ip,svr_port,inner_port,status,start_service_time,stop_time from __all_server;
+-------+----+--------------+----------+------------+--------+--------------------+-----------+
| zone | id | svr_ip | svr_port | inner_port | status | start_service_time | stop_time |
+-------+----+--------------+----------+------------+--------+--------------------+-----------+
| zone1 | 1 | 192.168.1.71 | 2882 | 2881 | ACTIVE | 1682332392218402 | 0 |
| zone2 | 2 | 192.168.1.72 | 2882 | 2881 | ACTIVE | 1682332393197284 | 0 |
| zone3 | 3 | 192.168.1.73 | 2882 | 2881 | ACTIVE | 1682332396105272 | 0 |
+-------+----+--------------+----------+------------+--------+--------------------+-----------+
2.7 修改密码
使用root@sys用户连接
[admin]# obclient -h127.0.0.1 -P2881 -D oceanbase -uroot@sys -p -A
修改root用户密码
obclient [oceanbase]> alter user root identified by 'OceanBase010';
创建proxyro用户,obproxy连接oceanbase时使用
obclient [oceanbase]> grant select on oceanbase.* to proxyro identified by 'OceanBase010';
3 安装obproxy
3.1 安装obproxy软件包
[admin]# sudo rpm -ivh obproxy-ce-4.0.0-5.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:obproxy-ce-4.0.0-5.el7 ################################# [100%]
3.2 启动obproxy服务
[admin]# cd /home/admin/obproxy-4.0.0 && bin/obproxy -r "192.168.1.71:2881;192.168.1.72:2881;192.168.1.73:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c ob_cluster
bin/obproxy -r 192.168.1.71:2881;192.168.1.72:2881;192.168.1.73:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c ob_cluster
rs list: 192.168.1.71:2881;192.168.1.72:2881;192.168.1.73:2881
listen port: 2883
optstr: enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false
cluster_name: ob_cluster
3.3 修改proxy密码
用户名:root@proxysys,端口:2883,初始密码:空
[admin]# mysql -h 192.168.1.71 -P2883 -u root@proxysys -p
mysql> show proxyconfig like '%sys_password%';
+------------------------+-------+--------------------------------+-------------+---------------+
| name | value | info | need_reboot | visible_level |
+------------------------+-------+--------------------------------+-------------+---------------+
| observer_sys_password1 | | password for observer sys user | false | SYS |
| observer_sys_password | | password for observer sys user | false | SYS |
| obproxy_sys_password | | password for obproxy sys user | false | SYS |
+------------------------+-------+--------------------------------+-------------+---------------+
mysql> alter proxyconfig set obproxy_sys_password='OceanBase010';
Query OK, 0 rows affected (0.05 sec)
mysql> alter proxyconfig set observer_sys_password='OceanBase010';
Query OK, 0 rows affected (0.05 sec)
3.4 通过obproxy连接oceanbase集群
[admin]# mysql -h192.168.1.71 -P2883 -D oceanbase -uroot@sys#ob_cluster -p -A
mysql> show processlist;
+------------+---------+--------------------+-----------+---------+------+--------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------------+---------+--------------------+-----------+---------+------+--------+------------------+
| 3221752263 | root | 192.168.1.71:44346 | oceanbase | Query | 0 | ACTIVE | show processlist |
| 3221487776 | proxyro | 192.168.1.71:53746 | oceanbase | Sleep | 5 | SLEEP | NULL |
+------------+---------+--------------------+-----------+---------+------+--------+------------------+
mysql> show full processlist;
+------------+---------+--------+--------------------+-----------+---------+------+--------+-----------------------+--------------+------+----------------------+
| Id | User | Tenant | Host | db | Command | Time | State | Info | Ip | Port | Proxy_sessid |
+------------+---------+--------+--------------------+-----------+---------+------+--------+-----------------------+--------------+------+----------------------+
| 3221752263 | root | sys | 192.168.1.71:44346 | oceanbase | Query | 0 | ACTIVE | show full processlist | 192.168.1.72 | 2881 | NULL |
| 3221890762 | proxyro | sys | 192.168.1.71:45410 | oceanbase | Sleep | 1 | SLEEP | NULL | 192.168.1.72 | 2881 | 13882347256012800205 |
| 3221890799 | NULL | | 192.168.1.73:2882 | oceanbase | Sleep | 0 | INIT | NULL | 192.168.1.72 | 2881 | 1 |
+------------+---------+--------+--------------------+-----------+---------+------+--------+-----------------------+--------------+------+----------------------+