实践练习二:手动部署 OceanBase 集群

1,系统版本信息

[root@db01 ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

#系统空间要求

内存不低于10G

磁盘空间不低于100G

2,OB软件下载

https://open.oceanbase.com/softwareCenter/community

[root@db01 ob]# ls
libobclient-2.0.0-2.el7.x86_64.rpm  
ob-deploy-1.0.0-1.el7.x86_64.rpm  
oceanbase-ce-3.1.0-1.el7.x86_64.rpm
obclient-2.0.0-1.el7.x86_64.rpm     
obproxy-3.1.0-1.el7.x86_64.rpm    
oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm

3,软件安装

rpm -ivh oceanbase-ce-*
rpm -ivh obclient-2.0.0-1.el7.x86_64.rpm

4,主机环境设置

/etc/sysctl.conf

net.core.somaxconn = 2048
net.core.netdev_max_backlog = 10000
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.ip_local_port_range = 3500 65535
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_slow_start_after_idle=0

vm.swappiness = 0
vm.min_free_kbytes = 2097152
vm.max_map_count=655360
fs.aio-max-nr=1048576

/etc/security/limits.conf

* soft nofile 655360
* hard nofile 655360
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
* soft stack unlimited
* hard stack unlimited


systemctl disable firewalld 
systemctl stop firewalld
systemctl status firewalld

/etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled

setenforce 0
```shell

\#新建admin用户

新增普通用户 admin

useradd adin
·
# 改用户密码
passwd admin

# 或下面命令指定密码,密码修改为自己的。

echo 'admin:adminPWD123' | chpasswd




### 5,启动OBSERVER
建立相关数据目录
```shell
su - admin
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/oceanbase/lib' >> ~/.bash_profile
. ~/.bash_profile
mkdir -p ~/oceanbase/store/obdemo  /data/obdemo/{sstable,etc3} /redo/obdemo/{clog,ilog,slog,etc2}
for f in {clog,ilog,slog,etc2}; do ln -s /redo/obdemo/$f ~/oceanbase/store/obdemo/$f ; done
for f in {sstable,etc3}; do ln -s /data/obdemo/$f ~/oceanbase/store/obdemo/$f; done

6、启动observer

cd ~/oceanbase 
bin/observer -i ens192 -p 2881 -P 2882 -z zone1 -d ~/oceanbase/store/obdemo -r '192.168.5.200:2882:2881' -c 20210912 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/obdemo/etc3;/redo/obdemo/etc2"
7、进入数据库(初次完成不需要输入密码)
obclient -h 127.0.0.1 -P 2881 -uroot -p -c -A
8、查看当前资源规格及资源池配置(默认是有一个obmysql)
select unit_config_id, name from __all_unit_config;
select resource_pool_id, name from __all_resource_pool;
MySQL [oceanbase]>  select tenant_id,tenant_name,max_cpu,min_cpu,max_memory/1024/1024/1024 from v$unit;
+-----------+-------------+---------+---------+---------------------------+
| tenant_id | tenant_name | max_cpu | min_cpu | max_memory/1024/1024/1024 |
+-----------+-------------+---------+---------+---------------------------+
|         1 | sys         |       5 |     2.5 |            1.199999999255 |
|      1001 | obmysql     |       9 |       9 |            2.500000000000 |
9、利用系统默认的用户登录(系统给的没有密码)
obclient -h 127.0.0.1 -P 2881 -uroot@obmysql  -p -c -A
obclient -h 127.0.0.1 -P 2883 -u root@obmysql -p -c -A oceanbase

14、创建一个单元资源(可选)可跳过

create resource unit my_unit1 max_cpu=1, max_memory='1g', max_iops=128, max_disk_size='5g', max_session_num=64, min_cpu=1, min_memory='1g', min_iops=128;
10、资源池配置(可选)可跳过
create resource pool my_pool1 unit='my_unit1', unit_num=1, zone_list=('zone1');
11、创建一个租户
create tenant my_tenant1 resource_pool_list=('obmysql');
12、创建数据表
create table user1(id int(4) primary key, name varchar(20));
13、创建内容
insert into user1(id, name) values(1, '张三');
insert into user1(id, name) values(2, '李四');

MySQL [test]> select * from user1;
+----+--------+
| id | name   |
+----+--------+
|  1 | 张三 |
|  2 | 李四 |
+----+--------+
2 rows in set (0.002 sec)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值