当前位置:   article > 正文

linux安装OceanBase数据库_oceanbaselinux

oceanbaselinux

1.下载OceanBase数据库安装包

OceanBase官网下载页面

在这里插入图片描述
在这里插入图片描述

2. 解压安装包并安装OBD

tar -xzf oceanbase-all-in-one.4.0.0.0-beta-100120221102135736.el7.x86_64.tar.gz
cd oceanbase-all-in-one/bin/
安装obd
./install.sh
设置环境变量
source /root/.oceanbase-all-in-one/bin/env.sh
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3.检测OBD是否安装成功

执行 which obd 和 which obclient 检测是否安装成功,如果可以找到 obd 和 obclient 则表示安装
[root@test .obd]# which obd
/root/.oceanbase-all-in-one/obd/usr/bin/obd
[root@test .obd]# which obclient
/root/.oceanbase-all-in-one/obclient/u01/obclient/bin/obclient
  • 1
  • 2
  • 3
  • 4
  • 5

4. 启动 OceanBase 数据库

第一种方式:这是官网提供的快速部署启动单实例OceanBase的数据库
(1)部署并启动 OceanBase 数据库
obd demo
(2)使用 OBClient 客户端连接到 OceanBase 数据库
obclient -h127.0.0.1 -uroot -P2881


第二种方式:自定义部署启动单实例OceanBase的数据库
(1)配置文件:oceanbase-jamy.yaml,内容如下
#===================================================
## Only need to configure when remote login is required
# user:
#   username: your username
#   password: your password if need
#   key_file: your ssh-key file path if need
#   port: your ssh port, default 22
#   timeout: ssh connection timeout (second), default 30
oceanbase-ce:
  servers:
    # Please don't use hostname, only IP can be supported
  - 127.0.0.1
  global:
    # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
    home_path: /root/oceanbase-jamy
    # 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: lo
    # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
    mysql_port: 2888
    # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
    rpc_port: 2889
    # Defines the zone for an observer. The default value is zone1.
    zone: zone1
    # The maximum running memory for an observer. When ignored, autodeploy calculates this value based on the current server available resource.
    memory_limit: 6G
    # The percentage of the maximum available memory to the total memory. This value takes effect only when memory_limit is 0. The default value is 80.
    # memory_limit_percentage: 80
    # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. Autodeploy calculates this value based on the current server available resource.
    system_memory: 3G
    enable_syslog_recycle: true
    enable_syslog_wf: false
    max_syslog_file_count: 4
    production_mode: false
    __min_full_resource_pool_memory: 1073741824
    cpu_count: 2
    datafile_size: 5G
    log_disk_size: 5G
    # The size of a data file. When ignored, autodeploy calculates this value based on the current server available resource.
    # datafile_size: 200G
    # The size of disk space used by the clog files. When ignored, autodeploy calculates this value based on the current server available resource.
    # log_disk_size: 66G
    # System log level. The default value is WDIAG.
    # syslog_level: WDIAG
    # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true. The default value for autodeploy mode is false.
    # enable_syslog_wf: false
    # Enable auto system log recycling or not. The default value is false. The default value for autodeploy mode is on.
    # enable_syslog_recycle: true
    # The maximum number of reserved log files before enabling auto recycling. When set to 0, no logs are deleted. The default value for autodeploy mode is 4.
    # max_syslog_file_count: 4
    # Cluster name for OceanBase Database. The default value is obcluster. When you deploy OceanBase Database and obproxy, this value must be the same as the cluster_name for obproxy.
    #appname: obcluster
    # Password for root. The default value is empty.
    #root_password:
    # Password for proxyro. proxyro_password must be the same as observer_sys_password. The default value is empty.
    # proxyro_password:
#===================================================
注意:你的磁盘大小需要大于memory_limit+system_memory+__min_full_resource_pool_memory+datafile_size+log_disk_size的总和,这里就是要大于20G(6G+3G+1G+5G+5G),还有一点要注意的是memory_limit的大小会决定OceanBase数据库能否成功启动,我这里虚拟机linux的内存大小给的是10G,除去系统本身用去的内存,实际可用的的内存就没有10G了,我第一次启动就失败了,截图如下:报了一个内存不够的报错提示,所以我把配置文件中memory_limit的值调整为6G,最后启动成功!!!

