龙空技术网

Ob初体验Docker版安装

葫芦儿的成长记录 382

前言:

现在咱们对“mysql安装配置教程5734”大约比较着重,姐妹们都想要了解一些“mysql安装配置教程5734”的相关内容。那么小编在网络上网罗了一些有关“mysql安装配置教程5734””的相关资讯,希望姐妹们能喜欢,看官们一起来了解一下吧!

Ob初体验Docker版安装

[root@observer01 ~]# cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core)安装docker服务器可以连接互联网,网络配置文件配置DNS1关键字并输入正确的dns服务器地址
环境介绍
系统版本:CentOS Linux release 7.6.1810 (Core)-最小化安装内存:32GCpu:4C
配置本地yum源命令汇总本地yum仓库配置
[root@observer01 ~]# cat /etc/yum.repos.d/centos.repo[local]name=localbaseurl=
添加docker仓库
yum-config-manager --add-repo  -O /etc/yum.repos.d/CentOS-Base.repo  -O /etc/yum.repos.d/epel.repo 
操作记录

操作记录

[root@observer01 ~]# mount /dev/cdrom /mntmount: /dev/sr0 is write-protected, mounting read-only[root@observer01 ~]# cd /etc/yum.repos.d/[root@observer01 yum.repos.d]# lsCentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo[root@observer01 yum.repos.d]# mkdir bak[root@observer01 yum.repos.d]# mv CentOS-* bak/[root@observer01 yum.repos.d]# vi centos.repo[root@observer01 ~]# cat /etc/yum.repos.d/centos.repo[local]name=localbaseurl=[root@observer01 yum.repos.d]# yum provides yum-config-managerLoaded plugins: fastestmirrorDetermining fastest mirrorslocal | 3.6 kB 00:00:00(1/2): local/group_gz | 166 kB 00:00:00(2/2): local/primary_db | 3.1 MB 00:00:00local/filelists_db | 3.2 MB 00:00:00yum-utils-1.1.31-50.el7.noarch : Utilities based around the yum package managerRepo : localMatched from:Filename : /usr/bin/yum-config-manager[root@observer01 yum.repos.d]# yum install yum-utils-1.1.31-50.el7.noarch下载docker源[root@observer01 yum.repos.d]# yum-config-manager --add-repo  plugins: fastestmirroradding repo from:  file  to /etc/yum.repos.d/docker-ce.reporepo saved to /etc/yum.repos.d/docker-ce.repo[root@observer01 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo  17:16:39--  mirrors.aliyun.com (mirrors.aliyun.com)... 59.109.111.231, 59.109.111.224, 59.109.111.230, ...Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|59.109.111.231|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 2523 (2.5K) [application/octet-stream]Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’100%[==========================================================================================================>] 2,523 --.-K/s in 0s2022-01-25 17:16:39 (133 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523][root@observer01 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo  17:16:44--  mirrors.aliyun.com (mirrors.aliyun.com)... 59.109.111.229, 59.109.111.228, 59.109.111.226, ...Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|59.109.111.229|:80... connected.HTTP request sent, awaiting response...200 OKLength: 664 [application/octet-stream]Saving to: ‘/etc/yum.repos.d/epel.repo’100%[==========================================================================================================>] 664 --.-K/s in 0s2022-01-25 17:16:45 (40.0 MB/s) - ‘/etc/yum.repos.d/epel.repo’ saved [664/664][root@observer01 yum.repos.d]#
安装docker
[root@observer01 yum.repos.d]# yum -y install docker-ce docker-ce-cli containerd.io
Docker常用命令
# 查看docker版本docker version# 显示docker系统的信息docker info# 日志信息docker logs# 故障检查service docker status# 启动关闭dockerservice docker start | stop# 查看容器日志docker logs -f <容器名orID># 清理命令,危险!!!# 清理不用的容器docker container prune# 清理不用的镜像docker image prune# 清理不用的卷docker volume prune
启动ob容器及集群
[root@observer01 yum.repos.d]# systemctl start docker[root@observer01 yum.repos.d]# docker search oceanbase
[root@observer01 yum.repos.d]# docker pull obpilot/oceanbase-ce:latest 获取docker镜像latest: Pulling from obpilot/oceanbase-ce7a0437f04f83: Pull complete615dc48ac9f1: Pull completeb10c1cdae3af: Pull complete4f4fb700ef54: Pull completec0f6c94a6a6a: Pull complete792630f35e24: Pull completeDigest: sha256:7ac28415cf27ba19cb47acb67a55ebf9848ad73a63d80b7e2e85d653233dbaebStatus: Downloaded newer image for obpilot/oceanbase-ce:latestdocker.io/obpilot/oceanbase-ce:latest

[root@observer01 yum.repos.d]# docker images 查看ob镜像

docker run -itd -m 10G -p 2881:2881 -p 2883:2883 --name oceanbase-ce obpilot/oceanbase-ce:latest 启动ob docker容器

