Tokyo tyrant (ttserver) series-startup parameters and Configuration [ Article Author: Sun Li link: http://www.cnblogs.com/sunli/ Update Time: Start parameter introduction continue previous Tokyo tyrant (ttserver) series-introduction and we continue to look at start parameters and configuration. The ttserver command can start a database instance. Because the database has implemented the abstract API of Tokyo cabinet, you can specify the database configuration type at startup.
Supported database types include:
- Memory hash Database
- Memory tree Database
- Hash Database
- B + tree database,
The command is used in the following format. 'dbname' specifies the database name. If it is omitted, it is regarded as a memory hash database.
Ttserver [-host
Name
] [-Port
Num
] [-Th
Num
Num
] [-Tout
Num
] [-DMN] [-PID
Path
] [-Log
Path
] [-LD |-le] [-ulog
Path
] [-Ulim
Num
] [-UAS] [-Sid
Num
] [-Mhost
Name
] [-Mport
Num
] [-RTS
Path
] [-Ext
Path
] [-Extpc
Name
Period
] [-Mask
Expr
] [
Dbname
] The following describes the functions of these parameters:
-
-HostName : Specify the hostname or IP address of the server. All IP addresses of the default server are bound. For example, if an IP address such as 127.0.0.1 is specified, it can be accessed locally.
-PortNum : Specify the port to start the service. The default value is 1978. If you want to start multiple database instances, the ports must be different.
-
-ThnumNum : Specifies the number of threads that the Service is working on. Default Value: 8.
-ToutNum : Specify the timeout time for each session. It never times out by default.
-
-DMN : Run as a daemon.
-
-PIDPath : Output the process IP address to the specified file.
-LogPath : Output log information to the specified file.
-
-LD : The debug information is recorded in the log.
-
-Le : Only error messages are recorded in logs.
-UlogPath : Specifies the directory where update logs are stored. It can be used to back up and restore databases and synchronize data between master and slave databases.
-
-UlimNum : Specify the size limit for each update log file.
-
-UAS : Update logs using asynchronous Io records. (Using this option can reduce the I/O overhead for writing logs, but when the server is shut down unexpectedly, the process may lose data when it is killed. Based on experience, it is generally unavailable ).
-SidNum : ID of the service. Different idnumbers are used to identify master-slave replication.
-
-MhostName : Specifies the IP address or domain name of the master server in master-slave replication mode.
-MportNum : Specifies the port number of the master server in master-slave mode.
-
-RTSPath : Specifies the timestamp used for master-slave replication to store files.
-ExtPath : Specify the extension script language file.
-
-ExtpcName Period : Specify the name and interval of the function to be called periodically.
-MaskExpr : Specifies the command name to be banned (for example, clear vanish is prohibited ).
-
-UnmaskExpr : Specifies the allowed command name.
|
- Database Type
- Next let's take a look at the detailed configuration of the database type.
- The database name naming method is specified by the abstract API of Tokyo cabinet.
- If the database name is "*", it indicates the memory hash database.
- If the database name is "+", it indicates the memory tree database.
- If the database name is ". Tch", the database is a hash database.
- If the database name is suffixed with ". TCB", the database is B + tree.
- If the database name is suffixed with ". TCF ". The database is fixed-length.
- If the database name is suffixed with ". TCT", the data will be a table database (with the concept of a table ).
Database adjustment parameters are specified by database name extension and separated by "#". Each parameter is specified by a parameter name and value, separated by "=. The memory hash Database supports "bnum", "capnum", and "capsiz" memory tree databases support "capnum" and "capsiz" capnum to specify the maximum capacity of records, capsiz specifies the maximum memory usage (in the memory database) and records are removed in the order of storage. The hash Database supports "Mode", "bnum", "apow", "fpow", "opts", "rcnum", and "xmsiz ".
'Rcnum' specifies the maximum number of cache records. If it is not greater than zero, the cache record is unavailable. Unavailable by default.
Xmsiz specifies the size of the external memory. If it is not greater than 0, the memory is unavailable. The default value is 67108864, that is, 64 m.
'Bnum' specifies the number of buckets. If the specified number is not greater than 0, the default value 131071 will be used. The recommended quantity should be 0.4-4 times the total number of all records to be stored.
'Aw' indicates the number of records associated with a key, which is expressed by the Npower of 2. If this parameter is not specified, the default value is 2 ^ 4 = 16.
'Fpow' specifies the maximum number of elements of the free block pool by power of 2. Default 2 ^ 10 = 1024.
'Opts' specifies the option, bit or: 'hdbtlarge' specifies the database size. By using a 64-Bit Array bucket, it can exceed 2 GB.
'Hdbtdeflate' indicates that each record is compressed by deflate encoding.
'Hdbtbzip' indicates that each record is compressed by Bzip2 encoding.
'Hdbttcbs 'indicates that each record is compressed by TCBs encoding. .
B + tree databases support "Mode", "lmemb", "nmemb", "bnum", "apow", "fpow", "opts", "lcnum ", "ncnum", and "xmsiz ". the fixed-length Database supports "Mode", "width", and "limsiz ". table Database supports "Mode", "bnum", "apow", "fpow", "opts", "rcnum", "lcnum", "ncnum", "xmsiz ", and "idx" "idx" specify the index of the table. "Mode" can contain "W" write, "R" read, "C" created, "T" truncated, "E" unlocked, and "F" non-blocking locks. Default The MOD is "WC ". To optimize the performance, we can specify # Bnum = xxx to improve performance. XXX is greater than or equal to the total number of our records. If you use B + tree databases, you can specify"# Lcnum = xxx # bnum = yyy" to improve performance. the first parameter specifies the maximum number of cached leaf nodes, which is limited by the memory capacity. The second parameter specifies the number of buckets, which should be greater than 1/128 of the total number of records. If there are a large number of client connections, make sure that our file descriptor is sufficient. The default value is 1024. We can use "ulimit" to reset the startup script for the following standalone instance (a script running online ):
#! /Bin/shulimit-shn 51200 ttserver-host 192.168.0.136-port 11212-thnum 8-DMN-PID/data/ttserver. PID-log/data/ttserver. log-le-ulog/data/ttserver/-ulim 128 M-Sid 1-RTS/data/ttserver. RTS/data/ttserver/database. tch # bnum = 10000000 # xmsiz = 434217728 # rcnum = 20000 |
When a hash database is used, a maximum of 20000 records are cached, and the maximum memory usage is 434217728 bytes (414 MB ),Number of buckets10000000.Current Library size:
-RW-r -- 1 Root 28g Mar 8 12:19 bbsdatabase. Tch |
Because the 64-bit operating system is used, the file size is not limited to 2 GB. Let's look at the data reading speed:
The current time for obtaining memcache threads_cdb_threads_tid3565732_displayorder_0 is 0.00054812431335449 |
The above isProgramThe printed key is readMemcache threads_cdb_threads_tid3565732_displayorder_0 takes 0.00054812431335449 (s) of data, and the speed is very fast.
It is recommended that you modify Ttservctl. Below are some simple startup examples. Single-host startup example:Ttservctl File:
#! /Bin/sh # repository # STARTUP script for the server of Tokyo tyrant # repository # configuration variablesprog = "ttservctl" cmd = "ttserver" basedir = "/var/ttserver" # database storage path, for example, change to "/data/mydata" Port = "1978" # Start port pidfile = "$ basedir/PID" logfile = "$ basedir/log" ulogdir = "$ basedir/ulog "ulimsiz =" 256 m "SID = 1 dbname =" $ basedir/casket. tch # bnum = 1000000 "# The preceding Database Type Configuration maxcon =" 65536 "retval = 0 |
The dual-host mode is the active/standby mode. For example, the IP addresses of the two machines are 192.168.1.176 and 192.168.1.1.177, respectively.Part of the ttservctl file.176 Configuration:
#! /Bin/sh # repository # STARTUP script for the server of Tokyo tyrant # repository # configuration variablesprog = "ttservctl" cmd = "ttserver" basedir = "/data/data1" Port = "11211" pidfile = "$ basedir/PID" logfile = "$ basedir/log" ulogdir = "$ basedir/" mhost = "192.168.1.177" # The primary IP address is the ipulimsiz of another machine. = "256 m" SID = 6 # note that each machine must be different dbname = "$ basedir/casket. tch # bnum = 100000000 # xmsiz = 104857600 # rcnum = 1000000 "RTS =" $ basedir/ttserver. RTS "# In Added Based on ttservctl Maxcon= "65536" retval = 0 # locale clearlang = clc_all = cexport Lang lc_all # Start the serverstart () {printf 'starting the server of Tokyo tyrant \ n' ulimit-n "$ maxcon" mkdir-P "$ basedir" If [-F "$ pidfile"]; then pid = 'cat "$ pidfile" 'printf' existing process: % d \ N' "$ PID" retval = 1 else $ cmd \-port "$ port" \-DMN \-pid "$ pidfile" \-log "$ logfile "\ -ulog "$ ulogdir" \-ulim "$ ulimsiz" \-Sid "$ Sid" \-mhost "$ mhost" \ # In Added Based on ttservctl -Mport "$ port" \ # In Added Based on ttservctl -RTS "$ RTS" \ # In Added Based on ttservctl "$ Dbname" If ["$? "-EQ 0]; then printf 'done \ n' else printf' the server cocould not started \ n' retval = 1 fi} |
177 Configuration:
#! /Bin/sh # repository # STARTUP script for the server of Tokyo tyrant # repository # configuration variablesprog = "ttservctl" cmd = "ttserver" basedir = "/data/data1" Port = "11211" pidfile = "$ basedir/PID" logfile = "$ basedir/log" ulogdir = "$ basedir/" mhost = "192.168.1.176" # The primary IP address is the ipulimsiz of another machine. = "256 m" SID = 7 # note that each machine must be different dbname = "$ basedir/casket. tch # bnum = 100000000 # xmsiz = 104857600 # rcnum = 1000000 "RTS =" $ basedir/ttserver. RTS "# In Added Based on ttservctl Maxcon= "65536" retval = 0 # locale clearlang = clc_all = cexport Lang lc_all # Start the serverstart () {printf 'starting the server of Tokyo tyrant \ n' ulimit-n "$ maxcon" mkdir-P "$ basedir" If [-F "$ pidfile"]; then pid = 'cat "$ pidfile" 'printf' existing process: % d \ N' "$ PID" retval = 1 else $ cmd \-port "$ port" \-DMN \-pid "$ pidfile" \-log "$ logfile "\ -ulog "$ ulogdir" \-ulim "$ ulimsiz" \-Sid "$ Sid" \-mhost "$ mhost" \ # In Added Based on ttservctl -Mport "$ port" \ # In Added Based on ttservctl -RTS "$ RTS" \ # In Added Based on ttservctl "$ Dbname" If ["$? "-EQ 0]; then printf 'done \ n' else printf' the server cocould not started \ n' retval = 1 fi} |