Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Non-relational database NoSQL

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

General introduction of NoSQL

Http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=8660&highlight=NoSQL

Memcached introduction

1.3 memcached installation

Http://www.apelearn.com/bbs/thread-9285-1-1.html

Yum install-y epel-release

Rpm-qa epel-release

Yum install-y livevent memcached libmemcached

/ etc/init.d/memcached start

Netstat-lnp

Ps aux | grep memcached

Vi / etc/init.d/memcached

Cat / etc/sysconfig/memcached

-l listening server ip

Memcached-tool 127.0.0.1:11211 stats

Memstat-servers=127.0.0.1:11211

1.4 basic operation of Memcached

Telnet 127.0.0.1 11211

Set key3 123 200 3

one hundred and twenty three

Replace key3 123 210 4

1234

Get key3

Php connection memcached

Cd / usr/local/src/

Wget http://www.lishiming.net/data/p_w_upload/forum/memcache-2.2.3.tgz

Tar zxf memcache-2.2.3.tgz

Php download does not need to be installed or reinstalled from mysql.

Http://cn2.php.net/get/php-5.4.45.tar.bz2/from/this/mirror

Cd memcache-2.2.3

/ usr/local/php/bin/phpize

When running / usr/local/webserver/php/bin/phpize: Configuring for:PHP Api Version: 20041225Zend Module Api No: 20060613Zend Extension Api No: 220060519Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script. Solution # yum install masked yum install autoconf

. / configure-- with-php-config=/usr/local/php/bin/php-config

Make & & make install

Ls / usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/

Vim / usr/local/php/etc/php.ini

Cp / usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so / usr/local/php/ext

Ls! $

Vim / usr/local/php/etc/php.ini

Extension= "memcache.so" add

/ usr/local/php/bin/php-m

Wget www.apelearn.com/study_v2/.memcache.txt

/ usr/local/php/bin/php test.php

Memcached share Session

1.7 Redis introduction and installation

Http://www.apelearn.com/bbs/thread-9286-1-1.html

Cd / usr/local/src

Wget https://codeload.github.com/antirez/redis/tar.gz/2.8.21

Mv 2.8.21 redis-2.8.21.tar.gz

Tar zxvf redis-2.8.21.tar.gz

Yum install-y epel-rele

Yum install-y jemalloc-devel

Make

Make PREFIX=/usr/local/redis install

Mkdir / usr/local/redis/etc

Wget http://www.apelearn.com/study_v2/.redis_conf-O / usr/local/redis/etc/redis.conf 2 > / dev/null

Cat / usr/local/redis/etc/redis.conf

Wget http://www.apelearn.com/study_v2/.redis_init-O / usr/local/redis/etc/redis.conf 2 > / dev/null

Useradd-s / sbin/nologin redis

Mkdir / usr/local/redis/var

Chmod 777 / usr/local/redis/var/

Vi / etc/init.d/redis

Add startup script

Chmod 755 / etc/init.d/redis

Chkconfig-add redis

Service redis start

Redis data structure

/ usr/local/redis/bin/redis-cli

Alias redis-cli='/usr/local/redis/bin/redis-cli'

Vi .bshre

Cp / etc/skel/.bashrc .bashre copy without

# .bashre

# User specific allases and functions

Alias rm='rm-i'

Alias cp='cp-i'

Alias mv='mv-i'

Alias redis-cli='/usr/local/redis/bin/redis-cli'

# Source global definitions

If [- f / etc/bashrc]; then

. / etc/bashrc

Fi

Redis-cli

Set key1 aminglinux

OK

127.0.0.1 purl 6379 > get key1

"aminglinux"

127.0.0.1 purl 6379 > mset key1 aminglinux key2 hello key3 love

OK

127.0.0.1 purl 6379 > mget key1 key2 key3

1) "aminglinux"

2) "hello"

3) "love"

Redis-cli get key1

Whereis redis view file path installation address

List is a linked list structure, and its main functions are push, pop, getting all values in a range, and so on. The key in the operation is understood as the name of the linked list.

Lrange list1 0-1

1) "123 456"

2) "aaa"

127.0.0.1 purl 6379 > lpop list1

"123456"

127.0.0.1 purl 6379 > rpush list1 aaa

