三、安装cmake,安装resin
开发环境说明:
centos7.2 ,最低配置:1核cpu,2G内存,1M带宽
1、安装rz,sz命令,将安装包发送至服务器
yum install lrzsz
2、glibc-devel安装介绍
如果没有安装glibc的开发库,需要先安装。
yum install glibc-devel
3、安装gcc
yum install gcc
yum install gcc-c++
4、cmake安装介绍
解压:
tar zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./bootstrap (如果系统还没有安装CMake,源码中提供了一个 bootstrap 脚本)
make //比较耗时
make install (如果make install失败,一般是权限不够,切换root进行安装)
cmake -version //查看版本
5、resin安装
mv resin-4.0.49.tar.gz /usr/local/
tar zxvf resin-4.0.49.tar.gz //解压
ln -s resin-4.0.49 resin
四、tars服务,mysql 安装介绍
1、解压mysql
mv mysql-5.6.26.tar.gz /usr/local/
tar zxvf mysql-5.6.26.tar.gz
cd /usr/local/mysql-5.6.26
执行
-
yum install ncurses-devel
-
-
yum install zlib-devel
-
-
yum install bison
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.26 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
执行
-
make //比较耗时
-
make install
2、接着执行
-
groupadd mysql
-
useradd -g mysql mysql
-
-
chown mysql:mysql ../mysql-5.6.26
-
ln -s /usr/local/mysql-5.6.26 /usr/local/mysql
3、继续一行行复制粘贴执行
-
yum install perl
-
-
-
-
rm -rf /usr/local/mysql/data
-
mkdir -p /data/mysql-data
-
ln -s /data/mysql-data /usr/local/mysql/data
-
chown -R mysql:mysql /data/mysql-data /usr/local/mysql/data
-
-
cp support-files/mysql.server /etc/init.d/mysql
-
**如果/etc/目录下有my.cnf存在,需要把这个配置删除了**
-
rm /etc/my.cnf
4、
-
cd /usr/local/mysql-5.6.26
-
yum install -y perl-Module-Install.noarch
-
perl scripts/mysql_install_db --user=mysql
5、修改my.cnf
vim /usr/local/mysql/my.cnf
-
[mysqld]
-
-
# Remove leading # and set to the amount of RAM for the most important data
-
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
-
innodb_buffer_pool_size = 128M
-
-
# Remove leading # to turn on a very important data integrity option: logging
-
# changes to the binary log between backups.
-
log_bin
-
-
# These are commonly set, remove the # and set as required.
-
basedir = /usr/local/mysql
-
datadir = /usr/local/mysql/data
-
# port = .....
-
socket = /tmp/mysql.sock
-
-
bind-address=127.0.0.1
-
-
# Remove leading # to set options mainly useful for reporting servers.
-
# The server defaults are faster for transactions and fast SELECTs.
-
# Adjust sizes as needed, experiment to find the optimal values.
-
join_buffer_size = 128M
-
sort_buffer_size = 2M
-
read_rnd_buffer_size = 2M
-
-
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
6、启动和关闭mysql
-
cd /etc/init.d
-
chmod u+x mysql
-
启动mysql
-
service mysql start
-
chkconfig mysql on
-
结束mysql
-
service mysql stop
-
添加mysql库路径
-
-
vim /etc/ld.so.conf
-
/usr/local/mysql/lib/
-
ldconfig
7、修改环境变量
vim /etc/profile //修改环境变量
在环境变量末尾加入
-
PATH=$PATH:/usr/local/mysql/bin
-
-
-
#set java environment
-
JAVA_HOME=/usr/java/jdk1.8.0_171
-
JRE_HOME=/usr/java/jdk1.8.0_171/jre
-
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
-
MAVEN_HOME=/home/py/tarsframe/apache-maven-3.3.9
-
PATH=$PATH:$JAVA_HOME/bin:/home/py/tarsframe/cmake-3.9.0/bin:$JRE_HOME/bin:$MAVEN_HOME/bin:/sbin
-
export JAVA_HOME JRE_HOME CLASS_PATH MAVEN_HOME PATH
此次环境变量将mysql,jdk,maven,cmake一并修改完成
source /etc/profile
8、下面密码为mysql密码
-
service mysql start
-
cd /etc/init.d
-
mysqladmin -u root password '密码'//添加root密码
-
mysql --user=root --password=密码
-
grant all privileges on *.* to 'root'@'%' identified by '密码';
-
flush privileges;
五、tars服务,安装jdk,安装maven
1、解压jdk
-
cd /usr
-
mkdir java
-
mv jdk-8u171-linux-x64.tar.gz /usr/java
-
tar zxvf jdk-8u171-linux-x64.tar.gz
2、安装maven
-
mv apache-maven-3.3.9-bin.tar.gz /home/py/tarsframe
-
tar zxvf apache-maven-3.3.9-bin.tar.gz
3、java语言框架开发环境安装
-
cd /home/py/tarsframe/apache-maven-3.3.9/conf 修改settings.xml镜像
-
-
Linux(CentOS7)安装zip、unzip命令
-
yum install -y unzip zip
-
-
unzip Tars-master.zip
-
-
mv Tars-master /usr/local/
-
cd /usr/local/Tars-master/java
-
mvn clean install
-
mvn clean install -f core/client.pom.xml
-
mvn clean install -f core/server.pom.xml
4、国内阿里云镜像为
-
<mirror>
-
<id>nexus-aliyun</id>
-
<mirrorOf>*</mirrorOf>
-
<name>Nexus aliyun</name>
-
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
-
</mirror>
六、tars服务 c++ 开发环境安装
1、
-
下载tars源码,首先进入cpp/thirdparty目录,
-
cd /usr/local/Tars-master/cpp/thirdparty
-
chmod u+x thirdparty.sh
-
yum install -y git
-
执行thirdparty.sh脚本,下载依赖的rapidjson
-
./thirdparty.sh //比较耗时
2、
-
然后进入cpp/build源码目录
-
cd /usr/local/Tars-master/cpp/build
-
chmod u+x build.sh
-
yum install flex bison
-
./build.sh all //比较耗时
3、
-
编译时默认使用的mysql开发库路径:include的路径为/usr/local/mysql/include,lib的路径为/usr/local/mysql/lib/,
-
若mysql开发库的安装路径不在默认路径,则需要修改build目录下CMakeLists.txt文件中的mysql相关的路径,再编译
-
如果需要重新编译
-
./build.sh cleanall
-
./build.sh all
-
-
-
cd /usr/local
-
mkdir tars
-
chown mysql:mysql ./tars/
-
-
cd /usr/local/Tars-master/cpp/build
-
./build.sh install或者make install
默认的安装路径为/usr/local/tars/cpp
-
如要修改安装路径:
-
**需要修改build目录下CMakeLists.txt文件中的安装路径。**
-
**需要修改servant/makefile/makefile.tars文件中的TARS_PATH的路径**
-
**需要修改servant/script/create_tars_server.sh文件中的DEMO_PATH的路径**
4、tars数据库添加用户
-
tars数据库添加用户
-
mysql -uroot -proot
-
-
grant all on *.* to 'tars'@'%' identified by 'tars2015' with grant option;
-
grant all on *.* to 'tars'@'localhost' identified by 'tars2015' with grant option;
-
grant all on *.* to 'tars'@ '${主机名}' identified by 'tars2015' with grant option;
-
flush privileges;
-
**注意${主机名}需要修改成自身机器的名称,可以通过查看/etc/hosts
5、
-
创建数据库
-
sql脚本在cpp/framework/sql目录下,修改部署的ip信息
-
cd /usr/local/Tars-master/cpp/framework/sql
-
sed -i "s/192.168.2.131/${your machine ip}/g" `grep 192.168.2.131 -rl ./*`
-
sed -i "s/db.tars.com/${your machine ip}/g" `grep db.tars.com -rl ./*`
-
注意,192.168.2.131这个ip是tars开发团队当时部署服务测试的ip信息,替换成自己数据库的部署地址即可,不要是127.0.0.1
-
注意,db.tars.com是tars框架数据库部署的地址信息,替换成自己数据库的部署地址即可
也可以这样修改,把/usr/local/Tars-master/cpp/framework/sql下的sql文件下载到本地,
然后将192.168.2.131替换成Linux的内网地址,db.tars.com替换成localhost(我的做法是这样做的)
-
执行.
-
chmod u+x exec-sql.sh
-
vi exec-sql.sh //修改里面的mysql密码
-
./exec-sql.sh
exec-sql.sh的作用是生成tars数据库,并生成初始化的一些数据,记得需要将里面的mysql密码修改成自己的mysql密码
-
如果exec-sql.sh脚本执行出错,需要脚本里修改数据库用户名root对应的密码
-
脚本执行后,会创建3个数据库,分别是db_tars、tars_stat、tars_property。
-
其中db_tars是框架运行依赖的核心数据库,里面包括了服务部署信息、服务模版信息、服务配置信息等等;
-
tars_stat是服务监控数据存储的数据库;
-
tars_property是服务属性监控数据存储的数据库;