环境介绍
环境信息
服务器配置及优化
变更内容请参考实战教程第二章2.4,如何初始化服务器环境(https://open.oceanbase.com/blog/8600144),内容比较详细。
下载软件
从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。
安装软件
使用root用户执行安装:
[root ~] # rpm -ivh oceanbase-ce-3.1.1-4.el7.x86_64.rpm [root ~] # rpm -ivh oceanbase-ce-libs-3.1.1-4.el7.x86_64.rpm [root ~] # rpm -ivh obproxy-3.2.0-1.el7.x86_64.rpm
查看安装后的信息:
[root ~] # 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/timezone_V1.log [root ~] # 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 ~] # 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
创建admin用户
OceanBase建议使用admin进行维护,创建admin用户。
[root ~] # useradd admin [root ~] # passwd admin # 修改admin用户密码
给予admin用户sudo root权限:
[root ~] # cd /etc/sudoers.d/ # 创建admin(文件可随意),并写入如下内容: [root ~] # more admin %admin ALL=(ALL) NOPASSWD: ALL
创建运行目录
[root ~] # mkdir /data
[root ~] # chown admin:admin /data
## 切换到admin用户下执行.
[admin ~]$ mkdir -p /data/{observer01,observer02,observer03,obproxy}
[admin ~]$ mkdir -p /data/observer{01,02,03}/store/{sort_dir,sstable,clog,ilog,slog}
配置lib信息
[admin ~]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/
# 也可以将以上内容写入到admin用户的.bash_profile中,然后执行source ~/.bash_profile生效。
启动OB进程
[admin ~]$ cd /data/observer01/ && /home/admin/oceanbase/bin/observer -r "192.168.211.54:2882:2881;192.168.211.54:3882:3881;192.168.211.54:4882:4881" -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,sys_bkgd_migration_retry_num=3,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone1 -p 2881 -P 2882 -c 1 -d /data/observer01/store -i eth0 -l INFO
[admin ~]$ cd /data/observer02/ && /home/admin/oceanbase/bin/observer -r "192.168.211.54:2882:2881;192.168.211.54:3882:3881;192.168.211.54:4882:4881" -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,sys_bkgd_migration_retry_num=3,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone2 -p 3881 -P 3882 -c 1 -d /data/observer02/store -i eth0 -l INFO
[admin ~]$ cd /data/observer03/ && /home/admin/oceanbase/bin/observer -r "192.168.211.54:2882:2881;192.168.211.54:3882:3881;192.168.211.54:4882:4881" -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,sys_bkgd_migration_retry_num=3,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone3 -p 4881 -P 4882 -c 1 -d /data/observer03/store -i eth0 -l INFO
#以上命令中指定的参数作用可参考obd自动部署过程yaml文件的说明,请移步 https://gitee.com/oceanbase/obdeploy/tree/master/example
[admin ~]$ ps -ef |grep observer # 查看进程信息
bootstrap集群
[admin ~]$ mysql -h192.168.211.54 -uroot -P2881 -p -c -A # 默认空密码
root@192.168.211.54 : (none) 08:27:06> set session ob_query_timeout=1000000000;
root@192.168.211.54 : (none) 08:27:06> alter system bootstrap ZONE 'zone1' SERVER '192.168.211.54:2882' , ZONE 'zone2' SERVER '192.168.211.54:3882' , ZONE 'zone3' SERVER '192.168.211.54:4882';
# 修改root密码
root@192.168.211.54 : (none) 08:27:06> alter user root identified by 'oracle_4U';
root@192.168.211.54 : (none) 08:27:06> create user proxyro identified by 'oracle_4U';
obproxy部署
[admin ~]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/ # 也可以将以上内容写入到admin用户的.bash_profile中,然后执行source ~/.bash_profile生效。
启动OB进程
[admin ~]$ cd /data/observer01/ && /home/admin/oceanbase/bin/observer -r "192.168.211.54:2882:2881;192.168.211.54:3882:3881;192.168.211.54:4882:4881" -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,sys_bkgd_migration_retry_num=3,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone1 -p 2881 -P 2882 -c 1 -d /data/observer01/store -i eth0 -l INFO
[admin ~]$ cd /data/observer02/ && /home/admin/oceanbase/bin/observer -r "192.168.211.54:2882:2881;192.168.211.54:3882:3881;192.168.211.54:4882:4881" -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,sys_bkgd_migration_retry_num=3,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone2 -p 3881 -P 3882 -c 1 -d /data/observer02/store -i eth0 -l INFO
[admin ~]$ cd /data/observer03/ && /home/admin/oceanbase/bin/observer -r "192.168.211.54:2882:2881;192.168.211.54:3882:3881;192.168.211.54:4882:4881" -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,sys_bkgd_migration_retry_num=3,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=50G,enable_syslog_recycle=True,max_syslog_file_count=10 -z zone3 -p 4881 -P 4882 -c 1 -d /data/observer03/store -i eth0 -l INFO
#以上命令中指定的参数作用可参考obd自动部署过程yaml文件的说明,请移步 https://gitee.com/oceanbase/obdeploy/tree/master/example
[admin ~]$ ps -ef |grep observer # 查看进程信息
bootstrap集群
[admin ~]$ mysql -h192.168.211.54 -uroot -P2881 -p -c -A # 默认空密码
root@192.168.211.54 : (none) 08:27:06> set session ob_query_timeout=1000000000;
root@192.168.211.54 : (none) 08:27:06> alter system bootstrap ZONE 'zone1' SERVER '192.168.211.54:2882' , ZONE 'zone2' SERVER '192.168.211.54:3882' , ZONE 'zone3' SERVER '192.168.211.54:4882';
# 修改root密码
root@192.168.211.54 : (none) 08:27:06> alter user root identified by 'oracle_4U';
root@192.168.211.54 : (none) 08:27:06> create user proxyro identified by 'oracle_4U';
obproxy部署
[admin ~]$ mysql -h192.168.211.54 -uroot -P2881 -p -c -A # 默认空密码 root@192.168.211.54 : (none) 08:27:06> set session ob_query_timeout=1000000000; root@192.168.211.54 : (none) 08:27:06> alter system bootstrap ZONE 'zone1' SERVER '192.168.211.54:2882' , ZONE 'zone2' SERVER '192.168.211.54:3882' , ZONE 'zone3' SERVER '192.168.211.54:4882'; # 修改root密码 root@192.168.211.54 : (none) 08:27:06> alter user root identified by 'oracle_4U'; root@192.168.211.54 : (none) 08:27:06> create user proxyro identified by 'oracle_4U';
obproxy部署
创建内部账户
[admin ~]$ mysql -h127.1 -uroot@sys -P2881 -poracle_4U -c -A oceanbase root@192.168.211.54 : (none) 08:27:06> create user proxyro identified by 'oracle_4U'; root@192.168.211.54 : (none) 08:27:06> grant select on oceanbase.* to proxyro; [admin ~]$ cd /data/obproxy [admin ~]$ /home/admin/obproxy-3.2.0/bin/obproxy -p2883 -c obcluster -r "192.168.211.54:2881;192.168.211.54:3881;192.168.211.54:4881" -o "enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false" /home/admin/obproxy-3.2.0/bin/obproxy -p2883 -c obcluster -r 192.168.211.54:2881;192.168.211.54:3881;192.168.211.54:4881 -o enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false listen port: 2883 cluster_name: obcluster rs list: 192.168.211.54:2881;192.168.211.54:3881;192.168.211.54:4881 optstr: enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false
附录
登录
[admin ~]$ mysql -h127.1 -uroot@sys -P2881 -poracle_4U -c -A oceanbase # 登录单节点
[admin ~]$ mysql -h127.1 -uroot@sys#obcluster -P2883 -p -c -A oceanbase # 使用obproxy登录,其中的obcluster,可通过登录单节点后:show parameter like 'cluster'获取到。
卸载
[admin ~]$ kill -9 `pidof observer` `pidof obproxy`
[admin ~]$ sleep 3
[admin ~]$ bin/rm -rf /data/observer{01,02,03} /data/obproxy
单机三节点htop
该图是OBD自动部署运行的htop
该图是OBD自动部署运行的htop