查看docker启动情况

docker exec -it oceanbase-ce bash 进入ob容器并查看集群状态

[admin@22fc2c005734 ~]$ obd cluster start obdemo 启动集群

连接集群

[admin@22fc2c005734 ~]$ obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase
查看集群的config.yaml

里面包括的相关的密码和集群信息

[admin@07f6a5ad8c5c obdemo]$ pwd/home/admin/.obd/cluster/obdemo[admin@07f6a5ad8c5c obdemo]$ lsconfig.yaml[admin@07f6a5ad8c5c obdemo]$ cat config.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 30oceanbase-ce:servers:# Please don't use hostname, only IP can be supported- 127.0.0.1global:# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.home_path: /home/admin/oceanbase-ce# The directory for data storage. The default value is $home_path/store.# data_dir: /data/1# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.redo_dir: /data/log1# 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: lomysql_port: 2881 # External port for OceanBase Database. The default value is 2881.rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.zone: zone1cluster_id: 1# please set memory limit to a suitable value which is matching resource.memory_limit: 8G # The maximum running memory for an observersystem_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.stack_size: 512Kcpu_count: 16cache_wash_threshold: 1G__min_full_resource_pool_memory: 268435456workers_per_cpu_quota: 10schema_history_expire_time: 1d# The value of net_thread_count had better be same as cpu's core number.net_thread_count: 4major_freeze_duty_time: Disableminor_freeze_times: 10enable_separate_sys_clog: 0enable_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.datafile_size: 5Gsyslog_level: ERROR # 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.# observer cluster name, consistent with obproxy's cluster_nameappname: obce-singleroot_password: rootPWD123 # root user password, can be emptyproxyro_password: proxyROPWD123 # proxyro user pasword, consistent with obproxy's observer_sys_password, can be emptyobproxy:servers:- 127.0.0.1depends:- oceanbase-ceglobal:listen_port: 2883 # External port. The default value is 2883.prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.home_path: /home/admin/obproxy# oceanbase root server list# format: ip:mysql_port,ip:mysql_portrs_list: 127.0.0.1:2881enable_cluster_checkout: false# observer cluster name, consistent with oceanbase-ce's appnamecluster_name: obce-singleobproxy_sys_password: proxySYSPWD123 # obproxy sys user password, can be emptyobserver_sys_password: proxyROPWD123 # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be emptyautomatic_match_work_thread: falsework_thread_num: 12xflush_log_level: ERRORmonitor_log_level: ERRORsyslog_level: ERRORlog_dir_size_threshold: 1Genable_compression_protocol: false[admin@07f6a5ad8c5c obdemo]$
通过obproxy连接集群

由于OceanBase支持多租户, 每个租户对应一个MySQL实例。因此访问OceanBase的用户名需要指定租户名。

又由于proxy支持OceanBase的多集群部署,因此通过proxy访问OceanBase服务时, 还需要指定集群名, 格式有四种:

username@tenantname#clustername, 如root@trade#xxbankclustername:tenantname:username, 如xxbank:trade:rootclustername-tenantname-username, 如xxbank-trade-rootclustername.tenantname.username, 如xxbank.trade.root
[admin@07f6a5ad8c5c obdemo]$ obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbaseWelcome to the OceanBase. Commands end with ; or \g.Your MySQL connection id is 13Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MySQL [oceanbase]> show databases;+--------------------+| Database |+--------------------+| oceanbase || information_schema || mysql || SYS || LBACSYS || ORAAUDITOR || test |+--------------------+7 rows in set (0.016 sec)通过observer连接
[admin@07f6a5ad8c5c obdemo]$ obclient -h127.1 -uroot -P2881 -prootPWD123 -c -A oceanbaseWelcome to the OceanBase. Commands end with ; or \g.Your MySQL connection id is 3221518706Server version: 5.7.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MySQL [oceanbase]>
创建租户数据库及表

obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase

创建unit规格

MySQL [oceanbase]> CREATE resource unit 1C1G max_cpu=1, min_cpu=1, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='10G';Query OK, 0 rows affected (0.007 sec)

查看unit相关配置

创建资源池

CREATE resource pool pool_1 unit = '1C1G', unit_num = 1;
create tenant mysql_t1 resource_pool_list=('pool_1'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
登陆业务租户

$ obclient -h 127.1 -uroot@mysql_t1#obce-single -P2883 -p -c -A test

默认密码为空

登陆后修改root密码

MySQL [tpccdb]> alter user root identified by 'root';Query OK, 0 rows affected (0.012 sec)
创建表

[admin@22fc2c005734 ~]$ ls

bmsql.sql obproxy oceanbase-ce readme.md

[admin@22fc2c005734 ~]$

启停命令

obd cluster stop obdemo

obd cluster start obdemo

标签: #mysql安装配置教程5734