(2)部署
obd cluster deploy 集群名 -c  yaml部署文件路径
例如:
obd cluster deploy  oceanbase-jamy  -c  /opt/oceanbase-all-in-one/conf/autodeploy/oceanbase-jamy.yaml

(3)启动数据库
obd cluster start  oceanbase-jamy

(4)连接数据库
obclient -h127.0.0.1 -uroot@sys -P2888
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83

在这里插入图片描述

自定义部署启动过程如下所示:

[root@localhost ~]# obd cluster deploy  oceanbase-jamy  -c  /opt/oceanbase-all-in-one/conf/autodeploy/oceanbase-jamy.yaml
+--------------------------------------------------------------------------------------------+
|                                          Packages                                          |
+--------------+---------+------------------------+------------------------------------------+
| Repository   | Version | Release                | Md5                                      |
+--------------+---------+------------------------+------------------------------------------+
| oceanbase-ce | 4.1.0.0 | 100000202023040520.el7 | d598937b1cfb1df85e2c2231acf024e4994db533 |
+--------------+---------+------------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-4.1.0.0-100000202023040520.el7-d598937b1cfb1df85e2c2231acf024e4994db533 repository install ok
Remote oceanbase-ce-4.1.0.0-100000202023040520.el7-d598937b1cfb1df85e2c2231acf024e4994db533 repository lib check !!
Try to get lib-repository
Remote oceanbase-ce-libs-4.1.0.0-100000202023040520.el7-5d24535db655b4dce6fc62aedc4d0e867225792a repository install ok
Remote oceanbase-ce-4.1.0.0-100000202023040520.el7-d598937b1cfb1df85e2c2231acf024e4994db533 repository lib check ok
oceanbase-jamy deployed
Trace ID: 3b3eab88-07a1-11ee-a9ec-000c291d4602
If you want to view detailed obd logs, please run: obd display-trace 3b3eab88-07a1-11ee-a9ec-000c291d4602
[root@localhost ~]# obd cluster list
+----------------------------------------------------------------------+
|                             Cluster List                             |
+----------------+-----------------------------------+-----------------+
| Name           | Configuration Path                | Status (Cached) |
+----------------+-----------------------------------+-----------------+
| demo           | /root/.obd/cluster/demo           | stopped         |
| oceanbase-jamy | /root/.obd/cluster/oceanbase-jamy | deployed        |
+----------------+-----------------------------------+-----------------+
Trace ID: 3e8fd852-07a1-11ee-b05e-000c291d4602
If you want to view detailed obd logs, please run: obd display-trace 3e8fd852-07a1-11ee-b05e-000c291d4602
[root@localhost oceanbase-jamy]# obd cluster start oceanbase-jamy
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] OBD-1012: (127.0.0.1) clog and data use the same disk (/)

Start observer ok
observer program health check ok
Connect to observer ok
Initialize oceanbase-ce ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.1.0.0 | 2888 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2888 -uroot -Doceanbase -A

oceanbase-jamy running
Trace ID: 6e7cc6b0-07a1-11ee-a3f9-000c291d4602
If you want to view detailed obd logs, please run: obd display-trace 6e7cc6b0-07a1-11ee-a3f9-000c291d4602
[root@localhost oceanbase-jamy]# obclient -h127.0.0.1 -P2888 -uroot
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487617
Server version: OceanBase_CE 4.1.0.0 (r100000202023040520-0765e69043c31bf86e83b5d618db0530cf31b707) (Built Apr  5 2023 20:26:14)

Copyright (c) 2000, 2018, 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           |
+--------------------+
| information_schema |
| LBACSYS            |
| mysql              |
| oceanbase          |
| ORAAUDITOR         |
| SYS                |
| test               |
+--------------------+
7 rows in set (0.003 sec)

obclient [(none)]>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81

5. 登录OceanBase 数据库

本地登录(刚安装完登录root用户默认密码为空即直接回车即可连接上数据库,但是新版不是为空,但是会直接在命令行启动窗口给提示临时登录密码是多少)
obclient -h127.0.0.1 -uroot -P2881

创建数据库
create database test2 default charset utf8mb4;

创建用户
create user jamy@'%' identified by '123456';

修改用户密码
alter user jamy@'%' identified by 'jamy';

授权用户
grant all privileges on *.* to jamy@'%';
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

