安装Docker
参考:https://www.xmmup.com/dbbao2centos7anzhuangdocker.html
Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。CentOS 7 的内核一般都是3.10的,而CentOS 6.X 的内核一般都是2.6,在2.6的内核下,Docker运行会比较卡,所以一般会选择升级到3.10版本。
11、卸载掉旧版本的 Docker:
2yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
3
42、执行以下安装命令去安装依赖包:
5yum install -y yum-utils device-mapper-persistent-data lvm2
6yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
7
8yum -y install docker-ce docker-ce-cli containerd.io
9
10# 若执行报错,则配置yum源
11wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
12wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
13
14
15
16
17systemctl start docker
18systemctl status docker
19
20
213、检查版本
22docker version
23docker info
也可以一键安装Docker:
1curl -fsSL get.docker.com -o get-docker.sh
2sh get-docker.sh
安装完成:
1[root@lhrdocker ~]# docker ps
2Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
3[root@lhrdocker ~]# systemctl start docker
4systemctl status docker[root@lhrdocker ~]# systemctl status docker
5● docker.service - Docker Application Container Engine
6 Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
7 Active: active (running) since Wed 2020-06-24 13:12:56 CST; 1s ago
8 Docs: https://docs.docker.com
9 Main PID: 9348 (dockerd)
10 Memory: 38.4M
11 CGroup: /system.slice/docker.service
12 └─9348 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
13
14Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.403432651+08:00" level=info msg="ccResolverWrappe...e=grpc
15Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.403438749+08:00" level=info msg="ClientConn switc...e=grpc
16Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.422565741+08:00" level=info msg="Loading containe...tart."
17Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.498364397+08:00" level=info msg="Default bridge (...dress"
18Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.586263842+08:00" level=info msg="Loading containe...done."
19Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.614176483+08:00" level=warning msg="Not using nat...erlay2
20Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.614312232+08:00" level=info msg="Docker daemon" c....03.12
21Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.614366802+08:00" level=info msg="Daemon has compl...ation"
22Jun 24 13:12:56 lhrdocker dockerd[9348]: time="2020-06-24T13:12:56.700953028+08:00" level=info msg="API listen on /v....sock"
23Jun 24 13:12:56 lhrdocker systemd[1]: Started Docker Application Container Engine.
24Hint: Some lines were ellipsized, use -l to show in full.
Cceanbase docker版本体验
下载ob docker镜像
1-- 下载
2docker pull obpilot/oceanbase-ce:latest
3docker run -itd -m 10G -p 2881:2881 -p 2883:2883 --name oceanbase-ce obpilot/oceanbase-ce:latest
4
5配置文件:/home/admin/.obd/cluster/obdemo/config.yaml
6
7
8docker exec -it oceanbase-ce bash
9
10-- 进入容器后,可以看看 readme.md 文档,然后启动集群:
11
12# 查看集群列表
13obd cluster list
14
15# 启动集群
16obd cluster start obdemo
17
18admin 用户的密码是 : adminPWD123 . 您可以使用 sudo yum 安装软件包。
19
20
21-- create an oceanbase mysql tenant
22obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase
23
24alter resource unit sys_unit_config min_cpu=5;
25CREATE resource unit S4C1G 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';
26CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1;
27create 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';
28
29exit;
30
31
32-- log in to the obmysql tenant
33obclient -h 127.1 -uroot@obmysql#obdemo -P2883 -p -c -A test
34
35empty password.
36
37show databases;
地址:https://hub.docker.com/r/obpilot/oceanbase-ce

1[root@docker35 ~]# docker pull obpilot/oceanbase-ce
2Using default tag: latest
3latest: Pulling from obpilot/oceanbase-ce
47a0437f04f83: Already exists
5615dc48ac9f1: Pull complete
6b10c1cdae3af: Pull complete
74f4fb700ef54: Pull complete
8c0f6c94a6a6a: Pull complete
9792630f35e24: Pull complete
10Digest: sha256:7ac28415cf27ba19cb47acb67a55ebf9848ad73a63d80b7e2e85d653233dbaeb
11Status: Downloaded newer image for obpilot/oceanbase-ce:latest
12docker.io/obpilot/oceanbase-ce:latest
13[root@docker35 ~]# docker images | grep oceanbase
14obpilot/oceanbase-ce latest 943379e0b05b 4 weeks ago 2.25GB
15obpilot/oceanbase-ce <none> c3ac45532094 4 months ago 2.24GB
16oceanbase/obce-mini latest 1a5ca6d233a7 4 months ago 690MB
17[root@docker35 ~]# docker run -itd -m 10G -p 2881:2881 -p 2883:2883 --name oceanbase-ce obpilot/oceanbase-ce:latest
18docker: Error response from daemon: Conflict. The container name "/oceanbase-ce" is already in use by container "2a86c75456b5509b21e5e6981ba5fd53826c2f630d7b06d3145140436f024db3". You have to remove (or rename) that container to be able to reuse that name.
19See 'docker run --help'.
20[root@docker35 ~]# docker rm -f oceanbase-ce
21oceanbase-ce
22[root@docker35 ~]# docker run -itd -m 10G -p 2881:2881 -p 2883:2883 --name oceanbase-ce obpilot/oceanbase-ce:latest
230209306f10bf1c49fb58ffee65ac2b17f3ce3c0b4c2884eca57f3af5464babf4
24[root@docker35 ~]#
25[root@docker35 ~]# docker exec -it oceanbase-ce bash
使用obd工具查看集群及启动
1[root@docker35 ~]# docker exec -it oceanbase-ce bash
2[admin@0209306f10bf ~]$ obd cluster list
3+------------------------------------------------------------+
4| Cluster List |
5+--------+---------------------------------+-----------------+
6| Name | Configuration Path | Status (Cached) |
7+--------+---------------------------------+-----------------+
8| obdemo | /home/admin/.obd/cluster/obdemo | deployed |
9+--------+---------------------------------+-----------------+
10
11[admin@0209306f10bf ~]$ obd cluster start obdemo
12Get local repositories and plugins ok
13Open ssh connection ok
14Cluster param config check ok
15Check before start observer ok
16Check before start obproxy ok
17Start observer ok
18observer program health check ok
19Connect to observer ok
20Initialize cluster
21Cluster bootstrap ok
22Wait for observer init ok
23+---------------------------------------------+
24| observer |
25+-----------+---------+------+-------+--------+
26| ip | version | port | zone | status |
27+-----------+---------+------+-------+--------+
28| 127.0.0.1 | 3.1.1 | 2881 | zone1 | active |
29+-----------+---------+------+-------+--------+
30
31Start obproxy ok
32obproxy program health check ok
33Connect to obproxy ok
34Initialize cluster
35+---------------------------------------------+
36| obproxy |
37+-----------+------+-----------------+--------+
38| ip | port | prometheus_port | status |
39+-----------+------+-----------------+--------+
40| 127.0.0.1 | 2883 | 2884 | active |
41+-----------+------+-----------------+--------+
42obdemo running
43[admin@0209306f10bf ~]$ obd cluster list
44+------------------------------------------------------------+
45| Cluster List |
46+--------+---------------------------------+-----------------+
47| Name | Configuration Path | Status (Cached) |
48+--------+---------------------------------+-----------------+
49| obdemo | /home/admin/.obd/cluster/obdemo | running |
50+--------+---------------------------------+-----------------+
登录ob数据库并创建租户
1[admin@0209306f10bf ~]$ obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase
2Welcome to the OceanBase. Commands end with ; or \g.
3Your MySQL connection id is 4
4Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)
5
6Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
7
8Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
9
10MySQL [oceanbase]> show databases;
11+--------------------+
12| Database |
13+--------------------+
14| oceanbase |
15| information_schema |
16| mysql |
17| SYS |
18| LBACSYS |
19| ORAAUDITOR |
20| test |
21+--------------------+
227 rows in set (0.005 sec)
创建资源单元、资源池、租户
1MySQL [oceanbase]> CREATE resource unit S4C1G 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';
2Query OK, 0 rows affected (0.006 sec)
3
4MySQL [oceanbase]> CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1;
5Query OK, 0 rows affected (0.011 sec)
6
7MySQL [oceanbase]> 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';
8Query OK, 0 rows affected (0.612 sec)
9
10MySQL [oceanbase]>
登录obmysql tenant并创建数据库及表等
1[admin@0209306f10bf ~]$ obclient -h 127.1 -uroot@obmysql#obce-single -P2883 -p -c -A test
2Enter password:
3Welcome to the OceanBase. Commands end with ; or \g.
4Your MySQL connection id is 8
5Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)
6
7Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
8
9Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
10
11MySQL [test]> show databases;
12+--------------------+
13| Database |
14+--------------------+
15| oceanbase |
16| information_schema |
17| mysql |
18| test |
19+--------------------+
204 rows in set (0.017 sec)
21
22MySQL [test]> create database lhrdb charset utf8mb4;
23Query OK, 1 row affected (0.168 sec)
24
25MySQL [test]> use lhrdb;
26Database changed
27
28MySQL [lhrdb]> source /tmp/mysql_employees.sql
29Query OK, 0 rows affected (0.001 sec)
30
31Query OK, 0 rows affected (0.001 sec)
32
33Query OK, 0 rows affected (0.001 sec)
34
35Query OK, 0 rows affected (0.001 sec)
36
37Query OK, 0 rows affected (0.001 sec)
38
39Query OK, 0 rows affected, 1 warning (0.004 sec)
40
41Query OK, 0 rows affected (0.001 sec)
42
43Query OK, 0 rows affected (0.001 sec)
44
45Query OK, 0 rows affected (0.001 sec)
46
47.....
48MySQL [lhrdb]> show tables;
49+-----------------+
50| Tables_in_lhrdb |
51+-----------------+
52| departments |
53| job_grades |
54| jobs |
55| late |
56| locations |
57+-----------------+
585 rows in set (0.018 sec)
59MySQL [lhrdb]> select * from jobs;
60+------------+---------------------------------+------------+------------+
61| job_id | job_title | min_salary | max_salary |
62+------------+---------------------------------+------------+------------+
63| AC_ACCOUNT | Public Accountant | 4200 | 9000 |
64| AC_MGR | Accounting Manager | 8200 | 16000 |
65| AD_ASST | Administration Assistant | 3000 | 6000 |
66| AD_PRES | President | 20000 | 40000 |
67| AD_VP | Administration Vice President | 15000 | 30000 |
68| FI_ACCOUNT | Accountant | 4200 | 9000 |
69| FI_MGR | Finance Manager | 8200 | 16000 |
70| HR_REP | Human Resources Representative | 4000 | 9000 |
71| IT_PROG | Programmer | 4000 | 10000 |
72| MK_MAN | Marketing Manager | 9000 | 15000 |
73| MK_REP | Marketing Representative | 4000 | 9000 |
74| PR_REP | Public Relations Representative | 4500 | 10500 |
75| PU_CLERK | Purchasing Clerk | 2500 | 5500 |
76| PU_MAN | Purchasing Manager | 8000 | 15000 |
77| SA_MAN | Sales Manager | 10000 | 20000 |
78| SA_REP | Sales Representative | 6000 | 12000 |
79| SH_CLERK | Shipping Clerk | 2500 | 5500 |
80| ST_CLERK | Stock Clerk | 2000 | 5000 |
81| ST_MAN | Stock Manager | 5500 | 8500 |
82+------------+---------------------------------+------------+------------+
8319 rows in set (0.003 sec)
总结
OB的docker版本比较简单。可以体验MySQL租户,缺点是不能体验Oracle租户。
文章转载自DB宝,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




