Squidのコンパイルとインストール、および基本的な操作

Squidのコンパイルとインストール、および基本的な操作

部門別データベースと非リレーショナルデータベース

関係データベース

一个结构化的数据库,创建在关系模型基础上
一般面向于记录
包括
    Oracle、Mysql、SQL Server、Microsoft Access、DB2等

非リレーショナルデータベース

除了主流的关系型数据库外的数据库,都认为是非关系型
包括
    Redis、MongoDB、Hbase、CouhDB等

Redis

前書き

Redisはメモリ上で実行され、永続性をサポートします

キーと値(キーと値のペア)の格納形式を使用する

利点
非常に高いデータの読み取りおよび書き込み速度
豊富なデータタイプ
をサポートデータの永続

をサポート原子性データのバックアップをサポート

redis(リモートディクショナリサーバー、リモートディクショナリサービス)は、ANSI C言語で記述されたオープンソースであり、BSDプロトコルに準拠し、ネットワークをサポートし、メモリの永続性を備えたログタイプおよびキー値データベースに基づくことができ、複数の言語でAPIを提供します。値は文字列、ハッシュ、リスト、セット、およびソート済みセットの場合があるため、通常は構造サーバーと呼ばれます。

Redisは完全にオープンソースで無料であり、高性能のKey-Valueデータベースです。

redisの機能

Redisはデータの永続性をサポートしています。メモリ内のデータベースはディスクに保存でき、再起動時に使用するために再度ロードできます。

Redisは単純なKey-Valueデータをサポートするだけでなく、リスト、セット、zset、ハッシュ、その他のデータ構造のストレージも提供します。Redis
はデータバックアップ、つまりマスタースレーブモードでのデータバックアップをサポートします(詳細は次の記事で説明します) redisクラスター)

Redisと他のKey-Valueの違い

Redisはより複雑なデータ構造を持ち、アトミック操作を提供します。これは、他のデータベースとは異なる進化のパスです。redisのデータ型は基本的なデータ構造に基づいており、追加の抽象化なしでプログラマーに透過的です。

Redisはメモリ内で実行されますが、ディスクに永続化できるため、データをハードウェアメモリより大きくすることはできないため、異なるデータセットを高速で読み書きする場合は、メモリを比較検討する必要があります。インメモリデータベースのもう1つの利点は、ディスク上の同じ複雑なデータ構造と比較して、メモリ内での操作が非常に簡単であるため、redisが内部で複雑な多くのことを実行できることです。同時に、ディスク形式に関しては、ランダムアクセスを必要としないため、コンパクトに追加された方法で作成されます。

Redisのインストールとデプロイ

操作步骤
    解压软件包
    make && make install
    设置Redis相关配置文件
    查看运行状态
编译安装Redis
[root@localhost ~]# yum -y install gcc gcc-c++ make
[root@localhost ~]# tar zxvf redis-5.0.7.tar.gz -C /opt/
[root@localhost ~]# cd /opt/redis-5.0.7/
[root@localhost redis-5.0.7]# make
[root@localhost redis-5.0.7]# make PREFIX=/usr/local/redis install
[root@localhost redis-5.0.7]# ln -s /usr/local/redis/bin/* /usr/local/bin/
[root@localhost redis-5.0.7]# cd /opt/redis-5.0.7/utils/
[root@localhost utils]# ./install_server.sh 
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] 
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] 
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] 
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
[root@localhost utils]# netstat -lnupt | grep redis
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      15435/redis-server 
[root@localhost utils]# /etc/init.d/redis_6379 start
[root@localhost utils]# /etc/init.d/redis_6379 stop
[root@localhost utils]# /etc/init.d/redis_6379 restart
[root@localhost utils]# /etc/init.d/redis_6379 status
[root@localhost utils]# vim /etc/redis/6379.conf 
  70 bind 127.0.0.1
  93 port 6379
 137 daemonize yes
 159 pidfile /var/run/redis_6379.pid
 167 loglevel notice
 172 logfile /var/log/redis_6379.log

  70 bind 127.0.0.1 192.168.20.10
配置参数
    bind:监听的主机地址
    port:端口
    daemonize yes:启用守护进程
    pidfile:指定PID文件
    loglevel notice:日志级别
    logfile:指定日志文件

Redisデータベースの一般的に使用されるコマンド
Redis-cliコマンドラインツール

コマンドヘルプ
ヘルプの取得@:コマンド
ヘルプのリストの取得:コマンドヘルプのヘルプの取得:役立つ
可能性のあるトピックのリストの取得

セット:データの保存

get:データを取得します

