redis緩存集群之Codis proxy變更

簡介

codis-proxy 是 codis 集群的代理轉發的應用,可以通過dashboard對codis-proxy進行操作,codis-proxy上不存儲數據,數據都在zookeeper上,。


redis緩存集群之Codis proxy變更


增加 proxy

如果集群設置了密碼,需要對應修改的配置文件參數是 product_auth,集群名稱 product_name 要一致。session_auth 是 proxy 節點的驗證,可以跟其他密碼不一樣。

配置

使用 codis-proxy 生成默認配置文件

<code>./codis-proxy  --default-config   | tee etc/proxy.toml
/<code>

修改 product_name 和 product_auth,整個集群的 product 相關信息要保持一致。session_auth 是用於連接的驗證,可以跟集群的驗證不一樣。如果短連接比較多可以調整一下 proxy_max_clients 參數。

<code>##################################################
# #
# Codis-Proxy #
# #
##################################################

# Set Codis Product Name/Auth.
product_name = "codis3"
product_auth = "h6oewuoaudPgCJRzYg0Uo"

# Set auth for client session
# 1. product_auth is used for auth validation among codis-dashboard,
# codis-proxy and codis-server.
# 2. session_auth is different from product_auth, it requires clients
# to issue AUTH <password> before processing any other commands.
session_auth = "L5SqVOieIOk7IyfYscCJcCdQBtHlK5Uq"

# Set bind address for admin(rpc), tcp only.
admin_addr = "0.0.0.0:11080"

# Set bind address for proxy, proto_type can be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
proto_type = "tcp4"
proxy_addr = "0.0.0.0:19000"

# Set jodis address & session timeout
# 1. jodis_name is short for jodis_coordinator_name, only accept "zookeeper" & "etcd".
# 2. jodis_addr is short for jodis_coordinator_addr
# 3. jodis_auth is short for jodis_coordinator_auth, for zookeeper/etcd, "user:password" is accepted.
# 4. proxy will be registered as node:
# if jodis_compatible = true (not suggested):
# /zk/codis/db_{PRODUCT_NAME}/proxy-{HASHID} (compatible with Codis2.0)
# or else
# /jodis/{PRODUCT_NAME}/proxy-{HASHID}
jodis_name = ""
jodis_addr = ""
jodis_auth = ""
jodis_timeout = "20s"
jodis_compatible = false

# Set datacenter of proxy.
proxy_datacenter = ""

# Set max number of alive sessions.
proxy_max_clients = 10000

# Set max offheap memory size. (0 to disable)
proxy_max_offheap_size = "1024mb"

# Set heap placeholder to reduce GC frequency.
proxy_heap_placeholder = "256mb"

# Proxy will ping backend redis (and clear 'MASTERDOWN' state) in a predefined interval. (0 to disable)
backend_ping_period = "5s"

# Set backend recv buffer size & timeout.
backend_recv_bufsize = "128kb"
backend_recv_timeout = "30s"

# Set backend send buffer & timeout.
backend_send_bufsize = "128kb"
backend_send_timeout = "30s"

# Set backend pipeline buffer size.
backend_max_pipeline = 20480

# Set backend never read replica groups, default is false
backend_primary_only = false

# Set backend parallel connections per server
backend_primary_parallel = 1

backend_replica_parallel = 1

# Set backend tcp keepalive period. (0 to disable)
backend_keepalive_period = "75s"

# Set number of databases of backend.
backend_number_databases = 16

# If there is no request from client for a long time, the connection will be closed. (0 to disable)
# Set session recv buffer size & timeout.
session_recv_bufsize = "128kb"
session_recv_timeout = "30m"

# Set session send buffer size & timeout.
session_send_bufsize = "64kb"
session_send_timeout = "30s"

# Make sure this is higher than the max number of requests for each pipeline request, or your client may be blocked.
# Set session pipeline buffer size.
session_max_pipeline = 10000

# Set session tcp keepalive period. (0 to disable)
session_keepalive_period = "75s"

# Set session to be sensitive to failures. Default is false, instead of closing socket, proxy will send an error response to client.
session_break_on_failure = false

# Set metrics server (such as http://localhost:28000), proxy will report json formatted metrics to specified server in a predefined period.
metrics_report_server = ""
metrics_report_period = "1s"

# Set influxdb server (such as http://localhost:8086), proxy will report metrics to influxdb.
metrics_report_influxdb_server = ""
metrics_report_influxdb_period = "1s"
metrics_report_influxdb_username = ""
metrics_report_influxdb_password = ""
metrics_report_influxdb_database = ""

# Set statsd server (such as localhost:8125), proxy will report metrics to statsd.
metrics_report_statsd_server = ""
metrics_report_statsd_period = "1s"
metrics_report_statsd_prefix = ""
/<password>/<code>

啟動命令

<code>nohup ./codis-proxy --ncpu=2 --config=./etc/proxy.toml --log=/data/codis/logs/proxy.log --log-level=WARN &
/<code>
<code>--ncpu 可以指定使用幾個 CPU 

--config 指定配置文件的路徑
--log 指定日誌文件路徑
--log-devel 指定日誌級別
/<code>


redis緩存集群之Codis proxy變更


添加的集群

通過 codis-fe 操作 codis-dashboard 添加 proxy,proxy admin address 的默認地址是:[IP]:11080。

刪除 proxy

刪除 proxy 的時候,需要先將對應的請求切走了,然後通過 codis-fe 操作 codis-dashboard,點擊對應 proxy 後面的減號進行刪除,刪除後proxy進程就會被關閉掉。


redis緩存集群之Codis proxy變更


分享到:


相關文章: