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)