キー関連
キー:シンボルルールのキー値リストが
存在するかどうかを取得します:キー値が存在するかどうかを判断します
del:現在のデータベースの指定されたキー
タイプを削除します
名前変更(上書き)/名前変更(上書きではない)に対応するキーの値タイプを取得します既存のKey rename
dbsize:現在のデータベース
Redis-benchmarkテストツールのキーの数を表示します

    -h:指定服务器主机名

    -p:指定服务器端口

    -c:指定请求数

    -d:以字节的形式指定set/get值的数据大小

    -q:强制退出Redis,仅显示query/sec值
 [root@localhost utils]# /etc/init.d/redis_6379 restart
[root@localhost utils]# redis-cli -h 192.168.20.10 -p 6379
192.168.20.10:6379> 
[root@localhost utils]# redis-cli 
127.0.0.1:6379> 

192.168.20.10:6379> keys *
(empty list or set)
192.168.20.10:6379> quit

192.168.20.10:6379> help @list

  BLPOP key [key ...] timeout
  summary: Remove and get the first element in a list, or block until one is available
  since: 2.0.0
......

192.168.20.10:6379> help keys

  KEYS pattern
  summary: Find all keys matching the given pattern
  since: 1.0.0
  group: generic

192.168.20.10:6379> set color yellow
OK
192.168.20.10:6379> keys *
1) "color"
192.168.20.10:6379> get color
"yellow"
192.168.20.10:6379> del color
(integer) 1
192.168.20.10:6379> keys per???
1) "person"
192.168.20.10:6379> keys per*
1) "person"
筛选键名模糊查询的时候 可以用* ?通配符
192.168.20.10:6379> type person
string
192.168.20.10:6379> exists person 
(integer) 1
192.168.20.10:6379> exists color
(integer) 0
192.168.20.10:6379> rename person name
OK
192.168.20.10:6379> keys *
1) "name"
192.168.20.10:6379> dbsize
(integer) 1  
[root@localhost utils]# /usr/local/redis/bin/redis-benchmark -h 192.168.20.10 -p 6379 -q -d 100
192.168.20.10:6379> select 3
OK
192.168.20.10:6379[3]> set num 10
OK
192.168.20.10:6379[3]> move num 4
(integer) 1
192.168.20.10:6379[3]> keys *
(empty list or set)
192.168.20.10:6379[3]> select 4
OK
192.168.20.10:6379[4]> keys *
1) "num"
192.168.20.10:6379[4]> get num
"10"

设置hash结构
192.168.20.10:6379> hset person name zhangsan
(integer) 1
192.168.20.10:6379> hset person age 25
(integer) 1
192.168.20.10:6379> hset person score 60
(integer) 1
192.168.20.10:6379> keys *
1) "person"
2) "mylist"
3) "name"
4) "myset:__rand_int__"
5) "key:__rand_int__"
6) "counter:__rand_int__"
192.168.20.10:6379> hget person name
"zhangsan"
192.168.20.10:6379> hget person age
"25"
192.168.20.10:6379> hget person score
"60"


[root@localhost utils]# cd /var/lib/redis/6379/
[root@localhost 6379]# ll
总用量 232
-rw-r--r--. 1 root root 233891 98 17:31 dump.rdb

[root@localhost 6379]# vim /etc/redis/6379.conf      
save 900 1
save 300 10
save 60 10000
dbfilename dump.rdb
dir /var/lib/redis/6379                         
rdbcompression yes

[root@localhost 6379]# vim /etc/redis/6379.conf      
appendonly yes
appendfilename "appendonly.aof"
# appendfsync always
appendfsync everysec
# appendfsync no
aof-load-truncated yes

[root@localhost 6379]# /etc/init.d/redis_6379 restart
[root@localhost 6379]# ll
总用量 232
-rw-r--r--. 1 root root      0 98 18:50 appendonly.aof
-rw-r--r--. 1 root root 233945 98 18:50 dump.rdb

[root@localhost 6379]# redis-cli -h 192.168.20.10 -p 6379
192.168.20.10:6379> info memory
# Memory
used_memory:853320
used_memory_human:833.32K
used_memory_rss:10493952
used_memory_rss_human:10.01M
used_memory_peak:853320
used_memory_peak_human:833.32K
used_memory_peak_perc:100.01%
used_memory_overhead:841094
used_memory_startup:791400
used_memory_dataset:12226
used_memory_dataset_perc:19.74%
allocator_allocated:1661928
allocator_active:2068480
allocator_resident:9187328
total_system_memory:3954188288
total_system_memory_human:3.68G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.24
allocator_frag_bytes:406552
allocator_rss_ratio:4.44
allocator_rss_bytes:7118848
rss_overhead_ratio:1.14
rss_overhead_bytes:1306624
mem_fragmentation_ratio:12.92
mem_fragmentation_bytes:9681656
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:49694
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0

おすすめ

転載: blog.csdn.net/weixin_46355881/article/details/108559083