Skip to content

Commit

Permalink
Merge branch 'master' into timestamp-binlog
Browse files Browse the repository at this point in the history
  • Loading branch information
wenduo committed Jun 29, 2016
2 parents 9728f93 + 4ec72d1 commit b2f6d21
Show file tree
Hide file tree
Showing 21 changed files with 331 additions and 267 deletions.
58 changes: 29 additions & 29 deletions conf/pika.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Pika port
port : 9221
# Thread Number
thread_num : 1
thread-num : 1
# Sync Thread Number
sync_thread_num : 6
sync-thread-num : 6
# Item count of sync thread queue
sync_buffer_size : 10
sync-buffer-size : 10
# Pika log path
log_path : ./log/
# Pika glog level
log_level : 0
log-path : ./log/
# Pika glog level: only INFO and ERROR
loglevel : 0
# Pika db path
db_path : ./db/
# Pika write_buffer_size
write_buffer_size : 268435456
db-path : ./db/
# Pika write-buffer-size
write-buffer-size : 268435456
# Pika timeout
timeout : 60
# Requirepass
Expand All @@ -23,40 +23,40 @@ userpass :
# User Blacklist
userblacklist :
# Dump Prefix
dump_prefix :
dump-prefix :
# daemonize [yes | no]
#daemonize : yes
# Dump Path
dump_path : ./dump/
dump-path : ./dump/
# pidfile Path
pidfile : ./pika.pid
# Max Connection
maxconnection : 20000
maxclients : 20000
# the per file size of sst to compact, defalut is 2M
target_file_size_base : 20971520
# Expire_logs_days
expire_logs_days : 7
# Expire_logs_nums
expire_logs_nums : 10
# Root_connection_num
root_connection_num : 2
# Slowlog_log_slower_than
slowlog_log_slower_than : 10000
target-file-size-base : 20971520
# Expire-logs-days
expire-logs-days : 7
# Expire-logs-nums
expire-logs-nums : 10
# Root-connection-num
root-connection-num : 2
# Slowlog-log-slower-than
slowlog-log-slower-than : 10000
# slave-read-only(yes/no, 1/0)
slave_read_only : 0
slave-read-only : 0
# Pika db sync path
db_sync_path : ./dbsync/
db-sync-path : ./dbsync/
# db sync speed(MB) max is set to 125MB, min is set to 0, and if below 0 or above 125, the value will be adjust to 125
db_sync_speed : -1
db-sync-speed : -1

###################
## Critical Settings
###################
# binlog file size: default is 100M, limited in [1K, 2G]
binlog_file_size : 104857600
binlog-file-size : 104857600
# Compression
compression : snappy
# max_background_flushes: default is 1, limited in [1, 4]
max_background_flushes : 1
# max_background_compactions: default is 1, limited in [1, 4]
max_background_compactions : 1
# max-background-flushes: default is 1, limited in [1, 4]
max-background-flushes : 1
# max-background-compactions: default is 1, limited in [1, 4]
max-background-compactions : 1
6 changes: 3 additions & 3 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PikaConf : public slash::BaseConf {
int expire_logs_days() { RWLock l(&rwlock_, false); return expire_logs_days_; }
std::string conf_path() { RWLock l(&rwlock_, false); return conf_path_; }
bool readonly() { RWLock l(&rwlock_, false); return readonly_; }
int maxconnection() { RWLock l(&rwlock_, false); return maxconnection_; }
int maxclients() { RWLock l(&rwlock_, false); return maxclients_; }
int root_connection_num() { RWLock l(&rwlock_, false); return root_connection_num_; }
int slowlog_slower_than() { RWLock l(&rwlock_, false); return slowlog_log_slower_than_; }

Expand Down Expand Up @@ -100,7 +100,7 @@ class PikaConf : public slash::BaseConf {
}
void SetMaxConnection(const int value) {
RWLock l(&rwlock_, true);
maxconnection_ = value;
maxclients_ = value;
}
void SetRootConnectionNum(const int value) {
RWLock l(&rwlock_, true);
Expand Down Expand Up @@ -140,7 +140,7 @@ class PikaConf : public slash::BaseConf {

//char pidfile_[PIKA_WORD_SIZE];
std::string compression_;
int maxconnection_;
int maxclients_;
int root_connection_num_;
int slowlog_log_slower_than_;
int expire_logs_days_;
Expand Down
2 changes: 2 additions & 0 deletions include/pika_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct SlaveItem {
struct timeval create_time;
};

#define PIKA_MIN_RESERVED_FDS 5000

#define SLAVE_ITEM_STAGE_ONE 1
#define SLAVE_ITEM_STAGE_TWO 2

Expand Down
2 changes: 1 addition & 1 deletion pikatests/tests/assets/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dump_path : ./dump/
# pidfile Path
pidfile : ./pika.pid
# Max Connection
maxconnection : 20000
maxclients : 20000
# the per file size of sst to compact, defalut is 2M
target_file_size_base : 20971520
# Expire_logs_days
Expand Down
20 changes: 18 additions & 2 deletions src/pika.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <glog/logging.h>
#include <sys/resource.h>
#include "pika_server.h"
#include "pika_command.h"
#include "pika_conf.h"
Expand Down Expand Up @@ -74,7 +75,7 @@ static void create_pid_file(void) {
}

static void IntSigHandle(const int sig) {
DLOG(INFO) << "Catch Signal " << sig << ", cleanup...";
LOG(INFO) << "Catch Signal " << sig << ", cleanup...";
g_pika_server->Exit();
}

Expand Down Expand Up @@ -132,6 +133,21 @@ int main(int argc, char *argv[]) {

PikaConfInit(path);

rlimit limit;
if (getrlimit(RLIMIT_NOFILE,&limit) == -1) {
LOG(WARNING) << "getrlimit error: " << strerror(errno);
} else if (limit.rlim_cur < g_pika_conf->maxclients() + PIKA_MIN_RESERVED_FDS) {
rlim_t old_limit = limit.rlim_cur;
rlim_t best_limit = g_pika_conf->maxclients() + PIKA_MIN_RESERVED_FDS;
limit.rlim_cur = best_limit > limit.rlim_max ? limit.rlim_max-1 : best_limit;
limit.rlim_max = best_limit > limit.rlim_max ? limit.rlim_max-1 : best_limit;
if (setrlimit(RLIMIT_NOFILE,&limit) != -1) {
LOG(WARNING) << "your 'limit -n ' of " << old_limit << " is not enough for Redis to start. pika have successfully reconfig it to " << limit.rlim_cur;
} else {
LOG(FATAL) << "your 'limit -n ' of " << old_limit << " is not enough for Redis to start. pika can not reconfig it(" << strerror(errno) << "), do it by yourself";
}
}

// daemonize if needed
if (g_pika_conf->daemonize()) {
daemonize();
Expand All @@ -143,7 +159,7 @@ int main(int argc, char *argv[]) {
PikaSignalSetup();
InitCmdInfoTable();

DLOG(INFO) << "Server at: " << path;
LOG(INFO) << "Server at: " << path;
g_pika_server = new PikaServer();

if (g_pika_conf->daemonize()) {
Expand Down
Loading

0 comments on commit b2f6d21

Please sign in to comment.