实践练习二(必选):手动部署 OceanBase 集群

练习目的

本次练习目的掌握 OceanBase 集群的手动部署技能,理解进程的相关目录、集群初始化、OBProxy和 OB 集群关系等。
练习条件
有笔记本或服务器,内存至少12G 。
练习内容
请记录并分享下列内容:
(必选)手动部署一个 OB 单副本集群,包括一个 OBProxy 节点。
(必选)创建一个业务租户、一个业务数据库,以及一些表等。
(可选)如果单台服务器内存有32G,或者有三台服务器,改为部署一个 OB 三副本集群,包括一个 OBProxy 节点。
(可选)如果有三台服务器并且服务器内存有 32 G,可以单服务器内启动 2 个节点,实现 1-1-1 扩容到 2-2-2 。
参考资料
社区版官网-文档-学习中心-入门教程:如何手动部署 OceanBase 集群 51
社区版官网-博客-入门实战:如何手动部署 OceanBase 集群 42
教程视频:【2-4-如何手动部署OceanBase三副本集群.mp4] 20
练习要求
请用文章记录实践练习的环境、过程和问题(可选)、总结等,图文并茂。如果企业内部有安全限制,可以对 IP 、 密码等打码或者修改。如果不允许截图,可以用文字适当补充说明。
分享的文章行文语句通顺,有条理,字数不少于 500 字。
发布:OceanBase 社区版官网问答区或社区版博客(准备word 版本稿件给运营 @Hope,钉钉:hopelee21@dingtalk.com),也可以在CSDN、开源中国、Itpub、知乎等技术社区发布,在问答区附上作业链接及简要说明。

软件下载:
https://open.oceanbase.com/softwareCenter/community
下载5个软件,分别是(其中包括obclient):
libobclient-2.0.2-2.el7.x86_64.rpm
obclient-2.0.2-3.el7.x86_64.rpm
obproxy-ce-3.2.3-2.el7.x86_64.rpm
oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm
oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm
部署参考:https://open.oceanbase.com/articles/8600151

本次为单节点部署

一、初始化安装环境:

参考:https://open.oceanbase.com/blog/8600144

OceanBase 数据库是单进程软件,需要访问网络,需要打开多个文件以及开启很多 TCP 连接,所以需要修改内核参数和用户会话设置。
注意:OBProxy 软件如果独立服务器部署的话,也按这个要求初始化服务器环境。
内核参数修改
修改配置文件。

vim /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

修改会话变量设置

vi /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
ulimit -a

关闭防火墙和 SELinux

systemctl status firewalld
systemctl disable firewalld
systemctl stop firewalld
systemctl status firew

vi /etc/selinux/config
SELINUX=disabled
setenforce 0

配置安装用户

useradd admin
admin用户sudo权限
#方法一:admin 加到用户组 wheel 里。
[root@obce00 ~]# usermod admin -G wheel
[root@obce00 ~]# id admin
uid=1000(admin) gid=1000(admin) groups=1000(admin),10(wheel)

#方法二:admin 添加到  /etc/sudoers 文件中
[root@obce00 ~]# cat /etc/sudoers |grep wheel
Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL
%wheel        ALL=(ALL)       NOPASSWD: ALL
vim /etc/sudoers
 Allow root to run any commands anywhere
admin    ALL=(ALL)       ALL

#方法三:给予admin用户sudo root权限:
[root ~] # cd /etc/sudoers.d/ 
 创建admin(文件可随意),并写入如下内容: 
[root ~] # more admin 
%admin ALL=(ALL) NOPASSWD: ALL
sudo date

二、安装

1.软件安装

[root@jt-t-rl79-tyghwsgl-1 admin]# rpm -ivh obproxy-ce-3.2.3-2.el7.x86_64.rpm
警告:obproxy-ce-3.2.3-2.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID e9b4a7aa: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:obproxy-ce-3.2.3-2.el7           ################################# [100%]
[root@jt-t-rl79-tyghwsgl-1 admin]# rpm -ivh oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:oceanbase-ce-libs-3.1.4-100000920################################# [100%]
[root@jt-t-rl79-tyghwsgl-1 admin]# rpm -ivh oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm      
准备中...                          ################################# [100%]
正在升级/安装...
   1:oceanbase-ce-3.1.4-10000092022071################################# [100%]

2.初始化数据,日志目录

#公司服务器,这里隐去目录名!!
mkdir ***/data
mkdir ***/redo
chown admin:admin /data
chown admin:admin /redo
su - admin
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

