redis配置

Prerequistes

  • Centos

    1
    yum -y install tcl
  • Ubuntu

    1
    apt-get -y install build-essential tcl

redis源码编译安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
REDIS_VERSION=4.0.1
wget http://download.redis.io/releases/redis-$REDIS_VERSION.tar.gz
tar -zxvf redis-$REDIS_VERSION.tar.gz
cd redis-$REDIS_VERSION
make
make test
sudo make install
# Once the program has been installed
# Redis comes with a built in script that sets up Redis to run as a background daemon.
cd utils
sudo ./install_server.sh
# Start and stop
sudo service redis_6379 start
sudo service redis_6379 stop
# To set Redis to automatically start at boot, run:
sudo update-rc.d redis_6379 defaults

/etc/redis/6379.conf 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
➜  ~ grep -v "#" /etc/redis/6379.conf | grep -v "^$"
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis_6379.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis/6379
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

设置redis密码

1
2
3
4
5
6
7
8
9
10
# 搜索requirepass 即可查看密码,并且设置密码
vim /etc/redis/redis.conf
# 如果之前没有设置过密码可以通过密码命令行设置密码
CONFIG get requirepass;
# 设置密码
127.0.0.1:6379> CONFIG set requirepass "tutorialspoint"
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "tutorialspoint
分享到

nginx配置

centos 6.5配置

  • /etc/yum.repos.d/目录下创建一个源配置文件nginx.repo:

    cd /etc/yum.repos.d/

    vim nginx.repo

    填写如下内容:

    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1

    保存,则会产生一个/etc/yum.repos.d/nginx.repo文件。

  • 直接执行如下指令即可自动安装好Nginx:

    yum install nginx -y
    安装完成,下面直接就可以启动Nginx了:

    /etc/init.d/nginx start

    现在Nginx已经启动了,直接访问服务器就能看到Nginx欢迎页面了的。

  • 如果还无法访问,则需配置一下Linux防火墙。

    iptables -I INPUT 5 -i eth0 -p tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT

    service iptables save

    service iptables restart
    Nginx的命令以及配置文件位置:

    /etc/init.d/nginx start # 启动Nginx服务

    /etc/init.d/nginx stop # 停止Nginx服务

    /etc/nginx/nginx.conf # Nginx配置文件位置

    chkconfig nginx on #设为开机启动

    至此,Nginx已经全部配置安装完成。

  • nginx基础配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
一台主机上适应多个服务器:
在你的nginx通过代理的方式转发请求:配置如下
vi /etc/nginx/nginx.conf
在http加入下面的内容,参考:http://wiki.nginx.org/FullExample
http {
....
server {
listen 80;
server_name www.a.com;
charset utf-8;
access_log /home/a.com.access.log main;
location / {
proxy_pass http://127.0.0.1:80;
}
}

server {
listen 80;
server_name www.b.com;
charset utf-8;
access_log /home/b.com.access.log main;
location / {
proxy_pass http://127.0.0.1:81;
}
}
...
}

centos 7.0 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14

NGINX_VERSION=1.10.1

yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel

wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz

tar -zxvf nginx-$NGINX_VERSION.tar.gz

cd nginx-$NGINX_VERSION
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
make && make install

#sudo /usr/local/nginx/sbin/nginx

ubuntu 14.04 配置

1
2
3
4
5
6
7
8
9
10
11
12
13

NGINX_VERSION=1.10.1

apt-get -y install libpcre3-dev aptitude libssl-dev openssl libssl0.9.8 build-essential libtool

wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz

tar -zxvf nginx-$NGINX_VERSION.tar.gz

cd nginx-$NGINX_VERSION
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
make && make install

分享到

mysql配置

centos 6.5

1
2
3
yum -y update && yum -y upgrade
yum -y install mysql-server
service mysqld restart

centos 7.0

1
2
3
4
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-server
service mysqld restart

Ubuntu 16.04

1
2
3
4
5
6
7
8
9
# Remove
sudo apt-get remove mysql-*
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
# Install
sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation
systemctl status mysql.service
mysqladmin -p -u root version

/etc/my.cnf配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@namenode01 ~]# grep -v "#" /etc/my.cnf | grep -v "^$"
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
skip-character-set-client-handshake=true
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql]
default-character-set=utf8mb4
[mysqld]
lower_case_table_names=1
[client]
port = 3306
default-character-set=utf8mb4

设置用户

1
2
3
grant all privileges on *.* to 'root'@'%' identified by 'root';
flush privileges;

分享到