在这里插入图片描述

6. 客户端连接

(1)navicat连接OceanBase
能连mysql的客户端都可以连接OceanBase,只不过端口号需要换成2881
在这里插入图片描述
(2)SQLyog连接OceanBase
在这里插入图片描述
在这里插入图片描述
(3)heidisql连接OceanBase

在这里插入图片描述
在这里插入图片描述
(4)OceanBase Developer Center连接OceanBase
odc客户端是OceanBase官方图形化客户端
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

7.OceanBase服务相关命令

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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

8.删除集群

确认集群不再需要后方可删除!!!

[root@localhost ~]# obd cluster list
+----------------------------------------------------------------------+
|                             Cluster List                             |
+----------------+-----------------------------------+-----------------+
| Name           | Configuration Path                | Status (Cached) |
+----------------+-----------------------------------+-----------------+
| demo           | /root/.obd/cluster/demo           | destroyed       |
| oceanbase-jamy | /root/.obd/cluster/oceanbase-jamy | running         |
| oceanbase-song | /root/.obd/cluster/oceanbase-song | stopped         |
+----------------+-----------------------------------+-----------------+
[root@localhost ~]# obd cluster stop oceanbase-song
Get local repositories ok
Search plugins ok
Open ssh connection ok
Stop prometheus ok
Stop obagent ok
Stop observer ok
Stop grafana ok
oceanbase-song stopped
Trace ID: ef1b9ff2-1df0-11ee-a4e5-000c291d4602
If you want to view detailed obd logs, please run: obd display-trace ef1b9ff2-1df0-11ee-a4e5-000c291d4602
[root@localhost ~]# obd cluster destroy oceanbase-song
Get local repositories ok
Search plugins ok
Open ssh connection ok
Cluster status check ok
prometheus work dir cleaning ok
obagent work dir cleaning ok
observer work dir cleaning ok
grafana work dir cleaning ok
oceanbase-song destroyed
Trace ID: 42585b2e-1df1-11ee-a3e6-000c291d4602
If you want to view detailed obd logs, please run: obd display-trace 42585b2e-1df1-11ee-a3e6-000c291d4602
[root@localhost ~]# obd cluster list
+----------------------------------------------------------------------+
|                             Cluster List                             |
+----------------+-----------------------------------+-----------------+
| Name           | Configuration Path                | Status (Cached) |
+----------------+-----------------------------------+-----------------+
| demo           | /root/.obd/cluster/demo           | destroyed       |
| oceanbase-jamy | /root/.obd/cluster/oceanbase-jamy | running         |
| oceanbase-song | /root/.obd/cluster/oceanbase-song | destroyed       |
+----------------+-----------------------------------+-----------------+
[root@localhost /]# cd /root/.obd/cluster
[root@localhost cluster]# ls
demo  oceanbase-jamy  oceanbase-song
[root@localhost cluster]# rm -rf demo
[root@localhost cluster]# rm -rf oceanbase-song
[root@localhost cluster]# obd cluster list
+----------------------------------------------------------------------+
|                             Cluster List                             |
+----------------+-----------------------------------+-----------------+
| Name           | Configuration Path                | Status (Cached) |
+----------------+-----------------------------------+-----------------+
| oceanbase-jamy | /root/.obd/cluster/oceanbase-jamy | running         |
+----------------+-----------------------------------+-----------------+
Trace ID: 7886c5cc-1df2-11ee-a16d-000c291d4602
If you want to view detailed obd logs, please run: obd display-trace 7886c5cc-1df2-11ee-a16d-000c291d4602

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59

9.部署ODC的web端服务(docker容器部署)

这里部署ODC的web端服务是使用官网推荐的docker镜像启动docker容器(web容器)
(1)安装docker
docker安装参考这里教程,根据自己Linux的版本选择性安装

(2)拉取odc的docker镜像

docker pull oceanbase/odc:4.2.2
  • 1

(3)创建挂载目录

mkdir -p /var/log/odc  /var/data/odc
  • 1

(4)启动容器

