OceanBase学习记录(十)社区版docker安装
[root@observer01 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
安装docker
服务器可以连接互联网,网络配置文件配置DNS1关键字并输入正确的dns服务器地址1.1.1. 配置本地yum源# mount /dev/cdrom /mnt mount: /dev/sr0 is write-protected, mounting read-only # cd /etc/yum.repos.d/ # mkdir bak # mv CentOS-* bak/ # vi centos.repo # yum install yum-utils-1.1.31-50.el7.noarch
下载docker源# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo1.1.2. 执行安装docker[root@observer01 yum.repos.d]# yum -y install docker-ce docker-ce-cli containerd.io1.1.3. Docker常用命令# 查看docker版本 docker version # 显示docker系统的信息 docker info # 日志信息 docker logs # 故障检查 service docker status # 启动关闭docker service docker start | stop # 查看容器日志 docker logs -f <容器名orID> # 清理命令,危险!!! # 清理不用的容器 docker container prune # 清理不用的镜像 docker image prune # 清理不用的卷 docker volume prune 1.1.4. 安装ob[root@observer01 yum.repos.d]# systemctl start docker 启动docker [root@observer01 yum.repos.d]# docker search oceanbase 查看docker版的ob镜像 NAME DESCRIPTION STARS OFFICIAL AUTOMATED oceanbase/oceanbase-xe OceanBase Database 2.2 Express Edition 3 oceanbase/obce-mini obce-mini is a mini standalone test image fo… 3 obpilot/oceanbase-ce 3 steps to run an OceanBase-CE docker in you… 2 oceanbase/oceanbase-ce OceanBase is open source now. This is the do… 2 zibuyu886/oceanbase-ce-cluster OceanBase ce cluster 1 oceanbase/obce-operator obce-operator 1 huweijie/oceanbase-ce-deploy 0 oceanbase/centos7 0 superbigfu/oceanbase 0 hongweiqin/anolisos-oceanbase A tentative deploy of oceanbase. 0 stutiredboy/centos_ob Build environment for OceanBase 3.1 CE. Crea… 0 [root@observer01 yum.repos.d]# docker pull obpilot/oceanbase-ce:latest 下载镜像 latest: Pulling from obpilot/oceanbase-ce 7a0437f04f83: Pull complete 615dc48ac9f1: Pull complete b10c1cdae3af: Pull complete 4f4fb700ef54: Pull complete c0f6c94a6a6a: Pull complete 792630f35e24: Pull complete Digest: sha256:7ac28415cf27ba19cb47acb67a55ebf9848ad73a63d80b7e2e85d653233dbaeb Status: Downloaded newer image for obpilot/oceanbase-ce:latest docker.io/obpilot/oceanbase-ce:latest[root@observer01 yum.repos.d]# docker images 查看镜像 REPOSITORY TAG IMAGE ID CREATED SIZE obpilot/oceanbase-ce latest 943379e0b05b 7 weeks ago 2.25GB docker run -itd -m 10G -p 2881:2881 -p 2883:2883 --name oceanbase-ce obpilot/oceanbase-ce:latest docker exec -it oceanbase-ce bash #启动docker [admin@07f6a5ad8c5c ~]$ obd cluster start obdemo #启动集群 Get local repositories and plugins ok Open ssh connection ok Cluster param config check ok Check before start observer ok [WARN] (127.0.0.1) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536) Check before start obproxy ok Start observer ok observer program health check ok Connect to observer ok Initialize cluster Cluster bootstrap ok Wait for observer init ok +---------------------------------------------+ | observer | +-----------+---------+------+-------+--------+ | ip | version | port | zone | status | +-----------+---------+------+-------+--------+ | 127.0.0.1 | 3.1.1 | 2881 | zone1 | active | +-----------+---------+------+-------+--------+ Start obproxy ok obproxy program health check ok Connect to obproxy ok Initialize cluster +---------------------------------------------+ | obproxy | +-----------+------+-----------------+--------+ | ip | port | prometheus_port | status | +-----------+------+-----------------+--------+ | 127.0.0.1 | 2883 | 2884 | active | +-----------+------+-----------------+--------+ obdemo running [admin@07f6a5ad8c5c ~]$
进入docker容器[root@observer01 ~]# docker exec -it oceanbase-ce bash [admin@07f6a5ad8c5c ~]$ ls bmsql.sql obproxy oceanbase-ce readme.md readme.md文件里面有集群的部署信息,包括集群名称连接用户名密码等信息
连接ob集群[admin@07f6a5ad8c5c ~]$ obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase Welcome to the OceanBase. Commands end with ; or g. #密码及集群名称查看md文件 Your MySQL connection id is 8 Server 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]> MySQL [oceanbase]> MySQL [oceanbase]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | SYS | | LBACSYS | | ORAAUDITOR | | test | +--------------------+ 7 rows in set (0.002 sec) 1.1.5. 查看集群的config.yaml
里面包括的相关的密码和集群信息 [admin@07f6a5ad8c5c obdemo]$ pwd /home/admin/.obd/cluster/obdemo [admin@07f6a5ad8c5c obdemo]$ ls config.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 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: /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: lo mysql_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: 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: 16 cache_wash_threshold: 1G __min_full_resource_pool_memory: 268435456 workers_per_cpu_quota: 10 schema_history_expire_time: 1d # The value of net_thread_count had better be same as cpu"s core number. net_thread_count: 4 major_freeze_duty_time: Disable 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. datafile_size: 5G syslog_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_name appname: obce-single root_password: rootPWD123 # root user password, can be empty proxyro_password: proxyROPWD123 # proxyro user pasword, consistent with obproxy"s observer_sys_password, can be empty obproxy: servers: - 127.0.0.1 depends: - oceanbase-ce global: 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_port rs_list: 127.0.0.1:2881 enable_cluster_checkout: false # observer cluster name, consistent with oceanbase-ce"s appname cluster_name: obce-single obproxy_sys_password: proxySYSPWD123 # obproxy sys user password, can be empty observer_sys_password: proxyROPWD123 # proxyro user pasword, consistent with oceanbase-ce"s proxyro_password, can be empty automatic_match_work_thread: false work_thread_num: 12 xflush_log_level: ERROR monitor_log_level: ERROR syslog_level: ERROR log_dir_size_threshold: 1G enable_compression_protocol: false [admin@07f6a5ad8c5c obdemo]$1.1.6. 通过obproxy连接集群[admin@07f6a5ad8c5c obdemo]$ obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase Welcome to the OceanBase. Commands end with ; or g. Your MySQL connection id is 13 Server 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)1.1.7. 通过observer连接[admin@07f6a5ad8c5c obdemo]$ obclient -h127.1 -uroot -P2881 -prootPWD123 -c -A oceanbase Welcome to the OceanBase. Commands end with ; or g. Your MySQL connection id is 3221518706 Server 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]>1.1.8. 创建租户数据库及表obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase alter resource unit sys_unit_config min_cpu=5; 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"; CREATE resource pool my_pool unit = "S4C1G", unit_num = 1; 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"; exit;1.1.9. 登陆obmysql租户$ obclient -h 127.1 -uroot@obmysql#obce-single -P2883 -p -c -A test Enter password: Welcome to the OceanBase. Commands end with ; or g. Your MySQL connection id is 9 Server 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 [test]> MySQL [test]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | test | +--------------------+ 4 rows in set (0.002 sec) MySQL [test]> source bmsql.sql Query OK, 1 row affected (0.034 sec) Query OK, 0 rows affected (0.054 sec) Query OK, 0 rows affected (0.023 sec) Query OK, 0 rows affected (0.038 sec) +-----------------+------------+---------------+ | Tablegroup_name | Table_name | Database_name | +-----------------+------------+---------------+ | oceanbase | NULL | NULL | | tpcc_group | NULL | NULL | +-----------------+------------+---------------+ 2 rows in set (0.034 sec) +----------------------------------------------+ | Grants for tpcc@% | +----------------------------------------------+ | GRANT USAGE ON *.* TO "tpcc" | | GRANT SELECT ON `oceanbase`.* TO "tpcc" | | GRANT ALL PRIVILEGES ON `tpccdb`.* TO "tpcc" | +----------------------------------------------+ 3 rows in set (0.072 sec) Database changed Query OK, 0 rows affected (0.145 sec) Query OK, 0 rows affected (0.040 sec) Query OK, 0 rows affected (0.078 sec) Query OK, 0 rows affected (0.158 sec) Query OK, 0 rows affected (0.209 sec) Query OK, 0 rows affected (0.213 sec) Query OK, 0 rows affected (0.312 sec) Query OK, 0 rows affected (0.370 sec) Query OK, 0 rows affected (0.242 sec) Query OK, 0 rows affected (0.234 sec) Query OK, 0 rows affected (0.177 sec) Query OK, 0 rows affected (0.183 sec) MySQL [tpccdb]>
1.1.10. 启停命令obd cluster stop obdemo obd cluster start obdemo