Loading...
My Blog 我的工作和学习笔记

CentOS 6.7上安装Redis 3.0.5

数据存储篇 2015/12/18 CentOS , Linux , Redis

在CentOS 6.7上安装Redis 3.0.5

#Redis是什么?

Redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。


#wget获取安装包并且安装

[root@centos1 data] wget http://download.redis.io/releases/redis-3.0.5.tar.gz

[root@centos1 data] tar xzf redis-3.0.5.tar.gz

[root@centos1 data] cd redis-3.0.5

[root@centos1 date] make


#安装过程中遇到的问题

1、提示没有“CC”编译器,于是安装“GCC”编译器

[root@centos1 date] yum install gcc

[root@centos1 date] make


2、提示“File `Makefile' has modification time 1.8e+06 s in the future”,将系统时间改为当前时间即可

[root@centos1 date] date -s "2015-11-08 15:15:00"

[root@centos1 date] make


3、提示“Newer version of jemalloc required”,“Leaving directory `/data/redis-3.0.5/src'”

[root@centos1 date] cd src

[root@centos1 src]  make MALLOC=libc


#启动服务并且使用内置客户端测试

[root@centos1 date] src/redis-server

......

359:M 08 Nov 15:28:30.429 * The server is now ready to accept connections on port 6379

说明启动成功,默认端口是:6379


[root@centos1 date] src/redis-cli

redis> set foo bar

OK

redis> get foo

"bar"


#结语

Redis的默认安装比较简单,默认安装启动没有在后台运行;指定配置文件启动可以配置为后台运行,IP、端口、主从配置、安全配置等等


#指定配置文件启动

redis-3.0.5根目录有一个配置文件example,将后台运行打开

[root@centos1 date] vi /data/redis-3.0.5/redis.conf


# By default Redis does not run as a daemon. Use 'yes' if you need it.

# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.

daemonize yes


指定配置文件开启服务

[root@centos1 date] src/redis-server /data/redis-3.0.5/redis.conf




参考文档

http://redis.io/

https://github.com/cinience/RedisStudio/releases

http://www.cnblogs.com/shanyou/archive/2012/01/28/2330451.html




Tungsten Replicator 4.0 Mysql同步MongoDB

数据存储篇 2015/10/13