docker run -v /var/log/odc:/opt/odc/log   -v /var/data/odc:/opt/odc/data \
-d -i --net host --cpu-period 100000 --cpu-quota 400000 --memory 6G --name "obodc" \
-e "DATABASE_HOST=192.168.225.49" \
-e "DATABASE_PORT=2888" \
-e "DATABASE_USERNAME=jamy@sys" \
-e "DATABASE_PASSWORD=123456" \
-e "DATABASE_NAME=odc_oceanbase" \
-e "ODC_PROFILE_MODE=alipay" \
-e "ODC_ADMIN_INITIAL_PASSWORD=ACbc214325%#@" \
oceanbase/odc:4.2.2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

说明:
–net host 共享宿主机的网络
–memory 设置docker容器内存的最大使用内存(根据你内存大小的实际情况,但是不能太小)
DATABASE_HOST 设置你的Oeacanbase数据库的IP地址
DATABASE_PORT 设置你的Oeacanbase数据库的端口号
DATABASE_USERNAME 设置你的Oeacanbase数据库的用户(格式是 用户名@租户名#集群名)
DATABASE_PASSWORD 设置你的Oeacanbase数据库的用户密码(这里就是用户jamy的密码)
DATABASE_NAME 设置ODC的web端连接的Oeacanbase数据库名,如果该数据库不存在,需要先创建
ODC_PROFILE_MODE 默认为alipay
ODC_ADMIN_INITIAL_PASSWORD 这个就是你首次访问ODC的web端的登录密码,登录用户名默认为admin

()访问ODC的web版
这里搭建的ODC的web版非常适用于团队使用,只要登录浏览器就可以访问,启动容器显示如下,表示服务搭建成功
访问地址:http://容器所在的宿主机:8989
在这里插入图片描述
在这里插入图片描述
团队空间
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
个人空间
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
选择表查看表结构
在这里插入图片描述
在这里插入图片描述
选择表查看表数据
在这里插入图片描述
打开sql查询窗口
在这里插入图片描述
在这里插入图片描述

10.部署ODC的web端服务(直接在linux下部署)

ODC的web客户端是使用Java编写的,所以需要在Linux安装jdk,版本为1.8

(1)配置环境变量
vim /etc/profile,在文件末尾添加如下内容后执行source /etc/profie使得新的环境变量生效

export ODC_JVM_TRY_USE_JDK=1
export ODC_ADMIN_INITIAL_PASSWORD=ACbc214325%#@
export ODC_PROFILE_MODE=alipay
export DATABASE_PORT=2888
export DATABASE_NAME=odc_oceanbase
export DATABASE_USERNAME=jamy@sys
export DATABASE_HOST=192.168.225.49
export DATABASE_PASSWORD=123456
export OLDPWD=/opt/odc
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

(2)创建数据库
在连接的数据库创建odc_oceanbase,建库语句如下:

CREATE DATABASE odc_oceanbase DEFAULT CHARSET utf8mb4;
  • 1

(3)将odc-web.zip压缩包解压到/opt目录下即可(odc-web.zip如果有需要可以@我)
在这里插入图片描述
(4)启动odc,执行如下命令
cd /opt/odc/bin/
sh start-odc.sh (直接在当前窗口运行,窗口关了,odc也就停止运行了)
或者
sh nohup-start-odc.sh (后台运行,适合长期运行服务)

在这里插入图片描述

如何确定启动是否成功
一是执行命令ps -ef|grep java查看服务进程
在这里插入图片描述
二是查看日志
tail -10f /opt/odc/log/odc.log
在这里插入图片描述

注意:odc使用java编写,所以必须安装jdk才能使用,openjdk也可以,版本是1.8

(5)连接web客户端
登录地址:http://部署odc的Linux的IP地址:端口号,端口号也是可以在环境变量里设置的,默认是8989,我这里的访问地址是192.168.225.68:8989,
登录用户是admin
密码就是(1)中设置的ACbc214325%#@,密码设置规则如下,这是设置的密码不符合密码规则的提示,登录成功后可以修改,但也要符合密码约束规则,下面有一个修改的截图
登录进去具体操作大家可以自己研究研究,这里不做过多讲述。

Bean create failed, beanName=odcServer, message=Error creating bean with name 'odcServer': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metadbMigrate': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Illegal password, please check your password, 
a valid password should:
1. has length between 8~32;
2. contains at least 2 number;
3. contains at least 2 alpha;
4. contains at least 2 special character(._+@#$%);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/385449
推荐阅读
相关标签
  

闽ICP备14008679号