(integer) 2

127.0.0.1 lrange list1 6379 > 0-1

1) "aaa"

2) "aaa"

-set

Set is a set, which is similar to the concept of set in our mathematics. There are operations such as adding and deleting elements to the set, intersection and difference of multiple sets, and so on.

Zadd myset2 12 "abc"

(integer) 1

127.0.0.1 6379 > zadd myset2 12 "abc 123"

(integer) 1

127.0.0.1 6379 > zadd myset2 12 "123-aaa"

(integer) 1

127.0.0.1 zrange myset2 6379 > positive sequence 0-1

Reverse order of zrevrange myset2 0-1

Hset hash3 name aaa

(integer) 1

127.0.0.1 6379 > hset hash3 age 10

(integer) 1

127.0.0.1 purl 6379 > set hash3 sex nan

(error) ERR syntax error

127.0.0.1 purl 6379 > hset hash3 sex nan

(integer) 1

127.0.0.1 purl 6379 > hgettall hash3

(error) ERR unknown command 'hgettall'

127.0.0.1 purl 6379 > hgetall hash3

1) "name"

2) "aaa"

3) "age"

4) "10"

5) "sex"

6) "nan"

Hget hash3 age

1.9 Redis persistence

Explanation of 2.0 Redis configuration (part I)

Explanation of Redis configuration (part two)

Redis master-slave configuration

2.3 string type common commands

Common commands of hash type

Source .bashrc

Echo $PATH

Vi / etc/profile

Export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

2.5 list type common commands

Common commands of set type

Common commands of zset type

Key values and server commands

2.9 php uses Redis storage

Cd / usr/local/src

Wget https://codeload.github.com/phpredis/phpredis/zip/develop

Mv develop phpredis.zip

Yum install-y unzip

Unzip phpredis.zip

Cd phpredis-develop/

/ usr/local/php/bin/phpize

. / configure-- with-php-config=/usr/local/php/bin/php-config

Make

Make install

Vi / usr/local/php/etc/php.ini

Finally, add a line

Extension = redis.so

Vi / usr/local/apache2/conf/httpd.conf

# before the removal of servername

Add to lphp.ini

Session.save_handler = "redis"

Session.save_path = "tcp://127.0.0.1:6379"

Or apache virtual host to join.

Php_valuesession.save_handler "redis"

Php_valuesession.save_path "tcp://127.0.0.1:6379"

Or add to the pool corresponding to php-fpm.conf

Php_ value [session. Save _ handler] = redis

Php_ value [session. Save _ path] = "tcp://127.0.0.1:6379

3.0 MongoDB introduction

3.1 MongoDB installation

Http://www.apelearn.com/bbs/thread-9287-1-1.html

Vim / etc/yum.repos.d/mongodb-org-3.0.repo

Join:

[mongodb-org-3.0]

Name=MongoDB Repository

Baseurl= http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/

Gpgcheck=0

Enabled=1

Yum install-y mongodb-org

Ls / etc/init.d/mongod

Ls / etc/mongod.conf

Ls / var/log/mongodb/

Ls / var/lib/mongo/

Vim / etc/mongod.conf

/ etc/init.d/mongod start

Echo never > / sys/kernel/mm/transparent_hugepage/enabled

Echo never > / sys/kernel/mm/transparent_hugepage/defrag

Vim / etc/security/limits.con

Mongod soft nofile 64000

Mongod hard nofile 64000

Mongod soft nproc 32000

Mongod hard nproc 32000

Service mongod start

There was a startup error and the second startup failed.

Mongod-f / etc/mongod.conf

ERROR: child process failed, exited with error number 100

Rm / var/lib/mongo/mongod.lock delete and restart will be fine

MongoDB connection and user Management

Mongo

# create a user

Db.createUser ({user: "admin", pwd: "123456", roles: [{role:'dbOwner',db:'userdb'}]})

# View users

Db.system.users.find () / / lists all users. You need to switch to the admin library (use admin)

Show users / / View all users under the current library

# to delete a user, you need to switch to the admin library

Db.dropUser ('admin')

3.3 MongoDB library and collection management

Db.version ()

MongoDB replica set building

MongoDB replica set test

MongoDB backup and recovery

Php connection MongoDB

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 226

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report