1.系统配置
1).ulimit
# vi /etc/security/limits.conf
* - core unlimited
* - data unlimited
* - fsize unlimited
* - sigpending 119934
* - memlock 64
* - rss unlimited
* - nofile 1048576
* - msgqueue 819200
* - stack 8192
* - cpu unlimited
* - nproc 12000
* - locks unlimited
# vi /etc/security/limits.d/20-nproc.conf
* soft nproc 12000
root soft nproc unlimited
2).透明大页(always)
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
#
2.安装yugabyte
# tar zxvf yugabyte-2.9.0.0-linux.tar.gz -C /opt/
# cd /opt/yugabyte-2.9.0.0/
# ./bin/post_install.sh
3.配置master
1).创建数据目录
# mkdir -p /ybdata/master/data01
# mkdir -p /ybdata/master/data02
2).配置master
vi /etc/yb-master.conf
--master_addresses=192.168.43.54:7100,192.168.43.188:7100,192.168.43.32:7100
--rpc_bind_addresses=192.168.43.188:7100
--fs_data_dirs=/ybdata/master/data01,/ybdata/master/data02
--replication_factor=3
3).配置环境变量
/etc/profile
export PATH=/opt/yugabyte-2.9.0.0/bin:$PATH
4).启动服务器
yb-master --flagfile /etc/yb-master.conf >& /ybdata/master/yb-master.out &
5).状态检查
a. master
cat /ybdata/master/data01/yb-data/master/logs/yb-master.INFO|grep LEADER
[......]
This master's current role is: LEADER
[......]
b.follower
cat /ybdata/master/data01/yb-data/master/logs/yb-master.INFO|grep LEADER
[......]
[sys.catalog]: This master's current role is: FOLLOWER
[......]
4.启动tserver
1).创建目录
mkdir -p /ybdata/tserver/data01
mkdir -p /ybdata/tserver/data02
2).配置tserver
vi /etc/yb-tserver.conf
--tserver_master_addrs=192.168.43.54:7100,192.168.43.188:7100,192.168.43.32:7100
--rpc_bind_addresses=192.168.43.54:9100
--start_pgsql_proxy
--pgsql_proxy_bind_address=0.0.0.0:5433
--cql_proxy_bind_address=0.0.0.0:9042
--fs_data_dirs=/ybdata/tserver/data01,/ybdata/tserver/data02
3).启动服务
yb-tserver --flagfile /etc/yb-tserver.conf >& /ybdata/tserver/yb-tserver.out &
4).状态检查
cat /ybdata/tserver/data01/yb-data/tserver/logs/yb-tserver.INFO|grep successfully
[......]
CQL server successfully started.
5.master 检查
[root@ydb03 ~]# cat /ybdata/master/data01/yb-data/master/logs/yb-master.INFO |grep Registered
I0903 14:42:56.724704 1294 tablet_peer.cc:1125] T 00000000000000000000000000000000 P 3da33a01d6014c8d9e3b7d1379324fc4 [state=RUNNING]: Registered log gc
I0903 15:08:03.876421 1307 ts_manager.cc:142] Registered new tablet server { permanent_uuid: "2754f6de56c042d7b5bd9db97c005536" instance_seqno: 1630681683798696 start_time_us: 1630681683798696 } with Master, full list: [{2754f6de56c042d7b5bd9db97c005536, 0x00000000031006d0 -> { permanent_uuid: 2754f6de56c042d7b5bd9db97c005536 registration: common { private_rpc_addresses { host: "192.168.43.54" port: 9100 } http_addresses { host: "192.168.43.54" port: 9000 } cloud_info { placement_cloud: "cloud1" placement_region: "datacenter1" placement_zone: "rack1" } placement_uuid: "" pg_port: 5433 } capabilities: 2189743739 capabilities: 1427296937 capabilities: 2980225056 placement_id: cloud1:datacenter1:rack1 }}]
I0903 15:08:09.300563 1295 ts_manager.cc:142] Registered new tablet server { permanent_uuid: "770a71a13a834dbc9f059a8f2523a64e" instance_seqno: 1630681689357352 start_time_us: 1630681689357352 } with Master, full list: [{770a71a13a834dbc9f059a8f2523a64e, 0x0000000002871690 -> { permanent_uuid: 770a71a13a834dbc9f059a8f2523a64e registration: common { private_rpc_addresses { host: "192.168.43.188" port: 9100 } http_addresses { host: "192.168.43.188" port: 9000 } cloud_info { placement_cloud: "cloud1" placement_region: "datacenter1" placement_zone: "rack1" } placement_uuid: "" pg_port: 5433 } capabilities: 2189743739 capabilities: 1427296937 capabilities: 2980225056 placement_id: cloud1:datacenter1:rack1 }}, {2754f6de56c042d7b5bd9db97c005536, 0x00000000031006d0 -> { permanent_uuid: 2754f6de56c042d7b5bd9db97c005536 registration: common { private_rpc_addresses { host: "192.168.43.54" port: 9100 } http_addresses { host: "192.168.43.54" port: 9000 } cloud_info { placement_cloud: "cloud1" placement_region: "datacenter1" placement_zone: "rack1" } placement_uuid: "" pg_port: 5433 } capabilities: 2189743739 capabilities: 1427296937 capabilities: 2980225056 placement_id: cloud1:datacenter1:rack1 }}]
I0903 15:08:12.422075 1289 ts_manager.cc:142] Registered new tablet server { permanent_uuid: "93b36c858bc844e1ad0a8abe10a49218" instance_seqno: 1630681692410163 start_time_us: 1630681692410163 } with Master, full list: [{93b36c858bc844e1ad0a8abe10a49218, 0x0000000001a286d0 -> { permanent_uuid: 93b36c858bc844e1ad0a8abe10a49218 registration: common { private_rpc_addresses { host: "192.168.43.32" port: 9100 } http_addresses { host: "192.168.43.32" port: 9000 } cloud_info { placement_cloud: "cloud1" placement_region: "datacenter1" placement_zone: "rack1" } placement_uuid: "" pg_port: 5433 } capabilities: 2189743739 capabilities: 1427296937 capabilities: 2980225056 placement_id: cloud1:datacenter1:rack1 }}, {770a71a13a834dbc9f059a8f2523a64e, 0x0000000002871690 -> { permanent_uuid: 770a71a13a834dbc9f059a8f2523a64e registration: common { private_rpc_addresses { host: "192.168.43.188" port: 9100 } http_addresses { host: "192.168.43.188" port: 9000 } cloud_info { placement_cloud: "cloud1" placement_region: "datacenter1" placement_zone: "rack1" } placement_uuid: "" pg_port: 5433 } capabilities: 2189743739 capabilities: 1427296937 capabilities: 2980225056 placement_id: cloud1:datacenter1:rack1 }}, {2754f6de56c042d7b5bd9db97c005536, 0x00000000031006d0 -> { permanent_uuid: 2754f6de56c042d7b5bd9db97c005536 registration: common { private_rpc_addresses { host: "192.168.43.54" port: 9100 } http_addresses { host: "192.168.43.54" port: 9000 } cloud_info { placement_cloud: "cloud1" placement_region: "datacenter1" placement_zone: "rack1" } placement_uuid: "" pg_port: 5433 } capabilities: 2189743739 capabilities: 1427296937 capabilities: 2980225056 placement_id: cloud1:datacenter1:rack1 }}]
[root@ydb03 ~]#
6.登录系统
三个节点均为读写状态
[root@ydb03 ~]# ysqlsh
ysqlsh (11.2-YB-2.9.0.0-b0)
Type "help" for help.
yugabyte=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------------+----------+----------+---------+-------------+-----------------------
postgres | postgres | UTF8 | C | en_US.UTF-8 |
system_platform | postgres | UTF8 | C | en_US.UTF-8 |
template0 | postgres | UTF8 | C | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
yugabyte | postgres | UTF8 | C | en_US.UTF-8 |
(5 rows)
yugabyte=# create database tdb01;
CREATE DATABASE
yugabyte=#
节点状态检查
yugabyte=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
f
(1 row)
yugabyte=# \c tdb01
You are now connected to database "tdb01" as user "yugabyte".
tdb01=# create table t1(id int primary key, uname varchar(20));
CREATE TABLE
tdb01=#
tdb01=# \d t1
Table "public.t1"
Column | Type | Collation | Nullable | Default
--------+-----------------------+-----------+----------+---------
id | integer | | not null |
uname | character varying(20) | | |
Indexes:
"t1_pkey" PRIMARY KEY, lsm (id HASH)
tdb01=#
tdb01=#
tdb01=# \d+ t1
Table "public.t1"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+-----------------------+-----------+----------+---------+----------+--------------+-------------
id | integer | | not null | | plain | |
uname | character varying(20) | | | | extended | |
Indexes:
"t1_pkey" PRIMARY KEY, lsm (id HASH)
tdb01=#