oceanbase环境介绍:
192.168.1.4
192.168.1.3
192.168.1.5
配置三台机器免密:
# 生成密钥对
# ssh-keygen -t rsa
# 复制免登公钥到其它目标机器,修改user和ip
# ssh-copy-id root@{ip}
输入密码
最终确保三台机器之间ssh不需要输入密码
登录其中一台机器192.168.1.4
# mkdir -p /data/oceanbase
# cd /data/oceanbase
#### 数据库配置文件模板
# cat local-example.yaml
oceanbase-ce:
servers:
# Please don't use hostname, only IP can be supported
- 192.168.1.4
- 192.168.1.3
- 192.168.1.5
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /data/observer
# The directory for data storage. The default value is $home_path/store.
# data_dir: /data
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
# redo_dir: /redo
# Please set devname as the network adaptor's name whose ip is in the setting of severs.
# if set severs as "127.0.0.1", please set devname as "lo"
# if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
devname: p8p1
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
zone: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: 8G # The maximum running memory for an observer
system_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
stack_size: 512K
cpu_count: 8
cache_wash_threshold: 1G
__min_full_resource_pool_memory: 268435456
workers_per_cpu_quota: 8
schema_history_expire_time: 1d
# The value of net_thread_count had better be same as cpu's core number.
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_disk_percentage: 20 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
syslog_level: INFO # System log level. The default value is INFO.
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
# root_password: # root user password, can be empty
部署 OceanBase 数据库
# obd cluster deploy ob_test -c local-example.yaml -A
oceanbase-ce-3.1.4 already installed.
+-------------------------------------------------------------------------------------------+
| Packages |
+--------------+---------+-----------------------+------------------------------------------+
| Repository | Version | Release | Md5 |
+--------------+---------+-----------------------+------------------------------------------+
| oceanbase-ce | 3.1.4 | 10000092022071511.el7 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
+--------------+---------+-----------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository install ok
Send /root/.obd/repository/oceanbase-ce/3.1.4/c5cd94f4f190317b6a883c58a26460a506205ce6/etc to /root/.obd/repository/oceanbase-ce/3.1.4/c5cd94f4f190317b6a883c58a26460a506205ce6/etc ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check !!
Try to get lib-repository
oceanbase-ce-libs-3.1.4 already installed.
Remote oceanbase-ce-libs-3.1.4-10000092022071511.el7-6d5437b0cad486b55963f89b8ef3769af7995350 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check ok
ob_test deployed
启动 OceanBase 数据库:
# obd cluster start ob_test
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] (192.168.1.4) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)
[WARN] (192.168.1.4) clog and data use the same disk (/data)
[WARN] (192.168.1.3) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)
[WARN] (192.168.1.3) clog and data use the same disk (/data)
[WARN] (192.168.1.5) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)
[WARN] (192.168.1.5) clog and data use the same disk (/)
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap \
Cluster bootstrap |
Cluster bootstrap ok
Create tenant test ok
Wait for observer init ok
+-------------------------------------------------+
| observer |
+---------------+---------+------+-------+--------+
| ip | version | port | zone | status |
+---------------+---------+------+-------+--------+
| 192.168.1.3 | 3.1.4 | 2881 | zone1 | active |
| 192.168.1.4 | 3.1.4 | 2881 | zone1 | active |
| 192.168.1.5 | 3.1.4 | 2881 | zone1 | active |
+---------------+---------+------+-------+--------+
ob_test running
三台机器上分别安装OceanBase数据库客户端 OBClient
# yum install -y obclient
连接OceanBase数据库(其中任何一台皆可)
# obclient -h192.168.1.3 -P2881 -uroot
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221749761
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)
Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| oceanbase |
| information_schema |
| mysql |
| SYS |
| LBACSYS |
| ORAAUDITOR |
| test |
+--------------------+
7 rows in set (0.092 sec)
obclient [(none)]> use test
Database changed
obclient [test]> show tables;
Empty set (0.005 sec)
obclient [test]> create table test(id int primary key,name varchar(10));
Query OK, 0 rows affected (0.502 sec)
obclient [test]> insert into test values(1,"zhangsan");
Query OK, 1 row affected (0.133 sec)
obclient [test]> insert into test values(2,"lisi");
Query OK, 1 row affected (0.023 sec)
obclient [test]> insert into test values(3,"wangwu");
Query OK, 1 row affected (0.023 sec)
obclient [test]> insert into test values(4,"chenfeng");
Query OK, 1 row affected (0.030 sec)
obclient [test]> insert into test values(5,"liujing");
Query OK, 1 row affected (0.021 sec)
obclient [test]> insert into test values(6,"huangshan");
Query OK, 1 row affected (0.102 sec)
obclient [test]> select * from test;
+----+-----------+
| id | name |
+----+-----------+
| 1 | zhangsan |
| 2 | lisi |
| 3 | wangwu |
| 4 | chenfeng |
| 5 | liujing |
| 6 | huangshan |
+----+-----------+
6 rows in set (0.028 sec)
obclient [test]>
连接其他机器上的oceanbase:
# obclient -h192.168.1.5 -P2881 -uroot
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3222012104
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)
Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [(none)]> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
obclient [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test |
+----------------+
1 row in set (0.002 sec)
查看刚刚创建的表:
obclient [test]> select * from test;
+----+-----------+
| id | name |
+----+-----------+
| 1 | zhangsan |
| 2 | lisi |
| 3 | wangwu |
| 4 | chenfeng |
| 5 | liujing |
| 6 | huangshan |
+----+-----------+
6 rows in set (0.021 sec)
obclient [test]> \q
##obd命令帮助
# obd -h
Usage: obd <command> [options]
Available commands:
cluster Deploy and manage a cluster.
mirror Manage a component repository for OBD.
repo Manage local repository for OBD.
test Run test for a running deployment.
update Update OBD.
Options:
--version show program's version number and exit
-h, --help Show help and exit.
-v, --verbose Activate verbose output.
查看obd管理的集群列表:
# obd cluster list
+--------------------------------------------------------+
| Cluster List |
+---------+----------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+---------+----------------------------+-----------------+
| ob_test | /root/.obd/cluster/ob_test | running |
| test | /root/.obd/cluster/test | configured |
+---------+----------------------------+-----------------+
查看集群状态
# obd cluster display ob_test
Get local repositories and plugins ok
Open ssh connection ok
Cluster status check ok
Connect to observer ok
Wait for observer init ok
+-------------------------------------------------+
| observer |
+---------------+---------+------+-------+--------+
| ip | version | port | zone | status |
+---------------+---------+------+-------+--------+
| 192.168.1.3 | 3.1.4 | 2881 | zone1 | active |
| 192.168.1.4 | 3.1.4 | 2881 | zone1 | active |
| 192.168.1.5 | 3.1.4 | 2881 | zone1 | active |
+---------------+---------+------+-------+--------+
### obd clustern命令帮助
# obd cluster --help
Usage: obd cluster <command> [options]
Available commands:
autodeploy Deploy a cluster automatically by using a simple configuration file.
check4ocp Check Whether OCP Can Take Over Configurations in Use
chst Change Deployment Configuration Style
deploy Deploy a cluster by using the current deploy configuration or a deploy yaml file.
destroy Destroy a deployed cluster.
display Display the information for a cluster.
edit-config Edit the configuration file for a specific deployment.
list List all the deployments.
redeploy Redeploy a started cluster.
reinstall Reinstall a deployed component
reload Reload a started cluster.
restart Restart a started cluster.
start Start a deployed cluster.
stop Stop a started cluster.
tenant Create or drop a tenant.
upgrade Upgrade a cluster.
Options:
-h, --help Show help and exit.
-v, --verbose Activate verbose output.
销毁一个集群:
# obd cluster destroy ob_test
Get local repositories ok
Search plugins ok
Open ssh connection ok
Cluster status check ok
observer work dir cleaning ok
ob_test destroyed
OceanBase 部署中遇到的相关报错:
一.[ERROR] lo fail to ping . Please check configuration `devname`
解决方法:
修改local-example.yaml配置文件里devname: p8p1,此处要求三台服务器的网卡名称必须一致,否则会报如上错。
二.[ERROR] Cluster NTP is out of sync
解决方法:
oceanbase需要用到ntp服务来同步每台机器的服务器时间,需要分别启动三台机器的ntp服务:
# systemctl start ntpd
查看ntp服务状态:
# systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: active (running) since 四 2022-08-25 14:22:29 CST; 21s ago
Process: 26162 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 26163 (ntpd)
Tasks: 1
Memory: 1.4M
CGroup: /system.slice/ntpd.service
└─26163 /usr/sbin/ntpd -u ntp:ntp -g
8月 25 14:22:29 test3 ntpd[26163]: Listen normally on 2 lo 127.0.0.1 UDP 123
8月 25 14:22:29 test3 ntpd[26163]: Listen normally on 3 p8p1 192.168.1.4 UDP 123
8月 25 14:22:29 test3 ntpd[26163]: Listen normally on 4 docker0 172.17.0.1 UDP 123
8月 25 14:22:29 test3 ntpd[26163]: Listen normally on 5 lo ::1 UDP 123
8月 25 14:22:29 test3 ntpd[26163]: Listen normally on 6 p8p1 fe80::edcf:9cb5:2fbe:d875 UDP 123
8月 25 14:22:29 test3 ntpd[26163]: Listening on routing socket on fd #23 for interface updates
8月 25 14:22:29 test3 ntpd[26163]: 0.0.0.0 c016 06 restart
8月 25 14:22:29 test3 ntpd[26163]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
8月 25 14:22:29 test3 ntpd[26163]: 0.0.0.0 c011 01 freq_not_set
8月 25 14:22:37 test3 ntpd[26163]: 0.0.0.0 c614 04 freq_mode
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15498/viewspace-2912004/ ,如需转载,请注明出处,否则将追究法律责任。