虚拟主机和网络配置(略,详看http://www.imethan.cn/blog/article/73

在centos1安装mysql,centos2安装mongodb


MySQL安装(略)


MySQL数据库配置

vi my.cnf

binlog-format = row

#For MySQL 5.6.2 and later, you must enable full row log images:

binlog-row-image = full

character-set-server=utf8

collation-server=utf8_general_ci

mysql restart


MongoDB安装(略,详看http://docs.mongodb.org/manual/

MongoDB配置

vi  /etc/mongod.conf

#bind_ip=127.0.0.1

/etc/rc.d/init.d/mongod restart


tungsten-replicator安装配置


./tools/tpm configure alpha \

    --topology=master-slave \

    --master=centos1\

    --slaves=centos2 \

    --install-directory=/opt/continuent \

    --enable-heterogenous-service=true \

    --property=replicator.filter.pkey.addColumnsToDeletes=true \

    --property=replicator.filter.pkey.addPkeyToInserts=true  \


    #以下两行指定需要同步的数据库表

    --repl-svc-applier-filters=replicate \

    --property=replicator.filter.replicate.do=from_mysql.hellotable

    --start


./tools/tpm configure alpha --hosts=centos1 \

    --datasource-type=mysql \

    --replication-user=tungsten \

    --replication-password=123456 \

    --datasource-mysql-conf=/usr/my.cnf 


./tools/tpm configure alpha --hosts=centos2 \

    --datasource-type=mongodb

    

./tools/tpm install alpha


#更新同步数据表

./tools/tpm update alpha --hosts=centos1,centos2\

    --repl-svc-applier-filters=replicate \

    --property=replicator.filter.replicate.do=from_mysql.hellotable


#开启mongodb用户权限,更新配置

./tools/tpm update alpha --hosts=centos2 \

    --datasource-type=mongodb \

    --datasource-user=tungsten \

    --datasource-password=123456



#更新配置重启后生效

cd /opt/continuent/tungsten/tungsten-replicator/bin

./replicator restart


#查看当前配置

./tools/tpm reverse


#将Staging配置转换为INI配置

http://pubs.vmware.com/continuent/tungsten-replicator-4.0/cmdline-tools-tpm-ini.html#cmdline-tools-tpm-ini-conversion


参考:

http://docs.mongodb.org/manual/

http://pubs.vmware.com/continuent/tungsten-replicator-4.0/index.html

http://www.imethan.cn/blog/article/73


Tungsten Replicator 4.0 Mysql主从复制环境配置

数据存储篇 2015/09/23

前置条件:

两台CentOS 6.7虚拟机:centos1、centos2

分配的IP地址:centos1:192.168.42.133、centos2:192.168.42.134

Tungsten Replicator安装包:tungsten-replicator-oss-4.0.1-123.tar.gz 下载地址:https://code.google.com/p/tungsten-replicator/

MySql安装包:MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar   下载地址:http://dev.mysql.com/downloads/mysql/

JDK1.7


服务器主机和网络环境配置:

1、将centos1主机名称更改为centos1

uname -a 查看hostname

hostname centos1.imethan.cn 修改让hostname立刻生效

vi /etc/hosts 修改原hostname为 centos1.imethan.cn

vi  /etc/sysconfig/network 修改原hostname为 centos1.imethan.cn,这样可以让reboot重启后也生效

reboot重启,uname -a 重新检查


2、将centos2主机名称更改为centos2

同1


3、主机dns host配置 vi /etc/hosts

#centos1配置

#127.0.0.1 centos1.imethan.cn  centos1

::1 centos16.imethan.cn centos16

192.168.42.133  centos1.imethan.cn  centos1

192.168.42.134  centos2.imethan.cn  centos2


#centos2配置

#127.0.0.1 centos2.imethan.cn   localhost

::1 centos26.imethan.cn  centos26

192.168.42.133  centos1.imethan.cn   centos1

192.168.42.134  centos2.imethan.cn   centos2

3、添加用户tungsten

sudo adduser tungsten

sudo usermod -G mysql tungsten

4、ssh免密码登录配置,使得centos1和centos2相互免密码登录

ssh-keygen -t rsa -P ''

scp /home/tungsten/.ssh/id_rsa.pub tungsten@centos1:/home/tungsten/.ssh/authorized_keys

service sshd restart

5、安装JDK1.7(安装略

6、安装mysql(安装略

编辑配置文件,vi /usr/my.cnf在最后面添加如下内容

#other config

server-id = 1

open_files_limit = 65535

log-bin = mysql-bin

sync_binlog = 1

max_allowed_packet = 52m

default-storage-engine = InnoDB

innodb_flush_log_at_trx_commit = 2

innodb_flush_method=O_DIRECT

binlog-format = row

binlog-row-image = full

service mysql restart


添加配置mysql用户

CREATE USER tungsten@'%' IDENTIFIED BY '123456';GRANT ALL ON *.* TO tungsten@'%'  WITH GRANT OPTION;

CREATE USER tungsten@'centos1' IDENTIFIED BY '123456';GRANT ALL ON *.* TO tungsten@'centos1'  WITH GRANT OPTION;

CREATE USER tungsten@'centos2' IDENTIFIED BY '123456';GRANT ALL ON *.* TO tungsten@'centos2'  WITH GRANT OPTION;


防火墙端口开放:

ssh默认端口:22

mysql默认端口3306

Tungsten端口

ComponentSourceDestinationPortPurpose
Database ServiceDatabase HostDatabase Host7Checking availability
2112THL replication
10000-10001Replication connection listener port
ComponentPortPurpose
2114THL replication
10002-10003Replication connection listener ports
Client Application13306MySQL port for Connectivity
Manager Hosts7Communication between managers within multi-site, multi-master clusters


安装Tungsten Replicator

mkdir /opt/continuent/software

cd /opt/continuent/software

解压tungsten-replicator-oss-4.0.1-123.tar.gz至/opt/continuent/software

tar -zxvf tungsten-replicator-oss-4.0.1-123.tar.gz

cd tungsten-replicator-oss-4.0.1-123

#添加配置文件

vi /etc/tungsten/tungsten.ini

[one]

user=tungsten

topology=master-slave

install-directory=/opt/continuent

master=centos1

members=centos1,centos2

replication-user=tungsten

replication-password=123456

replication-port=3306

datasource-mysql-conf=/usr/my.cnf

start-and-report=true

profile-script=~/.bash_profile

#开始安装
./tools/tpm install

source /opt/continuent/share/env.sh


8、command命令使用

开机自启动:deployall

取消开机自启动:undeployall


cd /opt/continuent/tungsten/tungsten-replicator/bin

关闭:replicator stop

启动:replicator start


查看状态

trepctl services

trepctl status

trepctl -host host2 status


参考:

http://pubs.vmware.com/continuent/tungsten-replicator-4.0/index.html

https://code.google.com/p/tungsten-replicator/


RockMQ安装笔记

数据存储篇 2015/03/30

操作系统环境:CentOS 6.2 64Bit
1、安装 jdk1.6+,maven,git,

#配置java环境变量

vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_75
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
#配置maven环境变量
export MAVEN_HOME=/opt/apache-maven-3.3.1
export PATH=${MAVEN_HOME}/bin::$PATH

source /etc/profile 
2、编辑安装RockQM
cd /usr/local
cd RockMQ

#调用将所有文件转化为unix格式,如果没有该命令,安装之
dos2unix *

sh install.sh
将安装编译后程序 /usr/local/RocketMQ/target/alibaba-rocketmq/alibaba-rocketmq/  copy至/usr/local目录下
cd alibaba-rocketmq
cd bin

参考