如何使用 systemd 运行 YugabyteDB?
How to run YugabyteDB with systemd?
我正在为 运行 YugabyteDB 和 systemd 寻找一些生产配置文件。它应该能够指定 ulimits 并在 startup/failure.
上重新启动进程
有时 systemd 也需要在其配置中指定 ulimits,下面的配置文件也包含这些。
yb-master 服务:
# /etc/systemd/system/yugabyte-master.service
[Unit]
Wants=network-online.target
After=network-online.target
Description=yugabyte-master
[Service]
RestartForceExitStatus=SIGPIPE
EnvironmentFile=/etc/sysconfig/mycompany_env
StartLimitInterval=0
ExecStart=/bin/bash -c '/opt/misc/yugabyte/bin/yb-master \
--fs_data_dirs=/opt/data/1/yugabyte \
--rpc_bind_addresses=n1.node.gce-us-east1.mycompany:7100 \
--server_broadcast_addresses=n1.node.gce-us-east1.mycompany:7100 \
--webserver_interface=n1.node.gce-us-east1.mycompany \
--webserver_port=7000 \
--use_private_ip=never \
--placement_cloud=gce \
--placement_region=gce-us-east1 \
--placement_zone=us-east1-c \
--callhome_collection_level=low \
--logtostderr '
LimitCORE=infinity
TimeoutStartSec=30
WorkingDirectory=/opt/data/1/yugabyte
LimitNOFILE=1048576
LimitNPROC=12000
RestartSec=5
ExecStartPre=/usr/bin/su -c "mkdir -p /opt/data/1/yugabyte && chown yugabyte:yugabyte /opt/data/1/yugabyte"
PermissionsStartOnly=True
User=yugabyte
TimeoutStopSec=300
Restart=always
[Install]
WantedBy=multi-user.target
还有一个用于 yb-tserver 服务:
# /etc/systemd/system/yugabyte-tserver.service
[Unit]
Wants=network-online.target
After=network-online.target
Description=yugabyte-tserver
[Service]
RestartForceExitStatus=SIGPIPE
EnvironmentFile=/etc/sysconfig/mycompany_env
StartLimitInterval=0
ExecStart=/bin/bash -c '/opt/misc/yugabyte/bin/yb-tserver \
--tserver_master_addrs=n1.node.gce-us-east1.mycompany:7100,n2.node.gce-us-central1.mycompany:7100,n3.node.gce-us-west1.mycompany:7100 \
--fs_data_dirs=/opt/data/1/yugabyte \
--rpc_bind_addresses=n1.node.gce-us-east1.mycompany:9200 \
--server_broadcast_addresses=n1.node.gce-us-east1.mycompany:9200 \
--webserver_interface=n1.node.gce-us-east1.mycompany \
--webserver_port=9000 \
--cql_proxy_bind_address=0.0.0.0:9042 \
--use_private_ip=never \
--placement_cloud=gce \
--placement_region=gce-us-east1 \
--placement_zone=us-east1-c \
--start_redis_proxy=false \
--use_cassandra_authentication=true \
--max_stale_read_bound_time_ms=60000 \
--logtostderr --placement_uuid=live'
LimitCORE=infinity
TimeoutStartSec=30
WorkingDirectory=/opt/data/1/yugabyte
LimitNOFILE=1048576
LimitNPROC=12000
RestartSec=5
ExecStartPre=/usr/bin/su -c "mkdir -p /opt/data/1/yugabyte && chown yugabyte:yugabyte /opt/data/1/yugabyte"
PermissionsStartOnly=True
User=yugabyte
TimeoutStopSec=300
Restart=always
[Install]
WantedBy=multi-user.target
我正在为 运行 YugabyteDB 和 systemd 寻找一些生产配置文件。它应该能够指定 ulimits 并在 startup/failure.
上重新启动进程有时 systemd 也需要在其配置中指定 ulimits,下面的配置文件也包含这些。
yb-master 服务:
# /etc/systemd/system/yugabyte-master.service
[Unit]
Wants=network-online.target
After=network-online.target
Description=yugabyte-master
[Service]
RestartForceExitStatus=SIGPIPE
EnvironmentFile=/etc/sysconfig/mycompany_env
StartLimitInterval=0
ExecStart=/bin/bash -c '/opt/misc/yugabyte/bin/yb-master \
--fs_data_dirs=/opt/data/1/yugabyte \
--rpc_bind_addresses=n1.node.gce-us-east1.mycompany:7100 \
--server_broadcast_addresses=n1.node.gce-us-east1.mycompany:7100 \
--webserver_interface=n1.node.gce-us-east1.mycompany \
--webserver_port=7000 \
--use_private_ip=never \
--placement_cloud=gce \
--placement_region=gce-us-east1 \
--placement_zone=us-east1-c \
--callhome_collection_level=low \
--logtostderr '
LimitCORE=infinity
TimeoutStartSec=30
WorkingDirectory=/opt/data/1/yugabyte
LimitNOFILE=1048576
LimitNPROC=12000
RestartSec=5
ExecStartPre=/usr/bin/su -c "mkdir -p /opt/data/1/yugabyte && chown yugabyte:yugabyte /opt/data/1/yugabyte"
PermissionsStartOnly=True
User=yugabyte
TimeoutStopSec=300
Restart=always
[Install]
WantedBy=multi-user.target
还有一个用于 yb-tserver 服务:
# /etc/systemd/system/yugabyte-tserver.service
[Unit]
Wants=network-online.target
After=network-online.target
Description=yugabyte-tserver
[Service]
RestartForceExitStatus=SIGPIPE
EnvironmentFile=/etc/sysconfig/mycompany_env
StartLimitInterval=0
ExecStart=/bin/bash -c '/opt/misc/yugabyte/bin/yb-tserver \
--tserver_master_addrs=n1.node.gce-us-east1.mycompany:7100,n2.node.gce-us-central1.mycompany:7100,n3.node.gce-us-west1.mycompany:7100 \
--fs_data_dirs=/opt/data/1/yugabyte \
--rpc_bind_addresses=n1.node.gce-us-east1.mycompany:9200 \
--server_broadcast_addresses=n1.node.gce-us-east1.mycompany:9200 \
--webserver_interface=n1.node.gce-us-east1.mycompany \
--webserver_port=9000 \
--cql_proxy_bind_address=0.0.0.0:9042 \
--use_private_ip=never \
--placement_cloud=gce \
--placement_region=gce-us-east1 \
--placement_zone=us-east1-c \
--start_redis_proxy=false \
--use_cassandra_authentication=true \
--max_stale_read_bound_time_ms=60000 \
--logtostderr --placement_uuid=live'
LimitCORE=infinity
TimeoutStartSec=30
WorkingDirectory=/opt/data/1/yugabyte
LimitNOFILE=1048576
LimitNPROC=12000
RestartSec=5
ExecStartPre=/usr/bin/su -c "mkdir -p /opt/data/1/yugabyte && chown yugabyte:yugabyte /opt/data/1/yugabyte"
PermissionsStartOnly=True
User=yugabyte
TimeoutStopSec=300
Restart=always
[Install]
WantedBy=multi-user.target