(可选)清理目录和数据
第一次部署不需要执行这步。
这步主要是用于后面安装部署失败后,需要清空目录和数据重新部署。

kill -9 `pidof observer`
/bin/rm -rf ~/oceanbase/store/obdemo/*/*
检查目录结构,跟下面一致。
tree ~/oceanbase/store/ /data/ /redo/
输出:
[admin@obce02 ~]$ tree ~/oceanbase/store/ /data/ /redo/
/home/admin/oceanbase/store/
└── obdemo
    ├── clog -> /redo/obdemo/clog
    ├── etc2 -> /redo/obdemo/etc2
    ├── etc3 -> /data/obdemo/etc3
    ├── ilog -> /redo/obdemo/ilog
    ├── slog -> /redo/obdemo/slog
    └── sstable -> /data/obdemo/sstable
/data/
└── obdemo
    ├── etc3
    └── sstable
/redo/
└── obdemo
    ├── clog
    ├── etc2
    ├── ilog
    └── slog
15 directories, 0 files

3.启动ob-server

[root@jt-t-rl79-tyghwsgl-1 ob]# su - admin
上一次登录:四 11月 24 09:19:04 CST 2022pts/0 上
[admin@jt-t-rl79-tyghwsgl-1 ~]$ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/oceanbase/lib' >> ~/.bash_profile
[admin@jt-t-rl79-tyghwsgl-1 ~]$ . ~/.bash_profile

#启动ob server(ip隐掉了)

cd ~/oceanbase && bin/observer -i ens192 -p 2881 -P 2882 -z zone1 -d ~/oceanbase/store/obdemo -r '****: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"

#检查集群状态:

[admin@jt-t-rl79-tyghwsgl-1 oceanbase]$ ps -ef|grep obse
admin      7558      1 86 09:21 ?        00:00:28 bin/observer -i ens192 -p 2881 -P 2882 -z zone1 -d /home/admin/oceanbase/store/obdemo -r ****: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
admin      8184   7165  0 09:22 pts/0    00:00:00 grep --color=auto obse
[admin@jt-t-rl79-tyghwsgl-1 oceanbase]$
[admin@jt-t-rl79-tyghwsgl-1 oceanbase]$ netstat -ntlp|grep ob
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:2881            0.0.0.0:*               LISTEN      7558/bin/observer   
tcp        0      0 0.0.0.0:2882            0.0.0.0:*               LISTEN      7558/bin/observer  

ps -ef |grep observer

#多台机器分别启动, 每个机器的启动参数大部分一样,只有少数不一样,需要特别留意

cd ~/oceanbase && bin/observer -i eth0 -p 2881 -P 2882 -z zone1 -d ~/oceanbase/store/obdemo -r '172.20.249.52:2882:2881;172.20.249.49:2882:2881;172.20.249.51: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" -d ~/oceanbase/store/obdemo

cd ~/oceanbase && bin/observer -i eth0 -p 2881 -P 2882 -z zone2 -d ~/oceanbase/store/obdemo -r '172.20.249.52:2882:2881;172.20.249.49:2882:2881;172.20.249.51: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" -d ~/oceanbase/store/obdemo

cd ~/oceanbase && bin/observer -i eth0 -p 2881 -P 2882 -z zone3 -d ~/oceanbase/store/obdemo -r '172.20.249.52:2882:2881;172.20.249.49:2882:2881;172.20.249.51: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" -d ~/oceanbase/store/obdemo


如果三个节点机型都一致,那么启动参数里只有一个参数不一样,就是 -z 指定该节点是哪个 zone 。三个 zone 的三个节点初始化为一个三副本集群。后面 -o 参数不是必须的。这里主要是测试机器内存不足,所以需要指定一些影响内存的参数。如果您机器内存足够(如大于64G),则可以不需要 -o 参数部分。
检查三个节点进程启动正常,主要看端口监听是否正常。在中控机上批量查询:
[admin@obce00 oceanbase-ce]$ for OceanBase in $IPS;do echo $ob; ssh $ob "netstat -ntlp"; done

4.集群自举(初始化)

执行bootstrap

[admin@jt-t-rl79-tyghwsgl-1 ~]$ ll
总用量 272576
-rw------- 1 root  root     866256 11月 24 09:52 libobclient-2.0.2-2.el7.x86_64.rpm
-rw------- 1 root  root  181903628 11月 24 09:46 obclient-2.0.2-3.el7.x86_64.rpm
drwxr-xr-x 3 admin admin        17 11月 24 08:46 obproxy-3.2.3
-rw------- 1 root  root    9911060 11月 23 15:57 obproxy-ce-3.2.3-2.el7.x86_64.rpm
drwxr-xr-x 8 admin admin        74 11月 24 09:21 oceanbase
-rw------- 1 root  root   49601860 11月 23 15:57 oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm
-rw------- 1 root  root     158384 11月 23 15:56 oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm
-rw------- 1 root  root   36666947 11月 23 17:05 test_db-master.tar.gz
[admin@jt-t-rl79-tyghwsgl-1 ~]$ sudo rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:libobclient-2.0.2-2.el7          ################################# [100%]
[admin@jt-t-rl79-tyghwsgl-1 ~]$ sudo rpm -ivh obclient-2.0.2-3.el7.x86_64.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:obclient-2.0.2-3.el7             ################################# [100%]
[admin@jt-t-rl79-tyghwsgl-1 ~]$ obclient -h 127.1 -u root -P 2881 -p -c -A
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221225472
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)]>
obclient [(none)]> set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '127.1:2882';
Query OK, 0 rows affected (0.005 sec)
Query OK, 0 rows affected (34.219 sec)
obclient [(none)]>
obclient [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.017 sec)

#OceanBase 集群三个节点都正常启动,并且监听正常时,连接到任一节点(通过 2881 端口直连),进行自举(bootstrap 集群初始化)操作。 初始密码是空。

obclient-h 172.20.249.49 -u root -P 2881 -p -c -A
set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '172.20.249.52:2882', ZONE 'zone2' SERVER '172.20.249.49:2882', ZONE 'zone3' SERVER '172.20.249.51:2882' ;

5.ob-proxy
创建用户 proxyro:

使用root@sys登陆数据库:
#密码为空
设置相关密码
* 集群管理员(root@sys)密码默认集群管理员(root@sys)的密码是空的,这里需要设置一个密码。
alter user root identified by '4S9wDbSr' ;
* OBPROXY 用户(proxyro)密码默认 OBPROXY 连接 OceanBase 集群使用用户 proxyro 。这个用户不存在,需要创建。
grant select on oceanbase.* to proxyro identified by 'SWoLCQRH' ;

obclient -h 127.1 -u root@sys -P 2881 -p -c -A

obclient [(none)]> grant select on oceanbase.* to proxyro identified by 'SWoLCQRH' ;
Query OK, 0 rows affected (0.189 sec)

启动obproxy:
#-c 对应集群的名称,和前面的observer的启动参数对应。
[admin@jt-t-rl79-tyghwsgl-1 ~]$ cd ~/obproxy-3.2.3/ && bin/obproxy -r "127.1:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c obdemo
bin/obproxy -r 127.1:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c obdemo
rs list: 127.1:2881
listen port: 2883
optstr: enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false
cluster_name: obdemo
[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$
[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$ ps -ef|grep obproxy
admin     15108      1  2 10:08 ?        00:00:00 bin/obproxy -r 127.1:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c obdemo
admin     15143  12690  0 10:08 pts/0    00:00:00 grep --color=auto obproxy
端口状态检查:
[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$ netstat -ntlp |grep obproxy
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:2883            0.0.0.0:*               LISTEN      15108/bin/obproxy   
tcp        0      0 0.0.0.0:2884            0.0.0.0:*               LISTEN      15108/bin/obproxy   
[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$

修改 OBPROXY 连接 OceanBase 集群用户 proxyro 的密码。这样 OBPROXY 才能跟 OceanBase 集群正常连接:

#登录 OBPROXY:
#登录用户名:root@proxysys, 端口:2883 ,初始密码:空。
[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$ obclient -h 127.1 -u root@proxysys -P 2883 -p
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 1
Server version: 5.6.25
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)]>
obclient [(none)]> show proxyconfig like '%sys_password%';
+------------------------+-------+--------------------------------+-------------+---------------+
| name                   | value | info                           | need_reboot | visible_level |
+------------------------+-------+--------------------------------+-------------+---------------+
| observer_sys_password1 |       | password for observer sys user | false       | SYS           |
| observer_sys_password  |       | password for observer sys user | false       | SYS           |
| obproxy_sys_password   |       | password for obproxy sys user  | false       | SYS           |
+------------------------+-------+--------------------------------+-------------+---------------+
3 rows in set (0.001 sec)
obclient [(none)]>
修改 OBPROXY 用户密码是通过修改参数的方式,命令是:alter proxyconfig set 。
obclient [(none)]> alter proxyconfig set obproxy_sys_password = 'wPhGddup' ;
Query OK, 0 rows affected (0.020 sec)
同时还需要修改 OBPROXY 连接 OceanBase 集群用户 proxyro 的密码。这样 OBPROXY 才能跟 OceanBase 集群正常连接。这个密码就是前面 OceanBase 集群初始化后创建的用户 proxyro 的密码。
obclient [(none)]> alter proxyconfig set observer_sys_password = 'SWoLCQRH' ;
Query OK, 0 rows affected (0.023 sec)
obclient [(none)]>
退出,通过 OBPROXY 连接 OceanBase 集群看看, 如果能查看所有会话,则说明 OBPROXY 部署成功。
[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$ obclient -h 127.1 -uroot@sys#obdemo -P2883 -c -A oceanbase
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 10
Server version: 5.6.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 [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.006 sec)
obclient [oceanbase]> show processlist;
+------+--------+------+---------------------+-----------+-------------+-------------------+-------------------+-------+-------+
| Id   | Tenant | User | Host                | db        | trans_count | svr_session_count | state             | tid   | pid   |
+------+--------+------+---------------------+-----------+-------------+-------------------+-------------------+-------+-------+
|   10 | sys    | root | 127.1:56732 | oceanbase |           0 |                 1 | MCS_ACTIVE_READER | 15108 | 15108 |
+------+--------+------+---------------------+-----------+-------------+-------------------+-------------------+-------+-------+
1 row in set (0.001 sec)
obclient [oceanbase]> show full processlist;
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------------+
| Id         | User    | Tenant | Host                | db        | Command | Time | State  | Info                  | Ip            | Port | Proxy_sessid       |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------------+
| 3221487914 | proxyro | sys    | 127.1:38102 | oceanbase | Sleep   |   18 | SLEEP  | NULL                  | 127.1 | 2881 | 757837826992832519 |
| 3221487912 | root    | sys    | 127.1:38098 | oceanbase | Query   |    0 | ACTIVE | show full processlist | 127.1 | 2881 | 757837826992832518 |
+------------+---------+--------+---------------------+-----------+---------+------+--------+-----------------------+---------------+------+--------------------+
2 rows in set (0.014 sec)
obclient [oceanbase]> exit

三、创建租户、数据库,表

[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$ obclient -h 127.1 -u root@sys -P 2881 -p -c -A
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487988
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)]> alter resource unit sys_unit_config min_cpu=5;
Query OK, 0 rows affected (0.038 sec)
obclient [(none)]>
obclient [(none)]> CREATE resource unit ZEE4C1G max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G';
Query OK, 0 rows affected (0.012 sec)
obclient [(none)]>
#创建资源池
obclient [(none)]> CREATE resource pool my_pool unit = 'ZEE4C1G', unit_num = 1;
Query OK, 0 rows affected (0.048 sec)
obclient [(none)]>
#创建租户
obclient [(none)]> create tenant obmysql resource_pool_list=('my_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (2.087 sec)

6.2 使用租户登录,创建表
#登录刚刚创建的业务租户obmysql
obclient -h 127.1 -uroot@obmysql -P2883 -p -c -A
#默认空密码
[admin@0510bd3dca82 ~]$ obclient -h 127.1 -uroot@obmysql#obce-single -P2883 -p -c -A
#创建数据库
obclient [(none)]> create database mydb;
Query OK, 1 row affected (0.040 sec)


obclient [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
| mydb               |
+--------------------+
5 rows in set (0.005 sec)
#创建业务用户并赋权
obclient [(none)]> create user zee identified by "zee123";
Query OK, 0 rows affected (0.076 sec)
obclient [(none)]> grant all privileges on mydb.* to zee;
Query OK, 0 rows affected (0.045 sec)
#业务用户登录
obclient -h 127.1 -uzee@obmysql  -P2883 -p -c -A
[admin@jt-t-rl79-tyghwsgl-1 obproxy-3.2.3]$ obclient -h 127.1 -uzee@obmysql  -P2883 -p -c -A
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 16
Server version: 5.6.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)]>
obclient [(none)]> use mydb
Database changed
obclient [mydb]>
#创建业务表
obclient [mydb]> CREATE TABLE `accountmoremenuinfo` (
    ->   `id` INT DEFAULT NULL,
    ->   `labelid` INT DEFAULT NULL,
    ->   `customname` VARCHAR(1000) DEFAULT NULL,
    ->   `icon` VARCHAR(1000) DEFAULT NULL,
    ->   `isshow` CHAR(1) DEFAULT NULL,
    ->   `url` VARCHAR(1000) DEFAULT NULL,
    ->   `linkmode` CHAR(1) DEFAULT NULL,
    ->   `type` VARCHAR(10) DEFAULT NULL,
    ->   `shoposition` CHAR(1) DEFAULT NULL,
    ->   `sortnum` INT DEFAULT NULL,
    ->   `sType` VARCHAR(255) DEFAULT NULL,
    ->   `iconType` VARCHAR(100) DEFAULT NULL,
    ->   `iconFrom` VARCHAR(100) DEFAULT NULL,
    ->   `iconImgSrc` VARCHAR(300) DEFAULT NULL
    -> );


CREATE TABLE `actionexecutelog` (
  `id` INT NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `ACTIONID` TEXT,
  `ACTIONTYPE` INT DEFAULT NULL,
  `DATASHOWCOUNT` INT DEFAULT NULL,
  `CREATEDATE` VARCHAR(80) DEFAULT NULL,
  `CREATETIME` VARCHAR(64) DEFAULT NULL,
  `ModifyDate` VARCHAR(80) DEFAULT NULL,
Query OK, 0 rows affected (0.224 sec)


obclient [mydb]>
obclient [mydb]> CREATE TABLE `actionexecutelog` (
    ->   `id` INT NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    ->   `ACTIONID` TEXT,
    ->   `ACTIONTYPE` INT DEFAULT NULL,
    ->   `DATASHOWCOUNT` INT DEFAULT NULL,
    ->   `CREATEDATE` VARCHAR(80) DEFAULT NULL,
    ->   `CREATETIME` VARCHAR(64) DEFAULT NULL,
    ->   `ModifyDate` VARCHAR(80) DEFAULT NULL,
    ->   `ModifyTime` VARCHAR(64) DEFAULT NULL,
    ->   `clientip` VARCHAR(256) DEFAULT NULL,
    ->   `execresult` INT DEFAULT NULL,
    ->   `actiondbid` VARCHAR(1000) DEFAULT NULL,
    ->   PRIMARY KEY (`id`),
    ->   KEY `idx_0826_actiondbid` (`actiondbid`),
    ->   KEY `idx_0826_createDate` (`CREATEDATE`)
    -> ) ;


CREATE TABLE `actionsetting` (
  `id` INT NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `ACTIONNAME` VARCHAR(1000) DEFAULT NULL,
  `ACTIONCLASS` TEXT,
  `TYPENAME` VARCHAR(160) DEFAULT NULL,
  `ACTIONSHOWNAME` VARCHAR(1000) DEFAULT NULL,
Query OK, 0 rows affected (0.229 sec)


obclient [mydb]>
obclient [mydb]> CREATE TABLE `actionsetting` (
    ->   `id` INT NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    ->   `ACTIONNAME` VARCHAR(1000) DEFAULT NULL,
    ->   `ACTIONCLASS` TEXT,
    ->   `TYPENAME` VARCHAR(160) DEFAULT NULL,
    ->   `ACTIONSHOWNAME` VARCHAR(1000) DEFAULT NULL,
    ->   `CREATEDATE` VARCHAR(80) DEFAULT NULL,
    ->   `CREATETIME` VARCHAR(64) DEFAULT NULL,
    ->   `MODIFYDATE` VARCHAR(80) DEFAULT NULL,
    ->   `MODIFYTIME` VARCHAR(64) DEFAULT NULL,
    ->   `javacode` TEXT,
    ->   `uuid` VARCHAR(50) DEFAULT '0',
    ->   `subcompanyid` INT DEFAULT NULL,
    ->   PRIMARY KEY (`id`)
    -> ) AUTO_INCREMENT=152 ;
Query OK, 0 rows affected (0.117 sec)


obclient [mydb]>
obclient [mydb]>
obclient [mydb]>
obclient [mydb]>
obclient [mydb]> show tables;
+---------------------+
| Tables_in_mydb      |
+---------------------+
| accountmoremenuinfo |
| actionexecutelog    |
| actionsetting       |
+---------------------+
3 rows in set (0.005 sec)


obclient [mydb]>
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值